1 /* Conky, a system monitor, based on torsmo
3 * Any original torsmo code is licensed under the BSD license
5 * All code written since the fork of torsmo is licensed under the GPL
7 * Please see COPYING for details
9 * Copyright (c) 2005 Adi Zaimi, Dan Piponi <dan@tanelorn.demon.co.uk>,
10 * Dave Clark <clarkd@skynet.ca>
11 * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
13 * All rights reserved.
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 /* Ensure there's an operating system defined.
33 * compile with gcc -DOS ...
34 * There is *no* default because every OS has it's own way of revealing
35 * CPU/memory usage. */
37 /******************************************
39 ******************************************/
42 #define CPU_THRESHHOLD 0 /* threshhold for the cpu diff to appear */
57 #include <sys/types.h>
58 #include <sys/ioctl.h>
63 /******************************************
65 ******************************************/
67 /* XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so lame
68 * and it'll take me a while to write a replacement. */
69 #define BUFFER_LEN 1024
71 #define PROCFS_TEMPLATE "/proc/%d/stat"
72 #define PROCFS_TEMPLATE_MEM "/proc/%d/statm"
73 #define PROCFS_CMDLINE_TEMPLATE "/proc/%d/cmdline"
74 #define MAX_SP 10 // number of elements to sort
86 /******************************************
88 ******************************************/
92 struct process *previous;
97 // User and kernel times are in hundredths of seconds
98 unsigned long user_time;
100 unsigned long kernel_time;
101 unsigned long previous_user_time;
102 unsigned long previous_kernel_time;
103 unsigned long total_cpu_time;
106 unsigned int time_stamp;
107 unsigned int counted;
108 unsigned int changed;
112 struct sorted_process {
113 struct sorted_process *greater;
114 struct sorted_process *less;
115 struct process *proc;
118 /* Pointer to head of process list */
119 void process_find_top(struct process **, struct process **);