| 50 |
|
|
| 51 |
|
void getMemInfo() { |
| 52 |
|
char *line; |
| 53 |
< |
char *mem; |
| 54 |
< |
char *swap; |
| 53 |
> |
char *mem=NULL; |
| 54 |
> |
char *swap=NULL; |
| 55 |
|
char *ch; |
| 56 |
|
long memstat[6]; |
| 57 |
|
long swapstat[3]; |
| 80 |
|
errf("Failed to close file (%m)."); |
| 81 |
|
die(); |
| 82 |
|
} |
| 83 |
< |
|
| 83 |
> |
|
| 84 |
> |
if (mem==NULL || swap==NULL){ |
| 85 |
> |
errf("Failed to obtain information required for memory and swap stats"); |
| 86 |
> |
die(); |
| 87 |
> |
} |
| 88 |
> |
|
| 89 |
|
/* Get the info we want from the 2 read in lines */ |
| 90 |
|
|
| 91 |
|
ch = strchr(mem, ' '); |
| 223 |
|
usage=((((float)idle)/((float)total))*100.00); |
| 224 |
|
printf("packet.cpu.idle %3.2f\n", usage); |
| 225 |
|
|
| 226 |
< |
/* Cos i-scream's expexts this to be sent :/ */ |
| 226 |
> |
/* Cos i-scream's expects this to be sent :/ */ |
| 227 |
|
printf("packet.cpu.iowait 0\n"); |
| 228 |
< |
|
| 228 |
> |
printf("packet.cpu.swap 0\n"); |
| 229 |
> |
|
| 230 |
|
free(line[0]); |
| 231 |
|
free(line[1]); |
| 232 |
|
} |
| 275 |
|
|
| 276 |
|
printf("\npacket.users.count %d\n", nousers); |
| 277 |
|
|
| 278 |
< |
printf("packet.processes.total %d\n",sleeping); |
| 279 |
< |
printf("packet.processes.sleeping %d\n",running); |
| 278 |
> |
printf("packet.processes.sleeping %d\n",sleeping); |
| 279 |
> |
printf("packet.processes.cpu %d\n",running); |
| 280 |
|
printf("packet.processes.zombie %d\n",zombie); |
| 281 |
|
printf("packet.processes.stopped %d\n", stopped); |
| 282 |
|
printf("packet.processes.total %d\n", (sleeping+running+zombie+stopped)); |