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.1 by pajs, Tue Mar 19 13:17:58 2002 UTC vs.
Revision 1.2 by pajs, Tue Mar 19 16:49:30 2002 UTC

# Line 5 | Line 5
5   #include <sys/mount.h>
6   #include <string.h>
7   #include <stdlib.h>
8 + #include <sys/utsname.h>
9 + #include <sys/types.h>
10 + #include <utmp.h>
11  
12   void die(){
13    exit(1);
# Line 43 | Line 46 | void diskStats(){
46  
47   }
48  
49 + void osStats(){
50 +  struct utsname os;
51 +
52 +  if((uname(&os)) != 0){
53 +    errf("Failed to get os stats (%m)");
54 +    die();
55 +  }
56 +  
57 +  printf("packet.os.name %s\n", os.sysname);
58 +  printf("packet.os.release %s\n" , os.release);
59 +  printf("packet.os.version %s\n", os.version);
60 +  printf("packet.os.sysname %s\n" , os.nodename);
61 +  printf("packet.os.platform %s\n", os.machine);
62 +  
63 + }
64 + void loadStats(){
65 +  double loadav[3];
66 +  
67 +  if((getloadavg(loadav,3)) == -1){
68 +    errf("Failed to get load averages (%m)");
69 +    die();    
70 +  }
71 +  
72 +  printf("packet.load.load1 %.2f\n",loadav[0]);
73 +  printf("packet.load.load5 %.2f\n",loadav[1]);
74 +  printf("packet.load.load15 %.2f\n",loadav[2]);
75 + }
76 +
77   int main(){
78    diskStats();
79 +  osStats();
80 +  loadStats();
81    exit(0);
82    
83   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines