puppet/munin/files/plugins/irqstats
2009-09-12 11:25:56 +03:00

58 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl -w
#
# Plugin to monitor individual interrupts
#
# $Log$
# Revision 1.7.2.1 2005/02/24 17:33:22 jimmyo
# linux/irqstats should no longer fail on some systems (Deb#296452).
#
#%# family=auto
#%# capabilities=autoconf
use strict;
if (defined $ARGV[0] && $ARGV[0] eq 'autoconf') {
if(-e '/usr/bin/vmstat -zi') {
print "yes\n";
exit(0);
} else {
print "no\n";
exit(1);
}
}
open my $in, "/usr/bin/vmstat -zi |"
or die "Can't run vmstat -zi: $!\n";
my $header = <$in>; # throw away header line
my @irqs;
while (my $line = <$in>) {
my ($irq, $total, $rate) = split(' ', $line);
chomp $irq;
$irq =~ s/\//_/g;
chomp $total;
push @irqs, {
irq => $irq,
total => $total,
};
}
close $in;
if (defined $ARGV[0] && $ARGV[0] eq 'config') {
print "graph_title Individual interrupts \n";
print <<EOM;
graph_args --base 1000 -l 0;
graph_vlabel interrupts / \${graph_period}
graph_category system
EOM
print join(' ', 'graph_order', map {"i" . $_->{irq}} @irqs), "\n";
for my $irq (@irqs) {
my $f = ($irq->{irq} || $irq->{total});
print "i", $irq->{irq}, '.label ', $f, "\n";
print "i", $irq->{irq}, '.info Interrupt for device(s): ', $irq->{irq}, "\n";
print "i", $irq->{irq}, ".type DERIVE\n";
print "i", $irq->{irq}, ".min 0\n";
}
} else {
print "i", $_->{irq}, '.value ', $_->{total}, "\n" for @irqs;
}