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
Revision: 1.1
Committed: Fri Mar 8 13:24:32 2002 UTC (22 years, 7 months ago) by pajs
Content type: text/plain
Branch: MAIN
Log Message:
Initial work on the solaris replacement of running lots of processes.
Currently only replaces df.

File Contents

# User Rev Content
1 pajs 1.1 #include <stdio.h>
2     #include <sys/types.h>
3     #include <sys/statvfs.h>
4     #include <sys/mnttab.h>
5     #include <ukcprog.h>
6    
7     void die()
8     {
9     exit(1);
10     }
11    
12    
13     void diskStats()
14     {
15     struct mnttab mp;
16     struct statvfs df;
17     FILE *f;
18     int counter=0;
19    
20     if ((f=fopen("/etc/mnttab", "r" ))==NULL)
21     {
22     errf("Failed to open mounts (%m)");
23     die();
24     }
25    
26     while((getmntent(f, &mp)) == 0)
27     {
28     if ((statvfs(mp.mnt_mountp, &df)) !=0)
29     {
30     errf("Failed to gets fs stats (%m)");
31     die();
32     }
33    
34     printf("packet.disk.p%d.attributes.mount %s\n", counter, mp.mnt_mountp);
35     printf("packet.disk.p%d.attributes.name %s\n", counter, mp.mnt_special);
36     printf("packet.disk.p%d.attributes.kbytes %lu\n",counter, ((df.f_frsize/1024) * df.f_blocks));
37     printf("packet.disk.p%d.attributes.used %lu\n",counter, (((df.f_frsize/1024) * df.f_blocks) -((df.f_frsize/1024) * df.f_bfree)));
38     printf("packet.disk.p%d.attributes.avail %lu\n",counter, (df.f_frsize/1024) * df.f_bavail);
39     printf("packet.disk.p%d.attributes.totalinodes %lu\n", counter, df.f_files);
40     printf("packet.disk.p%d.attributes.freeinodes %lu\n",counter, df.f_ffree);
41    
42     counter++;
43     }
44    
45    
46    
47     }
48    
49    
50     int main()
51     {
52     diskStats();
53     return 0;
54     }
55