From 5a98a7672f8b54e0366e5fc9da177e7e4621b105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 12 Nov 2012 16:37:21 -0800 Subject: [PATCH] snmp__if_combined: rework to have both combined and split graphs available. This basically almost replaces snmp__if_multi in full, as sub-graphs with interface traffic are generated as a set of detailed graphs. It doesn't yet compose graphs with the interface errors though. --- plugins/snmp/snmp__if_combined | 105 ++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/plugins/snmp/snmp__if_combined b/plugins/snmp/snmp__if_combined index 833da1ea..970fbb75 100755 --- a/plugins/snmp/snmp__if_combined +++ b/plugins/snmp/snmp__if_combined @@ -58,6 +58,9 @@ A single graph is generated with all the interfaces overlaid one over the other: incoming traffic is received on the interface from the connected device, outgoing is sent to it instead. +Sub-graphs are created, one per interface, akin to snmp__if_multi +plugin. + =head1 MIB INFORMATION This plugin requires the IF-MIB the standard IETF MIB for network @@ -131,7 +134,7 @@ further grooming by Nicolai Langfeldt. Reworked to snmp__if_multi by Nicolai Langfeldt. -Reworked to snmp__if_all by Diego Elio Pettenò. +Reworked to snmp__if_combined by Diego Elio Pettenò. =head1 LICENSE @@ -547,11 +550,37 @@ sub do_config_root { if $version == 1; } - print "graph_title $host interfaces traffic\n"; - print "graph_args --base 1000\n"; - print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n"; - print "graph_category network\n"; - print "graph_info This graph shows the total traffic for $host.$extrainfo\n"; + print < $b} keys %{$snmpinfo}) { + print " recv$if=snmp_if_combined.$if.recv send$if=snmp_if_combined.$if.send"; + } + print "\n"; + + foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { + my $alias = $snmpinfo->{$if}->{ifDescr} || "Interface $if"; + + if (! ($alias =~ /\d+/) ) { + # If there are no numbers in the $alias add the if index + $alias .=" (if $if)"; + } + + print <{$if}->{ifType}; - print "recv$if.label $alias\n"; - print "recv$if.type DERIVE\n"; - print "recv$if.graph no\n"; - print "recv$if.cdef recv$if,8,*\n"; - print "recv$if.max $speed\n" if $speed; - print "recv$if.min 0\n"; - print "recv$if.warning ", (-$warn), "\n" if defined $warn; - print "send$if.label $alias\n"; - print "send$if.type DERIVE\n"; - print "send$if.negative recv$if\n"; - print "send$if.cdef send$if,8,*\n"; - print "send$if.max $speed\n" if $speed; - print "send$if.min 0\n"; - print "send$if.warning $warn\n" if defined $warn; + print <{$if}->{ifHCInOctets} || $snmpinfo->{$if}->{ifInOctets})) { - print "recv$if.value ", $response, "\n"; + print "recv.value $response\n"; } else { # No response... - print "recv$if.value U\n"; + print "recv.value U\n"; } if (defined ($response = $snmpinfoX->{$if}->{ifHCOutOctets} || $snmpinfo->{$if}->{ifOutOctets})) { - print "send$if.value ", $response, "\n"; + print "send.value $response\n"; } else { # No response... - print "send$if.value U\n"; + print "send.value U\n"; } } @@ -648,11 +693,11 @@ sub do_config { print "host_name $host\n" unless $host eq 'localhost'; - do_config_root($host,$version); - foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { do_config_if($host,$version,$if); } + + do_config_root($host,$version); } # ############################## MAIN ################################ @@ -666,5 +711,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") { } foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { + print "multigraph snmp_if_combined.$if\n"; + do_fetch_if($if); }