3 # check_maxchannels.pl - nagios plugin
6 # Copyright (C) 2000 Christoph Kron
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 # Report bugs to: ck@zet.net
25 # 11.01.2000 Version 1.0
31 &Getopt
::Long
::config
('auto_abbrev');
37 my %ERRORS = ('UNKNOWN' , '-1',
43 my $state = "UNKNOWN";
48 my $community = "public";
52 my $snmpWanAvailableChannels = '1.3.6.1.4.1.529.4.23.0';
54 my $snmpWanSwitchedChannels = '1.3.6.1.4.1.529.4.24.0';
55 my $snmpWanDisabledChannels = '1.3.6.1.4.1.529.4.25.0';
56 my $snmpWanActiveChannels = '1.3.6.1.4.1.529.4.26.0';
57 my $snmpWanNailedChannels = '1.3.6.1.4.1.529.4.27.0';
58 my $snmpWanOutOfServiceChannels = '1.3.6.1.4.1.529.4.28.0';
59 my $snmpEventCurrentActiveSessions = '1.3.6.1.4.1.529.10.6.0';
61 my $snmpEventTotalNoModems = '1.3.6.1.4.1.529.10.15.0';
63 my $snmpDeadLanModem = '1.3.6.1.4.1.529.15.7.0';
64 my $snmpDisabledLanModem = '1.3.6.1.4.1.529.15.5.0';
65 my $snmpSuspectLanModem = '1.3.6.1.4.1.529.15.3.0';
66 my $snmpAvailLanModem = '1.3.6.1.4.1.529.15.1.0';
67 my $snmpBusyLanModem = '1.3.6.1.4.1.529.15.9.0';
69 my $snmpMdmNumber = '1.3.6.1.2.1.38.1.1.0';
77 my $WanAvailableChannels;
78 my $WanSwitchedChannels;
79 my $WanDisabledChannels;
80 my $WanActiveChannels;
81 my $WanNailedChannels;
82 my $WanOutOfServiceChannels;
83 my $EventCurrentActiveSessions;
84 my $EventTotalNoModems;
94 printf "\nMissing arguments!\n";
96 printf "Perl Check maxchannels plugin for Nagios\n";
97 printf "monitors ISDN lines and modems on Ascend MAX 2000/4000/6000/TNT\n";
99 printf "check_maxchannel.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n";
100 printf "Copyright (C) 2000 Christoph Kron\n";
101 printf "check_maxchannels.pl comes with ABSOLUTELY NO WARRANTY\n";
102 printf "This programm is licensed under the terms of the ";
103 printf "GNU General Public License\n(check source code for details)\n";
105 exit $ERRORS{"UNKNOWN"};
108 # Just in case of problems, let's not hang Nagios
110 print ("ERROR: No snmp response from $hostname (alarm)\n");
111 exit $ERRORS{"UNKNOWN"};
116 $status = GetOptions
("community=s",\
$community,
124 $hostname = shift || &usage
;
128 push(@snmpoids,$snmpWanAvailableChannels);
129 push(@snmpoids,$snmpWanSwitchedChannels);
130 push(@snmpoids,$snmpWanDisabledChannels);
131 push(@snmpoids,$snmpWanActiveChannels);
132 push(@snmpoids,$snmpWanNailedChannels);
133 push(@snmpoids,$snmpWanOutOfServiceChannels);
135 push(@snmpoids,$snmpEventCurrentActiveSessions);
137 push(@snmpoids,$snmpEventTotalNoModems);
138 push(@snmpoids,$snmpDeadLanModem);
139 push(@snmpoids,$snmpDisabledLanModem);
140 push(@snmpoids,$snmpSuspectLanModem);
141 push(@snmpoids,$snmpAvailLanModem);
142 push(@snmpoids,$snmpBusyLanModem);
143 push(@snmpoids,$snmpMdmNumber);
145 ($session, $error) = Net
::SNMP
->session(
146 -hostname
=> $hostname,
147 -community
=> $community,
151 if (!defined($session)) {
154 print ("$state: $answer");
155 exit $ERRORS{$state};
158 if (!defined($response = $session->get_request(@snmpoids))) {
159 $answer=$session->error;
162 print ("$state: $answer,$community");
163 exit $ERRORS{$state};
167 $WanAvailableChannels = $response->{$snmpWanAvailableChannels};
168 $WanSwitchedChannels = $response->{$snmpWanSwitchedChannels};
169 $WanDisabledChannels = $response->{$snmpWanDisabledChannels};
170 $WanActiveChannels = $response->{$snmpWanActiveChannels};
171 $WanNailedChannels = $response->{$snmpWanNailedChannels};
172 $WanOutOfServiceChannels = $response->{$snmpWanOutOfServiceChannels};
173 $EventCurrentActiveSessions = $response->{$snmpEventCurrentActiveSessions};
174 $EventTotalNoModems = $response->{$snmpEventTotalNoModems};
175 $DeadLanModem = $response->{$snmpDeadLanModem};
176 $DisabledLanModem = $response->{$snmpDisabledLanModem};
177 $SuspectLanModem = $response->{$snmpSuspectLanModem};
178 $AvailLanModem = $response->{$snmpAvailLanModem};
179 $BusyLanModem = $response->{$snmpBusyLanModem};
180 $MdmNumber = $response->{$snmpMdmNumber};
182 # less than 50% -> WARNING
183 if ( 0 < $WanOutOfServiceChannels
184 && $WanOutOfServiceChannels < ($snmpWanSwitchedChannels * 0.5) ) {
187 elsif ($WanOutOfServiceChannels > 0) {
190 elsif ($DeadLanModem > 0) {
193 elsif ($SuspectLanModem > 0) {
196 elsif ($AvailLanModem == 0) {
204 $answer = sprintf("active sessions: %d (%d), active modems: %d (%d)<BR>",
205 $EventCurrentActiveSessions,
206 $WanSwitchedChannels,
210 $answer .= sprintf("channels available: %d, disabled: %d",
211 $WanAvailableChannels,
212 $WanDisabledChannels);
214 $answer .= sprintf(", out of service: %d, nailed: %d<BR>",
215 $WanOutOfServiceChannels,
218 $answer .= sprintf("modems avail.: %d, disabled: %d, suspect: %d, dead: %d<BR>",
224 $answer .= sprintf("unserviced modem calls: %d (since startup)\n",
225 $EventTotalNoModems);
229 print ("$state: $answer");
230 exit $ERRORS{$state};