| 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. |
| 68 |
|
sub include_disk() { |
| 69 |
|
|
| 70 |
|
# Run the df program. |
| 71 |
< |
my(@df) = `df -a`; |
| 71 |
> |
my(@df) = `df -ak`; |
| 72 |
|
|
| 66 |
– |
# Only look for these partitions at the moment. |
| 67 |
– |
my(@partition_list) = qw{ / /home /var /tmp }; |
| 68 |
– |
|
| 73 |
|
# Go through each line of the program, looking for each thing we want. |
| 70 |
– |
my($scan_for) = '('.join('|', @partition_list).')'; |
| 74 |
|
my($partition_no) = 0; |
| 75 |
|
for (my($i) = 0; $i < $#df; $i++) { |
| 76 |
|
my($line) = $df[$i]; |
| 77 |
< |
$line =~ /^$scan_for\s*\(([^\s]*)\s*\):\s*([0-9]*)\s*blocks\s*([0-9]*)\s*files/; |
| 77 |
> |
$line =~ /^(\/[^\s]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*[^\s]*\s*(\/[^\s]*)\s*/; |
| 78 |
|
# $4 will not match unless everything before it does... |
| 79 |
< |
if (defined $4) { |
| 80 |
< |
my ($partition, $mounted, $blocks, $files) = ($1, $2, $3, $4); |
| 81 |
< |
&print_pair("packet.disk.p$partition_no.attributes.name", $partition); |
| 82 |
< |
&print_pair("packet.disk.p$partition_no.mounted", $mounted); |
| 83 |
< |
&print_pair("packet.disk.p$partition_no.blocks", $blocks); |
| 84 |
< |
&print_pair("packet.disk.p$partition_no.name", $files); |
| 79 |
> |
if (defined $5) { |
| 80 |
> |
my ($filesystem, $kbytes, $used, $avail, $mount) = ($1, $2, $3, $4, $5); |
| 81 |
> |
&print_pair("packet.disk.p$partition_no.attributes.name", $filesystem); |
| 82 |
> |
&print_pair("packet.disk.p$partition_no.attributes.kbytes", $kbytes); |
| 83 |
> |
&print_pair("packet.disk.p$partition_no.attributes.used", $used); |
| 84 |
> |
&print_pair("packet.disk.p$partition_no.attributes.avail", $avail); |
| 85 |
> |
&print_pair("packet.disk.p$partition_no.attributes.mount", $mount); |
| 86 |
|
++$partition_no; |
| 87 |
|
} |
| 88 |
|
} |