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

Comparing projects/cms/source/host/ihost-perl/plugins/solaris/solaris.c (file contents):
Revision 1.5 by pajs, Mon Mar 18 13:46:12 2002 UTC vs.
Revision 1.7 by pajs, Mon Mar 18 15:45:04 2002 UTC

# Line 13 | Line 13
13   #include <sys/swap.h>
14   #include <stdlib.h>
15   #include <strings.h>
16 + #include <time.h>
17  
18   void die(){
19    exit(1);
# Line 35 | Line 36 | void diskStats(){
36        errf("Failed to gets fs stats (%m)");
37        die();
38      }
39 +
40 +    if((((strcmp(mp.mnt_fstype,"ufs"))==0) || (strcmp(mp.mnt_fstype,"tmpfs")) ==0)){
41          
42 <    printf("packet.disk.p%d.attributes.mount %s\n", counter, mp.mnt_mountp);
43 <    printf("packet.disk.p%d.attributes.name %s\n", counter, mp.mnt_special);
44 <    printf("packet.disk.p%d.attributes.kbytes %lu\n",counter, ((df.f_frsize/1024) * df.f_blocks));
45 <    printf("packet.disk.p%d.attributes.used %lu\n",counter, (((df.f_frsize/1024) * df.f_blocks) -((df.f_frsize/1024) * df.f_bfree)));
46 <    printf("packet.disk.p%d.attributes.avail %lu\n",counter, (df.f_frsize/1024) * df.f_bavail);
47 <    printf("packet.disk.p%d.attributes.totalinodes %lu\n", counter, df.f_files);
48 <    printf("packet.disk.p%d.attributes.freeinodes %lu\n",counter, df.f_ffree);
42 >      printf("packet.disk.p%d.attributes.mount %s\n", counter, mp.mnt_mountp);
43 >      printf("packet.disk.p%d.attributes.name %s\n", counter, mp.mnt_special);
44 >      printf("packet.disk.p%d.attributes.kbytes %lu\n",counter, ((df.f_frsize/1024) * df.f_blocks));
45 >      printf("packet.disk.p%d.attributes.used %lu\n",counter, (((df.f_frsize/1024) * df.f_blocks) -((df.f_frsize/1024) * df.f_bfree)));
46 >      printf("packet.disk.p%d.attributes.avail %lu\n",counter, (df.f_frsize/1024) * df.f_bavail);
47 >      printf("packet.disk.p%d.attributes.totalinodes %lu\n", counter, df.f_files);
48 >      printf("packet.disk.p%d.attributes.freeinodes %lu\n",counter, df.f_ffree);
49      
50 <    counter++;
50 >      counter++;
51 >    }
52    }
53   }
54  
# Line 99 | Line 103 | void systemStats(){
103    kstat_named_t *kn;
104    int pagesize;
105    cpu_stat_t cs;
106 <  uint_t cpustats[4][2];
106 >  uint_t cpustats[5][2];
107    float usage;
108 <  uint_t user, kernel, idle, iowait, total;
108 >  uint_t user, kernel, idle, iowait, swap, total;
109    ulong totalmem, freemem;
110    long swaptotal, swapused;
111 +  time_t uptime,curtime;
112    
113    struct anoninfo ai;
114  
# Line 128 | Line 133 | void systemStats(){
133    cpustats[1][0]=cs.cpu_sysinfo.cpu[CPU_WAIT];
134    cpustats[2][0]=cs.cpu_sysinfo.cpu[CPU_KERNEL];
135    cpustats[3][0]=cs.cpu_sysinfo.cpu[CPU_IDLE];
136 +  cpustats[4][0]=cs.cpu_sysinfo.cpu[CPU_STATES];
137    
138    sleep(1);
139    
# Line 149 | Line 155 | void systemStats(){
155    cpustats[1][1]=cs.cpu_sysinfo.cpu[CPU_WAIT];
156    cpustats[2][1]=cs.cpu_sysinfo.cpu[CPU_KERNEL];
157    cpustats[3][1]=cs.cpu_sysinfo.cpu[CPU_IDLE];
158 +  cpustats[4][1]=cs.cpu_sysinfo.cpu[CPU_STATES];
159  
160    user=cpustats[0][1]-cpustats[0][0];
161    iowait=cpustats[1][1]-cpustats[1][0];
162    kernel=cpustats[2][1]-cpustats[2][0];
163    idle=cpustats[3][1]-cpustats[3][0];
164 +  swap=cpustats[4][1]-cpustats[4][0];
165  
166 <  total=user+kernel+idle+iowait;
166 >  total=user+kernel+idle+iowait+swap;
167    
168    usage=((((float)user)/((float)total))*100.00);
169  
162  printf("user : %u\n",user);
163  printf("total : %u\n",total);
164
170    printf("packet.cpu.user %3.2f\n", usage);
171    usage=((((float)kernel)/((float)total))*100.00);
172    printf("packet.cpu.kernel %3.2f\n", usage);
# Line 169 | Line 174 | void systemStats(){
174    printf("packet.cpu.idle %3.2f\n", usage);
175    usage=((((float)iowait)/((float)total))*100.00);
176    printf("packet.cpu.iowait %3.2f\n", usage);
177 <
177 >  usage=((((float)swap)/((float)total))*100.00);
178 >  printf("packet.cpu.swap %3.2f\n", usage);
179 >  
180    /* MEMORY STATS */
181    
182    if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
# Line 215 | Line 222 | void systemStats(){
222    printf("packet.swap.total %ld\n",swaptotal);
223    printf("packet.swap.used %ld\n", swapused);
224    printf("packet.swap.free %lu\n", (swaptotal-swapused));
225 +
226 +  ksp=kstat_lookup(kc, "unix", -1, "system_misc");
227 +  if (kstat_read(kc, ksp, 0) == -1) {
228 +    errf("Failed to get uptime (%m)");
229 +    die();
230 +  }
231 +
232 +  if((kn=kstat_data_lookup(ksp, "boot_time")) == NULL){
233 +    errf("Failed to get uptime (%m)");
234 +    die();
235 +  }
236 +
237 +  uptime=(kn->value.ui32);
238 +  time(&curtime);
239 +  printf("packet.os.uptime %ld\n", (curtime-uptime));
240  
241   }    
242    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines