| 114 |
|
long cp_time[CPUSTATES]; |
| 115 |
|
long total, user, idle, kernel, nice; |
| 116 |
|
long totalmem, freemem, swaptotal, swapused; |
| 117 |
+ |
float stat; |
| 118 |
|
|
| 119 |
|
static char *uptimename = "kern.boottime"; |
| 120 |
|
static char *cpname = "kern.cp_time"; |
| 172 |
|
die(); |
| 173 |
|
} |
| 174 |
|
|
| 175 |
< |
user-=cp_time[CP_USER]; |
| 176 |
< |
nice-=cp_time[CP_NICE]; |
| 177 |
< |
kernel-=cp_time[CP_SYS]; |
| 178 |
< |
idle-=cp_time[CP_IDLE]; |
| 175 |
> |
user=cp_time[CP_USER]-user; |
| 176 |
> |
nice=cp_time[CP_NICE]-nice; |
| 177 |
> |
kernel=cp_time[CP_SYS]-kernel; |
| 178 |
> |
idle=cp_time[CP_IDLE]-idle; |
| 179 |
|
|
| 180 |
|
total=user+nice+kernel+idle; |
| 181 |
< |
|
| 182 |
< |
printf("packet.cpu.user %ld\n",((user+nice)*100)/total); |
| 183 |
< |
printf("packet.cpu.kernel %ld\n",(kernel*100)/total); |
| 184 |
< |
printf("packet.cpu.idle %ld\n",(idle*100)/total); |
| 181 |
> |
stat=((float)(user+nice)/(float)total)*100.0; |
| 182 |
> |
printf("packet.cpu.user %.2f\n",stat); |
| 183 |
> |
stat=((float)(kernel)/(float)total)*100.0; |
| 184 |
> |
printf("packet.cpu.kernel %.2f\n",stat); |
| 185 |
> |
stat=((float)(idle)/(float)total)*100.0; |
| 186 |
> |
printf("packet.cpu.idle %.2f\n",stat); |
| 187 |
|
|
| 188 |
|
/* Cos i-scream's expects this to be sent :/ */ |
| 189 |
|
printf("packet.cpu.iowait 0\n"); |
| 240 |
|
die(); |
| 241 |
|
} |
| 242 |
|
|
| 243 |
< |
/* Lose are setgid'ness */ |
| 243 |
> |
/* Lose our setgid'ness */ |
| 244 |
|
|
| 245 |
|
if ((setegid(gid)) != 0){ |
| 246 |
|
errf("Failed to release permissions, refusing to keep setgid. (%m)"); |