1sg_get_process_stats(3)    Library Functions Manual    sg_get_process_stats(3)
2
3
4

NAME

6       sg_get_process_stats,   sg_get_process_count,  sg_process_compare_name,
7       sg_process_compare_pid, sg_process_compare_uid, sg_process_compare_gid,
8       sg_process_compare_size,     sg_process_compare_res,    sg_process_com‐
9       pare_cpu, sg_process_compare_time - get process statistics
10

SYNOPSIS

12       #include <statgrab.h>
13
14
15       sg_process_stats *sg_get_process_stats(int *entries);
16
17       sg_process_count *sg_get_process_count(void);
18
19       int sg_process_compare_name(const void *va, const void *vb);
20
21       int sg_process_compare_pid(const void *va, const void *vb);
22
23       int sg_process_compare_uid(const void *va, const void *vb);
24
25       int sg_process_compare_gid(const void *va, const void *vb);
26
27       int sg_process_compare_size(const void *va, const void *vb);
28
29       int sg_process_compare_res(const void *va, const void *vb);
30
31       int sg_process_compare_cpu(const void *va, const void *vb);
32
33       int sg_process_compare_time(const void *va, const void *vb);
34

DESCRIPTION

36       The sg_get_process_stats takes a pointer to an int, entries,  which  is
37       filled  with  the number of processes the snapshot contains. The return
38       value is a pointer to the first member of an array of  sg_process_stats
39       structures; the number of entries in the array is returned in entries.
40
41       sg_get_process_count  returns  a  pointer  to  a  static buffer of type
42       sg_process_count.
43
44       These two functions provide information on the process running  on  the
45       system. In the first case lots of detail is provided, and in the second
46       case a summary of the states of the current processes.
47
48       sg_process_compare_name
49
50       sg_process_compare_pid
51
52       sg_process_compare_uid
53
54       sg_process_compare_gid
55
56       sg_process_compare_size
57
58       sg_process_compare_res
59
60       sg_process_compare_cpu
61
62       sg_process_compare_time
63
64
65       These functions compare two sg_process_stats entries, and return an int
66       to  represent  which one is greater. The main use of these functions is
67       to be passed to qsort to sort the sg_process_stats by the given type.
68
69       For example:
70
71       qsort(sg_process_stats ps, int  ps_size,  sizeof  *ps,  sg_process_com‐
72       pare_pid);
73

RETURN VALUES

75       The   structure   returned   by   sg_get_process_stats   is   of   type
76       sg_process_stats.
77
78       typedef struct {
79               char *process_name;
80               char *proctitle;
81
82               pid_t pid;
83               pid_t parent; /* Parent pid */
84               pid_t pgid;   /* process id of process group leader */
85
86               uid_t uid;
87               uid_t euid;
88               gid_t gid;
89               gid_t egid;
90
91               unsigned long long proc_size; /* in bytes */
92               unsigned long long proc_resident; /* in bytes */
93               time_t time_spent; /* time running in seconds */
94               double cpu_percent;
95               int nice;
96               sg_process_state state;
97       } sg_process_stats;
98
99
100       typedef enum {
101               SG_PROCESS_STATE_RUNNING,
102               SG_PROCESS_STATE_SLEEPING,
103               SG_PROCESS_STATE_STOPPED,
104               SG_PROCESS_STATE_ZOMBIE,
105               SG_PROCESS_STATE_UNKNOWN
106       } sg_process_state;
107
108
109       process_name
110              The name of the command that was run.
111
112       proctitle
113              The command line (the "title") of the process. Take note -  this
114              can  be  modified  by the process, so isn't guaranteed to be the
115              original command line.
116
117       pid    The process ID.
118
119       parent The parent process ID.
120
121       pgid   The process ID of the process group leader.
122
123       uid    The UID the process is running as.
124
125       euid   The effective UID the process is running as.
126
127       gid    The GID the process is running as.
128
129       egid   The effective GID the process is running as.
130
131       proc_size
132              The size of the process in bytes.
133
134       proc_resident
135              The size of the process that's resident in memory.
136
137       time_spent
138              The number of seconds the process has been running.
139
140       cpu_percent
141              The current percentage of CPU the process is using.
142
143       nice   The nice value of the process.
144
145       state  The current state of the process. See sg_process_state for  per‐
146              mitted values.
147
148       The   structure   returned   by   sg_get_process_count   is   of   type
149       sg_process_count.
150
151       typedef struct{
152               int total;
153               int running;
154               int sleeping;
155               int stopped;
156               int zombie;
157       }sg_process_count;
158
159
160       total  The total number of processes.
161
162       running
163              The number of running processes.
164
165       sleeping
166              The number of sleeping processes.
167
168       stopped
169              The number of stopped processes.
170
171       zombie The number of zombie processes.
172

SEE ALSO

174       statgrab(3)
175

WEBSITE

177       http://www.i-scream.org/libstatgrab/
178
179
180
181i-scream                 $Date: 2005/04/25 11:25:45 $  sg_get_process_stats(3)
Impressum