Removing old svn keywords.
[monky] / src / top.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
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.
12  *      (see AUTHORS)
13  * All rights reserved.
14  *
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.
19  *
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/>.
26  *
27  */
28
29 #ifndef _top_h_
30 #define _top_h_
31
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. */
36
37 /******************************************
38  * Includes                                                               *
39  ******************************************/
40
41 #include "conky.h"
42 #define CPU_THRESHHOLD  0       /* threshhold for the cpu diff to appear */
43 #include <time.h>
44 #include <dirent.h>
45 #include <string.h>
46 #include <fcntl.h>
47 #include <unistd.h>
48 #include <ctype.h>
49 #include <math.h>
50 #include <assert.h>
51 #include <limits.h>
52 #include <errno.h>
53 #include <signal.h>
54
55 #include <sys/wait.h>
56 #include <sys/stat.h>
57 #include <sys/types.h>
58 #include <sys/ioctl.h>
59 #include <sys/time.h>
60
61 #include <regex.h>
62
63 /******************************************
64  * Defines                                                                *
65  ******************************************/
66
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
70
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
75
76 enum top_field {
77         TOP_CPU,
78         TOP_NAME,
79         TOP_PID,
80         TOP_MEM,
81         TOP_TIME,
82         TOP_MEM_RES,
83         TOP_MEM_VSIZE
84 };
85
86 /******************************************
87  * Process class                                                  *
88  ******************************************/
89
90 struct process {
91         struct process *next;
92         struct process *previous;
93
94         pid_t pid;
95         char *name;
96         float amount;
97         // User and kernel times are in hundredths of seconds
98         unsigned long user_time;
99         unsigned long total;
100         unsigned long kernel_time;
101         unsigned long previous_user_time;
102         unsigned long previous_kernel_time;
103         unsigned long total_cpu_time;
104         unsigned int vsize;
105         unsigned int rss;
106         unsigned int time_stamp;
107         unsigned int counted;
108         unsigned int changed;
109         float totalmem;
110 };
111
112 struct sorted_process {
113         struct sorted_process *greater;
114         struct sorted_process *less;
115         struct process *proc;
116 };
117
118 /* Pointer to head of process list */
119 void process_find_top(struct process **, struct process **);
120
121 #endif /* _top_h_ */