ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/generic/statgrab.pl
(Generate patch)

Comparing projects/cms/source/host/generic/statgrab.pl (file contents):
Revision 1.3 by tdb, Sat Jan 20 20:04:46 2001 UTC vs.
Revision 1.6 by pjm2, Mon Jan 22 10:03:30 2001 UTC

# Line 21 | Line 21 | $| = 1;
21   # You'd be silly not to use this ;)
22   use strict;
23  
24 + # Run the following components: -
25   &print_ident();
26   &include_osver();
27   &include_users();
28   &include_top();
29 + &include_disk();
30  
31 + # End the program normally.
32   exit(0);
33  
34  
35  
36 +
37 +
38 +
39 +
40 +
41   # prints out an identifier for this version of statgrab.pl
42   # the host should check this when reading data
43   # means the host must be checked and updated to work with newer versions.
44   sub print_ident() {
45 <    print '# statgrab.pl $Revision$';
45 >    print 'version statgrab.pl $Revision$';
46      print "\n";
47   }
48  
49   # sub to print pairs of data, separated by a single space character.
50 + # If the second argument is undefined, then the pair is still printed,
51 + # however, the value shall be displayed as the string "unknown".
52   sub print_pair($$) {
53      my($name, $value) = @_;
54  
# Line 54 | Line 64 | sub print_pair($$) {
64   }
65  
66  
67 + # sub to find out disk partition information, if it exists.
68 + sub include_disk() {
69 +    
70 +    # Run the df program.
71 +    my(@df) = `df -a`;
72 +
73 +    # Only look for these partitions at the moment.
74 +    my(@partition_list) = qw{ / /home /var /tmp };
75 +
76 +    # Go through each line of the program, looking for each thing we want.
77 +    my($scan_for) = '('.join('|', @partition_list).')';
78 +    my($partition_no) = 0;
79 +    for (my($i) = 0; $i < $#df; $i++) {
80 +        my($line) = $df[$i];
81 +        $line =~ /^$scan_for\s*\(([^\s]*)\s*\):\s*([0-9]*)\s*blocks\s*([0-9]*)\s*files/;
82 +        # $4 will not match unless everything before it does...
83 +        if (defined $4) {
84 +            my ($partition, $mounted, $blocks, $files) = ($1, $2, $3, $4);
85 +            &print_pair("packet.disk.p$partition_no.attributes.name", $partition);
86 +            &print_pair("packet.disk.p$partition_no.mounted", $mounted);
87 +            &print_pair("packet.disk.p$partition_no.blocks", $blocks);
88 +            &print_pair("packet.disk.p$partition_no.name", $files);
89 +            ++$partition_no;
90 +        }
91 +    }
92 +    
93 + }
94 +
95 + # sub to find out the list of all (non-unique) usernames logged
96 + # in to the machine and how many their are. (not
97   sub include_users() {
98  
99      # Find out all users on this machine.
# Line 68 | Line 108 | sub include_users() {
108   }
109  
110  
111 + # sub to run a series of regexps on the output of 'top' to
112 + # gather various machine statistics.
113   sub include_top() {
114  
115      # Find out some numbers from top.
# Line 95 | Line 137 | sub include_top() {
137      
138   }
139  
140 + # sub to get details of the machine's operating system.
141   sub include_osver() {
142  
143      # Find out details about the operating system
144 +    # If these values remain undefined, then the print_pair
145 +    # function shall show the value to be the string "unknown".
146      my($os_name) = `uname -s`;
147      my($os_release) = `uname -r`;
148      my($os_platform) = `uname -m`;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines