root / plugins / network / nsr_device_writing @ dd4afac8
Historique | Voir | Annoter | Télécharger (1,25 ko)
| 1 | 6773191c | Moses Moore | #!/usr/bin/perl |
|---|---|---|---|
| 2 | use strict; |
||
| 3 | |||
| 4 | my $magic = `echo -e "show name;message\nprint type: nsr device" |nsradmin -i -`; |
||
| 5 | # name: /dev/nst0; |
||
| 6 | # message: "writing at 57 MB/s, 4063 GB"; |
||
| 7 | # |
||
| 8 | # name: /dev/nst1; |
||
| 9 | # message: "reading, data "; |
||
| 10 | |||
| 11 | my %hash = (); |
||
| 12 | |||
| 13 | while ($magic =~ m! name: (\S+?);\s+message: "(.+?)";!sg) {
|
||
| 14 | my ($dev,$mess) = ($1,$2); |
||
| 15 | $hash{$dev} ||= {};
|
||
| 16 | $mess =~ m!writing at (\d+) (.?B)/s!; |
||
| 17 | if ($2 eq 'B') {
|
||
| 18 | $hash{$dev}->{writing} = $1+0;
|
||
| 19 | } |
||
| 20 | elsif ($2 eq 'KB') {
|
||
| 21 | $hash{$dev}->{writing} = $1*1024;
|
||
| 22 | } |
||
| 23 | elsif ($2 eq 'MB') {
|
||
| 24 | $hash{$dev}->{writing} = $1*1024*1024;
|
||
| 25 | } |
||
| 26 | elsif ($2 eq 'GB') {
|
||
| 27 | $hash{$dev}->{writing} = $1*1024*1024*1024;
|
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($ARGV[0] eq "config") {
|
||
| 32 | print <<_EOM; |
||
| 33 | graph_title NSR Device write speed (bytes/s) |
||
| 34 | graph_args -l 0 --base 1000 |
||
| 35 | graph_vlabel bytes/s |
||
| 36 | graph_category Networker |
||
| 37 | graph_info Shows how much writing each device is doing. |
||
| 38 | _EOM |
||
| 39 | foreach my $d (sort keys %hash) {
|
||
| 40 | my ($l) = ($d =~ m!([A-Za-z0-9]+)$!); |
||
| 41 | print "$l.label $d\n" |
||
| 42 | # print $l.warning ??\n"; |
||
| 43 | # print "$l.critical ??\n"; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | else {
|
||
| 47 | foreach my $d (sort keys %hash) {
|
||
| 48 | my ($l) = ($d =~ m!([A-Za-z0-9]+)$!); |
||
| 49 | print "$l.value ".$hash{$d}->{writing}."\n";
|
||
| 50 | } |
||
| 51 | } |
