ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/ihost-perl/plugins/freebsd/freebsd.c
(Generate patch)

Comparing projects/cms/source/host/ihost-perl/plugins/freebsd/freebsd.c (file contents):
Revision 1.7 by pajs, Tue Apr 2 11:25:37 2002 UTC vs.
Revision 1.9 by tdb, Sat May 18 18:15:56 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   #include <stdio.h>
21   #include "ukcprog.h"
22   #include <sys/param.h>
# Line 114 | Line 133 | void systemStats(){
133    long cp_time[CPUSTATES];
134    long total, user, idle, kernel, nice;
135    long totalmem, freemem, swaptotal, swapused;
136 +  float stat;
137  
138    static char *uptimename = "kern.boottime";
139    static char *cpname = "kern.cp_time";
# Line 171 | Line 191 | void systemStats(){
191      die();
192    }
193    
194 <  user-=cp_time[CP_USER];
195 <  nice-=cp_time[CP_NICE];
196 <  kernel-=cp_time[CP_SYS];
197 <  idle-=cp_time[CP_IDLE];
194 >  user=cp_time[CP_USER]-user;
195 >  nice=cp_time[CP_NICE]-nice;
196 >  kernel=cp_time[CP_SYS]-kernel;
197 >  idle=cp_time[CP_IDLE]-idle;
198    
199    total=user+nice+kernel+idle;
200 <
201 <  printf("packet.cpu.user %ld\n",((user+nice)*100)/total);
202 <  printf("packet.cpu.kernel %ld\n",(kernel*100)/total);
203 <  printf("packet.cpu.idle %ld\n",(idle*100)/total);
200 >  stat=((float)(user+nice)/(float)total)*100.0;
201 >  printf("packet.cpu.user %.2f\n",stat);
202 >  stat=((float)(kernel)/(float)total)*100.0;
203 >  printf("packet.cpu.kernel %.2f\n",stat);
204 >  stat=((float)(idle)/(float)total)*100.0;
205 >  printf("packet.cpu.idle %.2f\n",stat);
206  
207     /* Cos i-scream's expects this to be sent :/ */
208    printf("packet.cpu.iowait 0\n");
# Line 237 | Line 259 | void systemStats(){
259      die();
260    }
261    
262 <  /* Lose are setgid'ness */
262 >  /* Lose our setgid'ness */
263  
264    if ((setegid(gid)) != 0){
265      errf("Failed to release permissions, refusing to keep setgid. (%m)");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines