This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnmp__tp_link_8840
executable file
·79 lines (61 loc) · 1.79 KB
/
snmp__tp_link_8840
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl -w
# -*- cperl -*-
=head1 NAME
snmp__tp_link - SNMP plugin to monitor DSL interface of a TP-LINK router
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=cut
use strict;
use Munin::Plugin::SNMP;
my $DEBUG = $ENV{'MUNIN_DEBUG'};
my $ifOIDBase = '1.3.6.1.2.1.2.2.1';
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "number 1.3.6.1.2.1.2.1.0\n";
print "index $ifOIDBase.1.\n";
print "require $ifOIDBase.10. [1-9]\n"; # ifInOctets
print "require $ifOIDBase.16. [1-9]\n"; # ifOutOctets
exit 0;
}
if ($ARGV[0] and $ARGV[0] eq "config") {
my ($host) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
print "multigraph if_dsl\n";
print "graph_title DSL interface traffic\n";
print "graph_order recv send\n";
print "graph_args --base 1000\n";
print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n";
print "graph_category network\n";
print "send.info Bits sent/received by this interface.\n";
print "recv.label recv\n";
print "recv.type DERIVE\n";
print "recv.graph no\n";
print "recv.cdef recv,8,*\n";
print "recv.min 0\n";
print "send.label bps\n";
print "send.type DERIVE\n";
print "send.negative recv\n";
print "send.cdef send,8,*\n";
print "send.min 0\n";
exit 0;
}
my $session = Munin::Plugin::SNMP->session();
my $result = $session->get_hash(
-baseoid => $ifOIDBase,
-cols => {
1 => 'index',
3 => 'type',
10 => 'in_octets',
16 => 'out_octets'
});
my ($send, $recv);
$send = $recv = 'U';
foreach (values(%$result)) {
if ($$_{'type'} == 23) {
$send = $$_{'out_octets'};
$recv = $$_{'in_octets'};
}
}
print "multigraph if_dsl\n";
print "send.value $send\n";
print "recv.value $recv\n";