diff options
| author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-02 13:16:24 +0200 |
|---|---|---|
| committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-02 13:16:24 +0200 |
| commit | b15adb7762b6caaecaa83637abfcf5fdb4802092 (patch) | |
| tree | 64eddbe2aa1a7f98a140be0f7973f05d7a781ae0 /contrib/check_maxchannels.pl | |
| parent | c4d5882b9e1d07c7b61091062b7d085fa5f00284 (diff) | |
| download | monitoring-plugins-b15adb7762b6caaecaa83637abfcf5fdb4802092.tar.gz | |
Remove "contrib" plugins
These days, sites such as "Nagios Exchange" are a much better place for
publishing plugins not maintained by the Plugins Development Team.
Diffstat (limited to 'contrib/check_maxchannels.pl')
| -rw-r--r-- | contrib/check_maxchannels.pl | 231 |
1 files changed, 0 insertions, 231 deletions
diff --git a/contrib/check_maxchannels.pl b/contrib/check_maxchannels.pl deleted file mode 100644 index a3ce525b..00000000 --- a/contrib/check_maxchannels.pl +++ /dev/null | |||
| @@ -1,231 +0,0 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | # | ||
| 3 | # check_maxchannels.pl - nagios plugin | ||
| 4 | # | ||
| 5 | # | ||
| 6 | # Copyright (C) 2000 Christoph Kron | ||
| 7 | # | ||
| 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. | ||
| 12 | # | ||
| 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. | ||
| 17 | # | ||
| 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. | ||
| 21 | # | ||
| 22 | # | ||
| 23 | # Report bugs to: ck@zet.net | ||
| 24 | # | ||
| 25 | # 11.01.2000 Version 1.0 | ||
| 26 | |||
| 27 | use strict; | ||
| 28 | |||
| 29 | use Net::SNMP; | ||
| 30 | use Getopt::Long; | ||
| 31 | &Getopt::Long::config('auto_abbrev'); | ||
| 32 | |||
| 33 | |||
| 34 | my $status; | ||
| 35 | my $TIMEOUT = 15; | ||
| 36 | |||
| 37 | my %ERRORS = ('UNKNOWN' , '-1', | ||
| 38 | 'OK' , '0', | ||
| 39 | 'WARNING', '1', | ||
| 40 | 'CRITICAL', '2'); | ||
| 41 | |||
| 42 | |||
| 43 | my $state = "UNKNOWN"; | ||
| 44 | my $answer = ""; | ||
| 45 | my $snmpkey; | ||
| 46 | my $snmpoid; | ||
| 47 | my $key; | ||
| 48 | my $community = "public"; | ||
| 49 | my $port = 161; | ||
| 50 | my @snmpoids; | ||
| 51 | # free channels | ||
| 52 | my $snmpWanAvailableChannels = '1.3.6.1.4.1.529.4.23.0'; | ||
| 53 | # maximum channels | ||
| 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'; | ||
| 60 | # since startup | ||
| 61 | my $snmpEventTotalNoModems = '1.3.6.1.4.1.529.10.15.0'; | ||
| 62 | # lan modem | ||
| 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'; | ||
| 68 | # max modems | ||
| 69 | my $snmpMdmNumber = '1.3.6.1.2.1.38.1.1.0'; | ||
| 70 | my $hostname; | ||
| 71 | my $session; | ||
| 72 | my $error; | ||
| 73 | my $response; | ||
| 74 | my %wanStatus; | ||
| 75 | |||
| 76 | |||
| 77 | my $WanAvailableChannels; | ||
| 78 | my $WanSwitchedChannels; | ||
| 79 | my $WanDisabledChannels; | ||
| 80 | my $WanActiveChannels; | ||
| 81 | my $WanNailedChannels; | ||
| 82 | my $WanOutOfServiceChannels; | ||
| 83 | my $EventCurrentActiveSessions; | ||
| 84 | my $EventTotalNoModems; | ||
| 85 | my $DeadLanModem; | ||
| 86 | my $DisabledLanModem; | ||
| 87 | my $SuspectLanModem; | ||
| 88 | my $AvailLanModem; | ||
| 89 | my $BusyLanModem; | ||
| 90 | my $MdmNumber; | ||
| 91 | |||
| 92 | |||
| 93 | sub usage { | ||
| 94 | printf "\nMissing arguments!\n"; | ||
| 95 | printf "\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"; | ||
| 98 | printf "usage: \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"; | ||
| 104 | printf "\n\n"; | ||
| 105 | exit $ERRORS{"UNKNOWN"}; | ||
| 106 | } | ||
| 107 | |||
| 108 | # Just in case of problems, let's not hang Nagios | ||
| 109 | $SIG{'ALRM'} = sub { | ||
| 110 | print ("ERROR: No snmp response from $hostname (alarm)\n"); | ||
| 111 | exit $ERRORS{"UNKNOWN"}; | ||
| 112 | }; | ||
| 113 | alarm($TIMEOUT); | ||
| 114 | |||
| 115 | |||
| 116 | $status = GetOptions("community=s",\$community, | ||
| 117 | "port=i",\$port); | ||
| 118 | if ($status == 0) | ||
| 119 | { | ||
| 120 | &usage; | ||
| 121 | } | ||
| 122 | |||
| 123 | #shift; | ||
| 124 | $hostname = shift || &usage; | ||
| 125 | |||
| 126 | |||
| 127 | |||
| 128 | push(@snmpoids,$snmpWanAvailableChannels); | ||
| 129 | push(@snmpoids,$snmpWanSwitchedChannels); | ||
| 130 | push(@snmpoids,$snmpWanDisabledChannels); | ||
| 131 | push(@snmpoids,$snmpWanActiveChannels); | ||
| 132 | push(@snmpoids,$snmpWanNailedChannels); | ||
| 133 | push(@snmpoids,$snmpWanOutOfServiceChannels); | ||
| 134 | |||
| 135 | push(@snmpoids,$snmpEventCurrentActiveSessions); | ||
| 136 | |||
| 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); | ||
| 144 | |||
| 145 | ($session, $error) = Net::SNMP->session( | ||
| 146 | -hostname => $hostname, | ||
| 147 | -community => $community, | ||
| 148 | -port => $port | ||
| 149 | ); | ||
| 150 | |||
| 151 | if (!defined($session)) { | ||
| 152 | $state='UNKNOWN'; | ||
| 153 | $answer=$error; | ||
| 154 | print ("$state: $answer"); | ||
| 155 | exit $ERRORS{$state}; | ||
| 156 | } | ||
| 157 | |||
| 158 | if (!defined($response = $session->get_request(@snmpoids))) { | ||
| 159 | $answer=$session->error; | ||
| 160 | $session->close; | ||
| 161 | $state = 'CRITICAL'; | ||
| 162 | print ("$state: $answer,$community"); | ||
| 163 | exit $ERRORS{$state}; | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 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}; | ||
| 181 | |||
| 182 | # less than 50% -> WARNING | ||
| 183 | if ( 0 < $WanOutOfServiceChannels | ||
| 184 | && $WanOutOfServiceChannels < ($snmpWanSwitchedChannels * 0.5) ) { | ||
| 185 | $state = 'WARNING'; | ||
| 186 | } | ||
| 187 | elsif ($WanOutOfServiceChannels > 0) { | ||
| 188 | $state = 'CRITICAL'; | ||
| 189 | } | ||
| 190 | elsif ($DeadLanModem > 0) { | ||
| 191 | $state = 'CRITICAL'; | ||
| 192 | } | ||
| 193 | elsif ($SuspectLanModem > 0) { | ||
| 194 | $state = 'WARNING'; | ||
| 195 | } | ||
| 196 | elsif ($AvailLanModem == 0) { | ||
| 197 | $state = 'WARNING'; | ||
| 198 | } | ||
| 199 | else { | ||
| 200 | $state = 'OK'; | ||
| 201 | } | ||
| 202 | |||
| 203 | |||
| 204 | $answer = sprintf("active sessions: %d (%d), active modems: %d (%d)<BR>", | ||
| 205 | $EventCurrentActiveSessions, | ||
| 206 | $WanSwitchedChannels, | ||
| 207 | $BusyLanModem, | ||
| 208 | $MdmNumber); | ||
| 209 | |||
| 210 | $answer .= sprintf("channels available: %d, disabled: %d", | ||
| 211 | $WanAvailableChannels, | ||
| 212 | $WanDisabledChannels); | ||
| 213 | |||
| 214 | $answer .= sprintf(", out of service: %d, nailed: %d<BR>", | ||
| 215 | $WanOutOfServiceChannels, | ||
| 216 | $WanNailedChannels); | ||
| 217 | |||
| 218 | $answer .= sprintf("modems avail.: %d, disabled: %d, suspect: %d, dead: %d<BR>", | ||
| 219 | $AvailLanModem, | ||
| 220 | $DisabledLanModem, | ||
| 221 | $SuspectLanModem, | ||
| 222 | $DeadLanModem); | ||
| 223 | |||
| 224 | $answer .= sprintf("unserviced modem calls: %d (since startup)\n", | ||
| 225 | $EventTotalNoModems); | ||
| 226 | |||
| 227 | $session->close; | ||
| 228 | |||
| 229 | print ("$state: $answer"); | ||
| 230 | exit $ERRORS{$state}; | ||
| 231 | |||
