/usr/share/munin/plugins/pm3users_ is in munin-plugins-extra 2.0.19-3ubuntu0.3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/usr/bin/perl -w
# -*- perl
=pod
=head1 NAME
pm3users_ - SNMP wildcard plugin to monitor busy channels on L(ivingston|ucent) Portmaster Network Access Servers
=head1 APPLICABLE SYSTEMS
L(ivingston|ucent) Portmaster 3 (maybe PM2 and PM4, too. Dunno 'bout that)...
=head1 CONFIGURATION
Link into plugin dir with name pm3users_<hostname> or pm3users_<ip address>
[pm3users_somewherehost]
env.host - Host name or IP address to poll (default: guessed from symlink, i.e. somewherehost)
env.port - Port number (default: 161)
env.community - SNMP read community to use (default: public)
env.maxpstn - Number of analog modems onboard the PM3 (default: 20)
env.maxisdn - Number of ISDN channels available (default: 30 == a full E1 line)
=head1 BUGS
Should be rewritten as a snmp__pm3users plugin using the Plugin::SNMP module.
=head1 AUTHOR
(C) 2004, Jacques Caruso
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=contrib
=cut
use Net::SNMP;
use strict;
my $usertable = '1.3.6.1.4.1.307.3.2.1.1.1.4';
my $modemtable = '1.3.6.1.4.1.307.3.2.1.1.1.13';
my ($total, $pstn, $isdn) = (0, 0, 0);
my ($maxpstn, $maxisdn) = (20, 30);
my ($user, $modem) = ('', '');
my ($host, $port, $community) = (undef, 161, 'public');
my $progname = '';
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';
# Check how we were called to guess the PM3's hostname
($progname, $host) = split(/_/, $0) if ($0 =~ /^(?:|.*\/)pm3users_/);
# Let's see if our configuration differs from the defaults
(defined($ENV{'host'})) and $host = $ENV{'host'};
(defined($ENV{'port'})) and $port = $ENV{'port'};
(defined($ENV{'community'})) and $community = $ENV{'community'};
# We need an host name
(defined($host)) or die('# Error: cannot find the host to be monitored');
# XXX maybe there is a way to get this info from the equipment
# XXX remember to look into this
(defined($ENV{'maxpstn'})) and $maxpstn = $ENV{'maxpstn'};
(defined($ENV{'maxisdn'})) and $maxisdn = $ENV{'maxisdn'};
my $maxtotal = $maxisdn;
# Show default values if requested
if ($cmd eq 'config') {
print("host_name $host\n");
print("graph_title Users on $host\n");
print("graph_args --lower-limit 0 --upper-limit $maxtotal\n");
print("graph_vlabel channels in use\n");
print("pstn.label PSTN\n");
print("pstn.max $maxpstn\n");
print("pstn.type GAUGE\n");
print("pstn.draw AREA\n");
print("pstn.colour 50f0ff\n");
print("isdn.label ISDN\n");
print("isdn.max $maxisdn\n");
print("isdn.type GAUGE\n");
print("isdn.draw STACK\n");
print("isdn.colour 9598dd\n");
print("total.label Total\n");
print("total.max $maxtotal\n");
print("total.type GAUGE\n");
print("total.draw LINE1\n");
print("total.colour 000000\n");
# These options are unsupported in the current version:
# print("hrules $maxpstn:ff8800:Max PSTN users,$maxisdn:ff0000:Max ISDN users\n");
exit(0);
}
# Else proceed to poll the equipment
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port,
);
if (defined($session)) {
my $user = $session->get_table(
-baseoid => $usertable
);
my $modem = $session->get_table(
-baseoid => $modemtable
);
# Interface 1 is the console port, thus we start at 2
for my $i (2 .. 61) {
(scalar($user->{"$usertable.$i"}) ne '') and $total++;
(scalar($modem->{"$modemtable.$i"}) ne '') and $pstn++;
}
$session->close;
}
$isdn = $total - $pstn;
print("pstn.value $pstn\n");
print("isdn.value $isdn\n");
print("total.value $total\n");
exit(0);
|