mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
snmp__if_combined: add support for multiple instances
This allows to split the data into smaller groups, e.g., per ifType. Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
parent
387bb863f1
commit
4262dc8564
1 changed files with 40 additions and 12 deletions
|
@ -74,6 +74,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
|
are supposted, please see IANAifType-MIB (on your system or find with
|
||||||
Google) for a full list.
|
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_<HOST>_if_combined_<SUFFIX>` will generate the `snmp_if_combined_<SUFFIX>`
|
||||||
|
multigraph and associated series for the selected `<HOST>`.
|
||||||
|
|
||||||
|
=head2 STACKED ROOT GRAPH
|
||||||
|
|
||||||
The `stackedRoot` option determines whether the root summary graph shows the
|
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
|
traffic on each interface separately, or stacks them on top of one another to
|
||||||
show the total traffic through the device.
|
show the total traffic through the device.
|
||||||
|
@ -211,6 +233,12 @@ use strict;
|
||||||
use Munin::Plugin;
|
use Munin::Plugin;
|
||||||
use Munin::Plugin::SNMP;
|
use Munin::Plugin::SNMP;
|
||||||
|
|
||||||
|
my $scriptname='snmp_if_combined';
|
||||||
|
my @scriptname_components= split(/_/,$0);
|
||||||
|
if ($scriptname_components[-1] ne 'combined') {
|
||||||
|
$scriptname .= "_${scriptname_components[-1]}";
|
||||||
|
}
|
||||||
|
|
||||||
my $response;
|
my $response;
|
||||||
my $iface;
|
my $iface;
|
||||||
|
|
||||||
|
@ -611,7 +639,7 @@ sub do_config_root {
|
||||||
|
|
||||||
print <<END;
|
print <<END;
|
||||||
|
|
||||||
multigraph snmp_if_combined
|
multigraph $scriptname
|
||||||
graph_title All interfaces traffic
|
graph_title All interfaces traffic
|
||||||
graph_args --base 1000
|
graph_args --base 1000
|
||||||
graph_vlabel bits in (-) / out (+) per \${graph_period}
|
graph_vlabel bits in (-) / out (+) per \${graph_period}
|
||||||
|
@ -622,8 +650,8 @@ END
|
||||||
print "graph_order";
|
print "graph_order";
|
||||||
my @ifs;
|
my @ifs;
|
||||||
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
|
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
|
||||||
print " recv$if=snmp_if_combined.$if.recv send$if=snmp_if_combined.$if.send";
|
print " recv$if=$scriptname.$if.recv send$if=$scriptname.$if.send";
|
||||||
push @ifs, "snmp_if_combined.$if";
|
push @ifs, "$scriptname.$if";
|
||||||
}
|
}
|
||||||
if ($stackedRoot) {
|
if ($stackedRoot) {
|
||||||
print " recv_bits send_bits";
|
print " recv_bits send_bits";
|
||||||
|
@ -679,7 +707,7 @@ END
|
||||||
}
|
}
|
||||||
|
|
||||||
print <<END;
|
print <<END;
|
||||||
multigraph snmp_if_combined_err
|
multigraph ${scriptname}_err
|
||||||
graph_title All interfaces errors
|
graph_title All interfaces errors
|
||||||
graph_args --base 1000
|
graph_args --base 1000
|
||||||
graph_vlabel errors in (-) / out (+) per \${graph_period}
|
graph_vlabel errors in (-) / out (+) per \${graph_period}
|
||||||
|
@ -688,7 +716,7 @@ END
|
||||||
|
|
||||||
print "graph_order";
|
print "graph_order";
|
||||||
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
|
foreach my $if (sort {$a <=> $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";
|
print "\n";
|
||||||
|
|
||||||
|
@ -761,7 +789,7 @@ sub do_config_if {
|
||||||
$extrainfo .= " This is a '".$ifTypeByNum{$response}."' interface.";
|
$extrainfo .= " This is a '".$ifTypeByNum{$response}."' interface.";
|
||||||
|
|
||||||
print <<END;
|
print <<END;
|
||||||
multigraph snmp_if_combined.$if
|
multigraph $scriptname.$if
|
||||||
graph_title $alias traffic
|
graph_title $alias traffic
|
||||||
graph_info This graph shows traffic for the \"$alias\" network interface.$extrainfo
|
graph_info This graph shows traffic for the \"$alias\" network interface.$extrainfo
|
||||||
graph_args --base 1000
|
graph_args --base 1000
|
||||||
|
@ -787,7 +815,7 @@ END
|
||||||
}
|
}
|
||||||
|
|
||||||
print <<END;
|
print <<END;
|
||||||
multigraph snmp_if_combined_err.$if
|
multigraph ${scriptname}_err.$if
|
||||||
graph_title $alias errors
|
graph_title $alias errors
|
||||||
graph_info This graph shows errors for the \"$alias\" network interface.$extrainfo
|
graph_info This graph shows errors for the \"$alias\" network interface.$extrainfo
|
||||||
graph_args --base 1000
|
graph_args --base 1000
|
||||||
|
@ -836,11 +864,11 @@ sub do_fetch_if {
|
||||||
if ($status != 1) {
|
if ($status != 1) {
|
||||||
# Interface is down
|
# Interface is down
|
||||||
print <<END;
|
print <<END;
|
||||||
multigraph snmp_if_combined.$if
|
multigraph $scriptname.$if
|
||||||
recv.value U
|
recv.value U
|
||||||
send.value U
|
send.value U
|
||||||
send.extinfo This interface is currently down.
|
send.extinfo This interface is currently down.
|
||||||
multigraph snmp_if_combined_err.$if
|
multigraph ${scriptname}_err.$if
|
||||||
errors_in.value U
|
errors_in.value U
|
||||||
errors_out.value U
|
errors_out.value U
|
||||||
discards_in.value U
|
discards_in.value U
|
||||||
|
@ -856,7 +884,7 @@ END
|
||||||
my $recv;
|
my $recv;
|
||||||
my $send;
|
my $send;
|
||||||
|
|
||||||
print "multigraph snmp_if_combined.$if\n";
|
print "multigraph $scriptname.$if\n";
|
||||||
|
|
||||||
$response = $snmpinfoX->{$if}->{ifHCInOctets} || $snmpinfo->{$if}->{ifInOctets};
|
$response = $snmpinfoX->{$if}->{ifHCInOctets} || $snmpinfo->{$if}->{ifInOctets};
|
||||||
$recv = defined($response) ? ($response * 8) : undef;
|
$recv = defined($response) ? ($response * 8) : undef;
|
||||||
|
@ -866,7 +894,7 @@ END
|
||||||
$send = defined($response) ? ($response * 8) : undef;
|
$send = defined($response) ? ($response * 8) : undef;
|
||||||
printf("send.value %s\n", $send || "U");
|
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 $errors = $snmpinfo->{$if}->{ifInErrors};
|
||||||
my $discards = $snmpinfo->{$if}->{ifInDiscards};
|
my $discards = $snmpinfo->{$if}->{ifInDiscards};
|
||||||
|
@ -925,7 +953,7 @@ foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
|
||||||
$send += ($send_if || 0);
|
$send += ($send_if || 0);
|
||||||
}
|
}
|
||||||
if ($stackedRoot) {
|
if ($stackedRoot) {
|
||||||
print "multigraph snmp_if_combined\n";
|
print "multigraph $scriptname\n";
|
||||||
print "recv_bits.value $recv\n";
|
print "recv_bits.value $recv\n";
|
||||||
print "send_bits.value $send\n";
|
print "send_bits.value $send\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue