diff --git a/plugins/router/snmp__mikrotik b/plugins/router/snmp__mikrotik index 2cf1880b..b57a23a1 100755 --- a/plugins/router/snmp__mikrotik +++ b/plugins/router/snmp__mikrotik @@ -88,8 +88,8 @@ if ($ARGV[0] and $ARGV[0] eq "config") { if (defined $response) { print "multigraph flash\n"; print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit " . ($response->{$sysFlashTotalOID} * 1024) . "\n"; - print "graph_title Flash disk usage\n"; - print "graph_category system\n"; + print "graph_title Disk usage\n"; + print "graph_category disk\n"; print "graph_info This graph shows the router's flash disk usage.\n"; print "graph_order Total Used\n"; print "graph_vlabel bytes\n"; @@ -103,7 +103,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") { if (defined $response) { print "multigraph ram\n"; print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit " . ($response->{$sysRAMTotalOID} * 1024) . "\n"; - print "graph_title RAM usage\n"; + print "graph_title Memory usage\n"; print "graph_category system\n"; print "graph_info This graph shows the router's memory usage.\n"; print "graph_order Total Used\n"; diff --git a/plugins/snmp/snmp__if_combined b/plugins/snmp/snmp__if_combined index 6d06619a..7be286f5 100755 --- a/plugins/snmp/snmp__if_combined +++ b/plugins/snmp/snmp__if_combined @@ -33,7 +33,7 @@ reality. The stored values would need to be adjusted. bytes to bits. Conversely, they do now need a CDEF to convert bits to bytes. To reflect this aspect explicitely, the root graph's totals are named -recv_bits and send_bits. +`recv_bits` and `send_bits`. =head1 CONFIGURATION @@ -45,6 +45,7 @@ configuration (shown here) will only work on insecure sites/devices: env.community public env.ifTypeOnly ethernetCsmacd env.stackedRoot 1 + env.stackedMax 0 In general SNMP is not very secure at all unless you use SNMP version 3 which supports authentication and privacy (encryption). But in any @@ -74,6 +75,28 @@ would normally be for VPNs. A minor horde of different interface types are supposted, please see IANAifType-MIB (on your system or find with Google) for a full list. +=head2 MULTIPLE INSTANCES + +It is possible to run multiple instances of the plugin for the same host. This +is most useful to generate separate views for groups of ifTypes (e.g., +ethernetCsmacd, ieee82011, l2vlan, ...). + +New instances should be symlinked to the script with an underscore-separated +suffix. A matching configuration file should be present to specify the required +ifTypes (or any other relevant parameters). + + $ readlink /etc/munin/plugins/snmp_192.2.0.1_if_combined_vlan + /path/to/munin-contrib/plugins/snmp/snmp__if_combined + + $ sudo cat /etc/munin/plugin-conf.d/snmp_192.2.0.1_if_combined_vlan + env.ifTypeOnly l2vlan + +The suffix will be appended to the graph base name, e.g., +`snmp__if_combined_` will generate the `snmp_if_combined_` +multigraph and associated series for the selected ``. + +=head2 STACKED ROOT GRAPH + The `stackedRoot` option determines whether the root summary graph shows the traffic on each interface separately, or stacks them on top of one another to show the total traffic through the device. @@ -139,12 +162,18 @@ issue (compounded by the first) is that of wraparound. When one of the counters wraps around, the sum jumps backwards. With a `min` set to 0, and other counters having kept increasing, this looks like a huge increase the total counter. Depending on the `max` (which should match the backplane bandwidth), this may -not be correctly recognised as a spurious value, just reconded as valid. +not be correctly recognised as a spurious value, just recorded as valid. -There is no clear solution to this bug at the moment, save for trying to salvage -the data after the fact. This can be done my either clipping all values beyond a -maximum (e.g., the known use of the switch, rather that its full backplane -bandwith). +As a workaround, the `stackedMax` option is available. It will be set as the max +values for the `send_bits` and `recv_bits` sum series, allowing to prevent +overshoot. It should be set to around the expected maximum given the monitored +network, rather than the sum of the theoretical maxes of the interfaces. This is +a blunt tool that is not going to be very precise, but it should get rid of the +largest outliers, keeping the graphs useful. + +Barring that, it should be possible to salvage the data after the fact. This can +be done my either clipping all values beyond a maximum (e.g., the known use of +the switch, rather that its full backplane bandwith). RANGE='[0-9.]\+e+\(0[789]\|[1-9][0-9]\)' # Anything >=1e07 rrdtool dump ${RRD_FILE} \ @@ -211,6 +240,14 @@ use strict; use Munin::Plugin; use Munin::Plugin::SNMP; +my $scriptname='snmp_if_combined'; +my @scriptname_components= split(/_/,$0); +my $instance = 'All interfaces'; +if ($scriptname_components[-1] ne 'combined') { + $instance = $scriptname_components[-1]; + $scriptname .= "_${instance}"; +} + my $response; my $iface; @@ -246,6 +283,10 @@ my $stackedRoot = 0; if (exists $ENV{'stackedRoot'}) { $stackedRoot = $ENV{'stackedRoot'}; } +my $stackedMax = 0; +if (exists $ENV{'stackedMax'}) { + $stackedMax = $ENV{'stackedMax'}; +} my $sysDescr = '1.3.6.1.2.1.1.1.0'; my $sysLocation = '1.3.6.1.2.1.1.6.0'; @@ -611,8 +652,8 @@ sub do_config_root { print < $b} keys %{$snmpinfo}) { - print " recv$if=snmp_if_combined.$if.recv send$if=snmp_if_combined.$if.send"; - push @ifs, "snmp_if_combined.$if"; + print " recv$if=$scriptname.$if.recv send$if=$scriptname.$if.send"; + push @ifs, "$scriptname.$if"; } if ($stackedRoot) { print " recv_bits send_bits"; @@ -676,11 +717,17 @@ send_bits.draw LINE1 send_bits.colour 000000 send_bits.negative recv_bits END + if ($stackedMax > 0) { + print < $b} keys %{$snmpinfo}) { - print " recv$if=snmp_if_combined_err.$if.total_in send$if=snmp_if_combined_err.$if.total_out"; + print " recv$if=${scriptname}_err.$if.total_in send$if=${scriptname}_err.$if.total_out"; } print "\n"; @@ -761,7 +808,7 @@ sub do_config_if { $extrainfo .= " This is a '".$ifTypeByNum{$response}."' interface."; print < 0) { printf("recv.max %s\nsend.max %s\n", $speed, $speed); } @@ -787,7 +834,7 @@ END } print <{$if}->{ifHCInOctets} || $snmpinfo->{$if}->{ifInOctets}; $recv = defined($response) ? ($response * 8) : undef; @@ -866,7 +913,7 @@ END $send = defined($response) ? ($response * 8) : undef; printf("send.value %s\n", $send || "U"); - print "multigraph snmp_if_combined_err.$if\n"; + print "multigraph ${scriptname}_err.$if\n"; my $errors = $snmpinfo->{$if}->{ifInErrors}; my $discards = $snmpinfo->{$if}->{ifInDiscards}; @@ -924,8 +971,16 @@ foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { $recv += ($recv_if || 0); $send += ($send_if || 0); } +if ($stackedMax > 0) { + if ($recv > $stackedMax) { + $recv = 'U'; + } + if ($send > $stackedMax) { + $send = 'U'; + } +} if ($stackedRoot) { - print "multigraph snmp_if_combined\n"; + print "multigraph $scriptname\n"; print "recv_bits.value $recv\n"; print "send_bits.value $send\n"; }