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 */
59 #include <sys/param.h>
60 #include <sys/types.h>
61 #include <sys/ioctl.h>
66 /******************************************
68 ******************************************/
70 /* XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so lame
71 * and it'll take me a while to write a replacement. */
72 #define BUFFER_LEN 1024
74 #define PROCFS_TEMPLATE "/proc/%d/stat"
75 #define PROCFS_TEMPLATE_MEM "/proc/%d/statm"
76 #define PROCFS_CMDLINE_TEMPLATE "/proc/%d/cmdline"
77 #define MAX_SP 10 // number of elements to sort
79 /******************************************
81 ******************************************/
85 struct process *previous;
90 // User and kernel times are in hundredths of seconds
91 unsigned long user_time;
93 unsigned long kernel_time;
94 unsigned long previous_user_time;
95 unsigned long previous_kernel_time;
96 unsigned long total_cpu_time;
99 unsigned int time_stamp;
100 unsigned int counted;
101 unsigned int changed;
105 struct sorted_process {
106 struct sorted_process *greater;
107 struct sorted_process *less;
108 struct process *proc;
111 /* Pointer to head of process list */
112 void process_find_top(struct process **, struct process **);