1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#!@@PERL@@ -w
# -*- cperl -*-
=head1 NAME
bdf - Munin plugin to monitor disk space usage on an HP-UX machine
=head1 APPLICABLE SYSTEMS
Any HP-UX system with commands '/usr/bin/bdf' and '/usr/sbin/fstyp'
=head1 CONFIGURATION
The plugin must be run as the root user to be able to determine
the filesystem type (VXFS, HFS, etc.):
[bdf*]
user root
=head1 INTERPRETATION
The plugin shows disk space usage on HP-UX systems as reported by
the command 'bdf'.
Only locally mounted VXFS or HFS filesystems are reported.
The plugin aims to be a functional equivalent to the Linux df plugin.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 BUGS
None known
=head1 AUTHOR
Chris Gardner
=head1 LICENSE
GPLv2
=cut
use Munin::Plugin;
use strict;
$ENV{'PATH'} = '/bin:/usr/bin:/sbin:/usr/sbin';
if(defined($ARGV[0]) and $ARGV[0] eq "autoconf") {
if(-x '/usr/bin/bdf' && -x '/sbin/fstyp') {
print "yes\n";
exit 0;
} else {
print "no (no bdf and/or fstyp executables\n";
exit 0;
}
}
# `bdf -i` --> [0]=Filesystem, [1]=kbytes, [2]=used, [3]=avail, [4]=%used, [5]=iused, [6]=ifree, [7]=%iuse, [8]=Mounted on
# Just 1 round of `bdf` is simpler but picks up CDFS cruft. bdf can't accept multiple FS types in 1 command.
my @bdf_hfs = `/usr/bin/bdf -ilt hfs`;
shift(@bdf_hfs);
my @bdf_vxfs = `/usr/bin/bdf -ilt vxfs`;
shift(@bdf_vxfs);
push(my @bdf, (@bdf_hfs, @bdf_vxfs)); # Recombine `bdf` for each FS type .
my $i = 0;
foreach(@bdf) {
chomp;
my @cols = split(/\s+/);
if($#cols == 0) { # `bdf` line wraps if device name > 18 chars. This restores 1 array element per filesystem.
chomp($_ .= $bdf[$i+1]);
splice(@bdf, $i+1, 1);
}
$i++;
}
my $maxlabel = 20;
if(defined($ARGV[0]) and $ARGV[0] eq "config") {
print "graph_title Disk usage in percent\n";
print "graph_args --upper-limit 100 -l 0\n";
print "graph_vlabel %\n";
print "graph_category disk\n";
print "graph_info This graph shows disk usage on the machine.\n";
foreach(@bdf) {
(my $fs, my $mount) = (split(/\s+/))[0,8]; # See top comment for array slice description.
chomp(my $fs_type = `/sbin/fstyp $fs`);
(my $name = $fs) =~ s|/|_|g;
print "$name.label ";
if(length($mount) > $maxlabel) {
print "..." . substr($mount, -$maxlabel+3) . "\n";
} else {
print "$mount\n";
}
print "$name.info $mount ($fs_type) -> $fs\n";
print "$name.warning 92\n";
print "$name.critical 98\n";
}
exit 0;
}
foreach(@bdf) {
(my $fs, my $pct_used) = (split(/\s+/))[0,4];
(my $name = $fs) =~ s|/|_|g;
$pct_used =~ s/%//g;
print "$name.value $pct_used\n";
}
# vim:syntax=perl
|