1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 22:25:23 +00: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 the other: incoming traffic is received on the interface from the
connected device, outgoing is sent to it instead. connected device, outgoing is sent to it instead.
Sub-graphs are created, one per interface, akin to snmp__if_multi
plugin.
=head1 MIB INFORMATION =head1 MIB INFORMATION
This plugin requires the IF-MIB the standard IETF MIB for network 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_multi by Nicolai Langfeldt.
Reworked to snmp__if_all by Diego Elio Pettenò. Reworked to snmp__if_combined by Diego Elio Pettenò.
=head1 LICENSE =head1 LICENSE
@ -547,11 +550,37 @@ sub do_config_root {
if $version == 1; if $version == 1;
} }
print "graph_title $host interfaces traffic\n"; print <<END;
print "graph_args --base 1000\n";
print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n"; multigraph snmp_if_combined
print "graph_category network\n"; graph_title $host interfaces traffic
print "graph_info This graph shows the total traffic for $host.$extrainfo\n"; 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 { sub do_config_if {
@ -589,20 +618,36 @@ sub do_config_if {
$response = $snmpinfo->{$if}->{ifType}; $response = $snmpinfo->{$if}->{ifType};
print "recv$if.label $alias\n"; print <<END;
print "recv$if.type DERIVE\n"; multigraph snmp_if_combined.$if
print "recv$if.graph no\n"; graph_title $alias traffic
print "recv$if.cdef recv$if,8,*\n"; graph_args --base 1000
print "recv$if.max $speed\n" if $speed; graph_vlabel bits in (-) / out (+) per \${graph_period}
print "recv$if.min 0\n"; graph_category network
print "recv$if.warning ", (-$warn), "\n" if defined $warn;
print "send$if.label $alias\n"; recv.label bps
print "send$if.type DERIVE\n"; recv.type DERIVE
print "send$if.negative recv$if\n"; recv.graph no
print "send$if.cdef send$if,8,*\n"; recv.cdef recv,8,*
print "send$if.max $speed\n" if $speed; recv.min 0
print "send$if.min 0\n"; send.label bps
print "send$if.warning $warn\n" if defined $warn; 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 { sub do_fetch_if {
@ -618,26 +663,26 @@ sub do_fetch_if {
if ($status == 2) { if ($status == 2) {
# Interface is down # Interface is down
print "recv$if.value U\n"; print "recv.value U\n";
print "send$if.value U\n"; print "send.value U\n";
print "send$if.extinfo This interface is currently down.\n"; print "send.extinfo This interface is currently down.\n";
return; return;
} }
if (defined ($response = $snmpinfoX->{$if}->{ifHCInOctets} || if (defined ($response = $snmpinfoX->{$if}->{ifHCInOctets} ||
$snmpinfo->{$if}->{ifInOctets})) { $snmpinfo->{$if}->{ifInOctets})) {
print "recv$if.value ", $response, "\n"; print "recv.value $response\n";
} else { } else {
# No response... # No response...
print "recv$if.value U\n"; print "recv.value U\n";
} }
if (defined ($response = $snmpinfoX->{$if}->{ifHCOutOctets} || if (defined ($response = $snmpinfoX->{$if}->{ifHCOutOctets} ||
$snmpinfo->{$if}->{ifOutOctets})) { $snmpinfo->{$if}->{ifOutOctets})) {
print "send$if.value ", $response, "\n"; print "send.value $response\n";
} else { } else {
# No response... # 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'; print "host_name $host\n" unless $host eq 'localhost';
do_config_root($host,$version);
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
do_config_if($host,$version,$if); do_config_if($host,$version,$if);
} }
do_config_root($host,$version);
} }
# ############################## MAIN ################################ # ############################## MAIN ################################
@ -666,5 +711,7 @@ if ($ARGV[0] and $ARGV[0] eq "config") {
} }
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) { foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
print "multigraph snmp_if_combined.$if\n";
do_fetch_if($if); do_fetch_if($if);
} }