1 |
|
/* |
2 |
< |
* i-scream central monitoring system |
2 |
> |
* i-scream libstatgrab |
3 |
|
* http://www.i-scream.org |
4 |
|
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
26 |
|
#include <unistd.h> |
27 |
|
|
28 |
|
int main(){ |
29 |
< |
sg_process_stats *ps; |
30 |
< |
int ps_size; |
31 |
< |
int x; |
29 |
> |
sg_process_stats *ps; |
30 |
> |
int ps_size; |
31 |
> |
int x; |
32 |
|
char *state = NULL; |
33 |
|
|
34 |
|
/* Initialise statgrab */ |
40 |
|
return 1; |
41 |
|
} |
42 |
|
|
43 |
< |
ps = sg_get_process_stats(&ps_size); |
43 |
> |
ps = sg_get_process_stats(&ps_size); |
44 |
|
|
45 |
|
if(ps == NULL){ |
46 |
|
fprintf(stderr, "Failed to get process snapshot\n"); |
50 |
|
printf("%5s %5s %5s %5s %5s %5s %5s %6s %6s %9s %-10s %-4s %-8s %-20s %s\n", |
51 |
|
"pid", "ppid", "pgid", "uid", "euid", "gid", "egid", "size", "res", "time", "cpu", "nice", "state", "name", "title"); |
52 |
|
|
53 |
< |
for(x=0;x<ps_size;x++){ |
53 |
> |
for(x=0;x<ps_size;x++){ |
54 |
|
switch (ps->state) { |
55 |
|
case SG_PROCESS_STATE_RUNNING: |
56 |
|
state = "RUNNING"; |
77 |
|
(int)ps->time_spent, (float)ps->cpu_percent, |
78 |
|
(int)ps->nice, state, |
79 |
|
ps->process_name, ps->proctitle); |
80 |
< |
ps++; |
81 |
< |
} |
80 |
> |
ps++; |
81 |
> |
} |
82 |
|
return 0; |
83 |
|
} |