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

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.
This commit is contained in:
Diego Elio Pettenò 2012-11-12 16:37:21 -08:00
parent 060ddd51f2
commit 5a98a7672f

View File

@ -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 <<END;
multigraph snmp_if_combined
graph_title $host interfaces traffic
graph_args --base 1000
graph_vlabel bits in (-) / out (+) per \${graph_period}
graph_category network
graph_info This graph shows the total traffic for $host.$extrainfo
END
print "graph_order";
foreach my $if (sort {$a <=> $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 <<END;
recv$if.label $alias
recv$if.graph no
send$if.label $alias
send$if.negative recv$if
END
}
}
sub do_config_if {
@ -589,20 +618,36 @@ sub do_config_if {
$response = $snmpinfo->{$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 <<END;
multigraph snmp_if_combined.$if
graph_title $alias traffic
graph_args --base 1000
graph_vlabel bits in (-) / out (+) per \${graph_period}
graph_category network
recv.label bps
recv.type DERIVE
recv.graph no
recv.cdef recv,8,*
recv.min 0
send.label bps
send.type DERIVE
send.negative recv
send.cdef send,8,*
send.min 0
END
if ( defined($speed) ) {
printf("recv.max %s\nsend.max %s\n", $speed, $speed);
}
if ( defined($warn) ) {
printf("recv.warning %s\nsend.warning %s\n", $warn, $warn);
}
if ( $ENV{MUNIN_CAP_DIRTYCONFIG} == 1 ) {
do_fetch_if($if);
}
}
sub do_fetch_if {
@ -618,26 +663,26 @@ sub do_fetch_if {
if ($status == 2) {
# Interface is down
print "recv$if.value U\n";
print "send$if.value U\n";
print "send$if.extinfo This interface is currently down.\n";
print "recv.value U\n";
print "send.value U\n";
print "send.extinfo This interface is currently down.\n";
return;
}
if (defined ($response = $snmpinfoX->{$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);
}