2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/network/nsr_device_writing

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2007-04-02 22:20:42 +02:00
#!/usr/bin/perl
use strict;
my $magic = `echo -e "show name;message\nprint type: nsr device" |nsradmin -i -`;
# name: /dev/nst0;
# message: "writing at 57 MB/s, 4063 GB";
#
# name: /dev/nst1;
# message: "reading, data ";
my %hash = ();
while ($magic =~ m! name: (\S+?);\s+message: "(.+?)";!sg) {
my ($dev,$mess) = ($1,$2);
$hash{$dev} ||= {};
$mess =~ m!writing at (\d+) (.?B)/s!;
if ($2 eq 'B') {
$hash{$dev}->{writing} = $1+0;
}
elsif ($2 eq 'KB') {
$hash{$dev}->{writing} = $1*1024;
}
elsif ($2 eq 'MB') {
$hash{$dev}->{writing} = $1*1024*1024;
}
elsif ($2 eq 'GB') {
$hash{$dev}->{writing} = $1*1024*1024*1024;
}
}
if ($ARGV[0] eq "config") {
print <<_EOM;
graph_title NSR Device write speed (bytes/s)
graph_args -l 0 --base 1000
graph_vlabel bytes/s
graph_category Network
2007-04-02 22:20:42 +02:00
graph_info Shows how much writing each device is doing.
_EOM
foreach my $d (sort keys %hash) {
my ($l) = ($d =~ m!([A-Za-z0-9]+)$!);
print "$l.label $d\n"
# print $l.warning ??\n";
# print "$l.critical ??\n";
}
}
else {
foreach my $d (sort keys %hash) {
my ($l) = ($d =~ m!([A-Za-z0-9]+)$!);
print "$l.value ".$hash{$d}->{writing}."\n";
}
}