| 1 |
#!/usr/bin/perl |
| •2 |
# ============================================================================ |
| 3 |
# ============================== INFO ======================================== |
| 4 |
# ============================================================================ |
| 5 |
# Version : 0.7 |
| 6 |
# Date : February 21 2011 |
| 7 |
# Author : Michiel Timmers ( michiel.timmers AT gmx.net) |
| 8 |
# Based on : "check_snmp_env" plugin (version 1.3) from Patrick Proy |
| 9 |
# Licence : GPL - summary below |
| 10 |
# |
| 11 |
# ============================================================================ |
| 12 |
# ============================== SUMMARY ===================================== |
| 13 |
# ============================================================================ |
| 14 |
# This plugin is an enhancement on the "check_snmp_env" plugin (version 1.3) |
| 15 |
# from Patrick Proy. The basic function of this script is to check various |
| 16 |
# hardware based information, like power supply's, fans, cards, modules etc. |
| 17 |
# Although some of the checks in this plugin are also in the "check_snmp_env" |
| 18 |
# I strongly suggest using this version as some of the checks in |
| 19 |
# "check_snmp_env" aren't efficient or don't give alarms. |
| 20 |
# |
| 21 |
# The default SNMP version has been changed from SNMPv1 to SNMPv2c because |
| 22 |
# of the use of SNMP Bulk option which is more efficient. SNMPv3 also |
| 23 |
# uses SNMP Bulk. |
| 24 |
# |
| 25 |
# This scrip supports IPv6. You can use the "-6" switch for this. |
| 26 |
# |
| 27 |
# ============================================================================ |
| 28 |
# ============================== SUPPORTED CHECKS ============================ |
| 29 |
# ============================================================================ |
| 30 |
# The following check are supported: |
| 31 |
# |
| 32 |
# NOTE(!!): There are several Cisco checks, on many Cisco devices multiple |
| 33 |
# Cisco checks will functions. |
| 34 |
# |
| 35 |
# cisco __________: Cisco Systems : Fan, power-supply, voltage, temperature |
| 36 |
# ciscoSW ________: Cisco Systems : Card and module status check |
| 37 |
# ciscoNEW _______: Cisco Systems : Sensor check for devices that have |
| 38 |
# the CISCO-ENTITY-SENSOR-MIB |
| 39 |
# nokia __________: Nokia IP : Fan, power-supply |
| 40 |
# bc _____________: Blue Coat Systems : Fan, power-supply, voltage, disk |
| 41 |
# iron ___________: IronPort : Fan, power-supply, temperature |
| 42 |
# foundry ________: Foundry Network : power supply, temperature |
| 43 |
# linux __________: lm-sensors : Fan, voltage, temperature, misc |
| 44 |
# extremeSW ______: Extreme Networks : Slot, power-supply, fan, temperature |
| 45 |
# juniper ________: Juniper Networks : Component status check |
| 46 |
# procurve _______: HP ProCurve : Fan, power-supply, temperature |
| 47 |
# netscreen ______: NetScreen : Slot, fan, power-supply |
| 48 |
# citrix _________: Citrix NetScaler : Fan, , voltage, temperture, |
| 49 |
# HA state, SSL engine |
| 50 |
# transmode ______: Transmode Systems : Check alarm table that is |
| 51 |
# not deactivated and not acknowledged |
| 52 |
# |
| 53 |
# Check the http://exchange.nagios.org website for new versions. |
| 54 |
# For comments, questions, problems and patches send me an |
| 55 |
# e-mail (michiel.timmmers AT gmx.net). |
| 56 |
# |
| 57 |
# ============================================================================ |
| 58 |
# ============================== TODO ======================================== |
| 59 |
# ============================================================================ |
| 60 |
# - cisco / ciscoSW and ciscoNEW needs to be checked regarding OID's |
| 61 |
# - Make use of "set_status" subroutine for all checks |
| 62 |
# - "linux" check does nothing (need all possible values of lm-sensors |
| 63 |
# to implement). Perhaps IPMI support, currently lacks general MIB |
| 64 |
# - "cisco","nokia","ironport","foundry","linux" needs clean up, need |
| 65 |
# snmpwalks for this |
| 66 |
# - Make more use of verbose output |
| 67 |
# - utils.pm will become deprecated. Replacement with Nagios::Plugin? |
| 68 |
# What are the effects of switching to Nagios::Plugin? |
| 69 |
# |
| 70 |
# ============================================================================ |
| 71 |
# ============================== VERSIONS ==================================== |
| 72 |
# ============================================================================ |
| 73 |
# version 0.2 : - juniper: Ignores a "Unknown" PCMCIA card |
| 74 |
# - Juniper: Standby(7) wasn't defined correctly |
| 75 |
# - juniper: Instance id's longer than 7 characters were failing |
| 76 |
# version 0.3 : - ciscoSW: Corrected the modules OID for Cisco |
| 77 |
# - ciscoSW: Standby cards don't generate critical status anymore |
| 78 |
# version 0.4 : - extreme: Added support for devices from Extreme Networks |
| 79 |
# version 0.5 : - juniper: J series routers now supported |
| 80 |
# version 0.6 : - general: Added support for IPv6 communication |
| 81 |
# version 0.7 : - ciscoNEW: Support for Cisco with CISCO-ENTITY-SENSOR-MIB |
| 82 |
# - procurve: Support for HP ProCurve |
| 83 |
# - netscreen: Support for Netscreen |
| 84 |
# - citrix: Support for Citrix Netscaler |
| 85 |
# - transmode: Support for Transmode |
| 86 |
# - extreme: Added checks for power-supply, fans and temperature |
| 87 |
# - juniper: |
| 88 |
# - bc: Blue Coat check wasn't working properly |
| 89 |
# - general: Default SNMP version is now SNMPv2c |
| 90 |
# - general: Switch default SNMPv3 from md5/des to sha/aes |
| 91 |
# - general: Lots of small fixes |
| 92 |
# |
| 93 |
# ============================================================================ |
| 94 |
# ============================== LICENCE ===================================== |
| 95 |
# ============================================================================ |
| 96 |
# This program is free software: you can redistribute it and/or modify |
| 97 |
# it under the terms of the GNU General Public License as published by |
| 98 |
# the Free Software Foundation, either version 3 of the License, or |
| 99 |
# (at your option) any later version. |
| 100 |
# |
| 101 |
# This program is distributed in the hope that it will be useful, |
| 102 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 103 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 104 |
# GNU General Public License for more details. |
| 105 |
# |
| 106 |
# You should have received a copy of the GNU General Public License |
| 107 |
# along with this program. If not, see <http://www.gnu.org/licenses/> |
| 108 |
# |
| 109 |
# ============================================================================ |
| 110 |
# ============================== HELP ======================================== |
| 111 |
# ============================================================================ |
| 112 |
# Help : ./check_snmp_environment.pl --help |
| 113 |
# |
| 114 |
# ============================================================================ |
| 115 |
|
| 116 |
use warnings; |
| 117 |
use strict; |
| 118 |
use Net::SNMP; |
| 119 |
use Getopt::Long; |
| 120 |
#use lib "/usr/local/nagios/libexec"; |
| 121 |
#use utils qw(%ERRORS $TIMEOUT); |
| 122 |
|
| 123 |
|
| 124 |
# ============================================================================ |
| 125 |
# ============================== NAGIOS VARIABLES ============================ |
| 126 |
# ============================================================================ |
| 127 |
|
| 128 |
my $TIMEOUT = 15; # This is the global script timeout, not the SNMP timeout |
| 129 |
my %ERRORS = ('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); |
| 130 |
my @Nagios_state = ("UNKNOWN","OK","WARNING","CRITICAL"); # Nagios states coding |
| 131 |
|
| 132 |
|
| 133 |
# ============================================================================ |
| 134 |
# ============================== OID VARIABLES =============================== |
| 135 |
# ============================================================================ |
| 136 |
|
| 137 |
# System description |
| 138 |
my $sysdescr = "1.3.6.1.2.1.1.1.0"; # Global system description |
| 139 |
|
| 140 |
# CISCO-ENVMON-MIB |
| 141 |
my $ciscoEnvMonMIB = "1.3.6.1.4.1.9.9.13"; # Cisco env base table |
| 142 |
my %CiscoEnvMonState = (1,"normal",2,"warning",3,"critical",4,"shutdown",5,"notPresent",6,"notFunctioning"); # Cisco states |
| 143 |
my %CiscoEnvMonNagios = (1,1 ,2,2 ,3,3 ,4,3 ,5,0, 6,3); # Nagios states returned for CIsco states (coded see @Nagios_state). |
| 144 |
my $ciscoVoltageTable = $ciscoEnvMonMIB.".1.2.1"; # Cisco voltage table |
| 145 |
my $ciscoVoltageTableIndex = $ciscoVoltageTable.".1"; #Index table |
| 146 |
my $ciscoVoltageTableDesc = $ciscoVoltageTable.".2"; #Description |
| 147 |
my $ciscoVoltageTableValue = $ciscoVoltageTable.".3"; #Value |
| 148 |
my $ciscoVoltageTableState = $ciscoVoltageTable.".7"; #Status |
| 149 |
|
| 150 |
my $ciscoTempTable = $ciscoEnvMonMIB.".1.3.1"; # Cisco temprature table |
| 151 |
my $ciscoTempTableIndex = $ciscoTempTable.".1"; #Index table |
| 152 |
my $ciscoTempTableDesc = $ciscoTempTable.".2"; #Description |
| 153 |
my $ciscoTempTableValue = $ciscoTempTable.".3"; #Value |
| 154 |
my $ciscoTempTableState = $ciscoTempTable.".6"; #Status |
| 155 |
|
| 156 |
my $ciscoFanTable = $ciscoEnvMonMIB.".1.4.1"; # Cisco fan table |
| 157 |
my $ciscoFanTableIndex = $ciscoFanTable.".1"; #Index table |
| 158 |
my $ciscoFanTableDesc = $ciscoFanTable.".2"; #Description |
| 159 |
my $ciscoFanTableState = $ciscoFanTable.".3"; #Status |
| 160 |
|
| 161 |
my $ciscoPSTable = $ciscoEnvMonMIB.".1.5.1"; # Cisco power supply table |
| 162 |
my $ciscoPSTableIndex = $ciscoPSTable.".1"; #Index table |
| 163 |
my $ciscoPSTableDesc = $ciscoPSTable.".2"; #Description |
| 164 |
my $ciscoPSTableState = $ciscoPSTable.".3"; #Status |
| 165 |
|
| 166 |
# Nokia env mib |
| 167 |
my $nokia_temp_tbl = "1.3.6.1.4.1.94.1.21.1.1.5"; |
| 168 |
my $nokia_temp = "1.3.6.1.4.1.94.1.21.1.1.5.0"; |
| 169 |
my $nokia_fan_table = "1.3.6.1.4.1.94.1.21.1.2"; |
| 170 |
my $nokia_fan_status = "1.3.6.1.4.1.94.1.21.1.2.1.1.2"; |
| 171 |
my $nokia_ps_table = "1.3.6.1.4.1.94.1.21.1.3"; |
| 172 |
my $nokia_ps_temp = "1.3.6.1.4.1.94.1.21.1.3.1.1.2"; |
| 173 |
my $nokia_ps_status = "1.3.6.1.4.1.94.1.21.1.3.1.1.3"; |
| 174 |
|
| 175 |
# Bluecoat env mib |
| 176 |
my @bc_SensorCode = ("","ok","unknown","not-installed","voltage-low-warning","voltage-low-critical", |
| 177 |
"no-power","voltage-high-warning","voltage-high-critical","voltage-high-severe", |
| 178 |
"temperature-high-warning","temperature-high-critical","temperature-high-severe", |
| 179 |
"fan-slow-warning","fan-slow-critical","fan-stopped"); # BC element status returned by MIB |
| 180 |
my @bc_status_code = (3,0,3,3,1,2,2,1,2,2,1,2,2,1,2,2); # nagios status equivallent to BC status |
| 181 |
my @bc_SensorStatus = ("","ok","unavailable","nonoperational"); # ok(1),unavailable(2),nonoperational(3) |
| 182 |
my @bc_status_sensor = (3,0,1,2); # nagios status equivallent to BC status |
| 183 |
my @bc_mesure = ("","","","Enum","volts","celsius","rpm"); |
| 184 |
my $bc_sensor_table = "1.3.6.1.4.1.3417.2.1.1.1.1.1"; # sensor table |
| 185 |
my $bc_sensor_Units = "1.3.6.1.4.1.3417.2.1.1.1.1.1.3"; # cf bc_mesure |
| 186 |
my $bc_sensor_Scale = "1.3.6.1.4.1.3417.2.1.1.1.1.1.4"; # * 10^value |
| 187 |
my $bc_sensor_Value = "1.3.6.1.4.1.3417.2.1.1.1.1.1.5"; # value |
| 188 |
my $bc_sensor_Code = "1.3.6.1.4.1.3417.2.1.1.1.1.1.6"; # bc_SensorCode |
| 189 |
my $bc_sensor_Status = "1.3.6.1.4.1.3417.2.1.1.1.1.1.7"; # bc_SensorStatus |
| 190 |
my $bc_sensor_Name = "1.3.6.1.4.1.3417.2.1.1.1.1.1.9"; # name |
| 191 |
my $bc_dsk_table = "1.3.6.1.4.1.3417.2.2.1.1.1.1"; # disk table |
| 192 |
my $bc_dsk_status = "1.3.6.1.4.1.3417.2.2.1.1.1.1.3"; # bc_DiskStatus - present(1), initializing(2), inserted(3), offline(4), removed(5), not-present(6), empty(7), bad(8), unknown(9 |
| 193 |
my $bc_dsk_vendor = "1.3.6.1.4.1.3417.2.2.1.1.1.1.5"; # bc_DiskStatus |
| 194 |
my $bc_dsk_product = "1.3.6.1.4.1.3417.2.2.1.1.1.1.6"; # bc_DiskStatus |
| 195 |
my $bc_dsk_serial = "1.3.6.1.4.1.3417.2.2.1.1.1.1.8"; # bc_DiskStatus |
| 196 |
my @bc_DiskStatus = ("","present","initializing","inserted","offline","removed","not-present","empty","bad","unknown"); |
| 197 |
my @bc_dsk_status_nagios = (3,0,1,1,1,1,0,0,2,3); |
| 198 |
|
| 199 |
# Iron Port env mib |
| 200 |
my $iron_ps_table = "1.3.6.1.4.1.15497.1.1.1.8"; # power-supply table |
| 201 |
my $iron_ps_status = "1.3.6.1.4.1.15497.1.1.1.8.1.2"; #powerSupplyNotInstalled(1), powerSupplyHealthy(2), powerSupplyNoAC(3), powerSupplyFaulty(4) |
| 202 |
my @iron_ps_status_name = ("","powerSupplyNotInstalled","powerSupplyHealthy","powerSupplyNoAC","powerSupplyFaulty"); |
| 203 |
my @iron_ps_status_nagios = (3,3,0,2,2); |
| 204 |
my $iron_ps_ha = "1.3.6.1.4.1.15497.1.1.1.8.1.3"; # ps redundancy status- powerSupplyRedundancyOK(1), powerSupplyRedundancyLost(2) |
| 205 |
my @iron_ps_ha_name = ("","powerSupplyRedundancyOK","powerSupplyRedundancyLost"); |
| 206 |
my @iron_ps_ha_nagios = (3,0,1); |
| 207 |
my $iron_ps_name = "1.3.6.1.4.1.15497.1.1.1.8.1.4"; # ps name |
| 208 |
my $iron_tmp_table = "1.3.6.1.4.1.15497.1.1.1.9"; # temp table |
| 209 |
my $iron_tmp_celcius = "1.3.6.1.4.1.15497.1.1.1.9.1.2"; # temp in celcius |
| 210 |
my $iron_tmp_name = "1.3.6.1.4.1.15497.1.1.1.9.1.3"; # name |
| 211 |
my $iron_fan_table = "1.3.6.1.4.1.15497.1.1.1.10"; # fan table |
| 212 |
my $iron_fan_rpm = "1.3.6.1.4.1.15497.1.1.1.10.1.2"; # fan speed in RPM |
| 213 |
my $iron_fan_name = "1.3.6.1.4.1.15497.1.1.1.10.1.3"; # fan name |
| 214 |
|
| 215 |
# Foundry BigIron Router Switch (FOUNDRY-SN-AGENT-MIB) |
| 216 |
my $foundry_temp = "1.3.6.1.4.1.1991.1.1.1.1.18.0"; # Chassis temperature in Deg C *2 |
| 217 |
my $foundry_temp_warn = "1.3.6.1.4.1.1991.1.1.1.1.19.0"; # Chassis warn temperature in Deg C *2 |
| 218 |
my $foundry_temp_crit = "1.3.6.1.4.1.1991.1.1.1.1.20.0"; # Chassis warn temperature in Deg C *2 |
| 219 |
my $foundry_ps_table = "1.3.6.1.4.1.1991.1.1.1.2.1"; # PS table |
| 220 |
my $foundry_ps_desc = "1.3.6.1.4.1.1991.1.1.1.2.1.1.2"; # PS desc |
| 221 |
my $foundry_ps_status = "1.3.6.1.4.1.1991.1.1.1.2.1.1.3"; # PS status |
| 222 |
my $foundry_fan_table = "1.3.6.1.4.1.1991.1.1.1.3.1"; # FAN table |
| 223 |
my $foundry_fan_desc = "1.3.6.1.4.1.1991.1.1.1.3.1.1.2"; # FAN desc |
| 224 |
my $foundry_fan_status = "1.3.6.1.4.1.1991.1.1.1.3.1.1.3"; # FAN status |
| 225 |
my @foundry_status = (3,0,2); # oper status : 1:other, 2: Normal, 3: Failure |
| 226 |
|
| 227 |
# lm-sensors |
| 228 |
my $linux_env_table = "1.3.6.1.4.1.2021.13.16"; # Global env table |
| 229 |
my $linux_temp = "1.3.6.1.4.1.2021.13.16.2.1"; # temperature table |
| 230 |
my $linux_temp_descr = "1.3.6.1.4.1.2021.13.16.2.1.2"; # temperature entry description |
| 231 |
my $linux_temp_value = "1.3.6.1.4.1.2021.13.16.2.1.3"; # temperature entry value (mC) |
| 232 |
my $linux_fan = "1.3.6.1.4.1.2021.13.16.3.1"; # fan table |
| 233 |
my $linux_fan_descr = "1.3.6.1.4.1.2021.13.16.3.1.2"; # fan entry description |
| 234 |
my $linux_fan_value = "1.3.6.1.4.1.2021.13.16.3.1.3"; # fan entry value (RPM) |
| 235 |
my $linux_volt = "1.3.6.1.4.1.2021.13.16.4.1"; # voltage table |
| 236 |
my $linux_volt_descr = "1.3.6.1.4.1.2021.13.16.4.1.2"; # voltage entry description |
| 237 |
my $linux_volt_value = "1.3.6.1.4.1.2021.13.16.4.1.3"; # voltage entry value (mV) |
| 238 |
my $linux_misc = "1.3.6.1.4.1.2021.13.16.5.1"; # misc table |
| 239 |
my $linux_misc_descr = "1.3.6.1.4.1.2021.13.16.5.1.2"; # misc entry description |
| 240 |
my $linux_misc_value = "1.3.6.1.4.1.2021.13.16.5.1.3"; # misc entry value |
| 241 |
|
| 242 |
# Cisco switches (catalys & IOS) |
| 243 |
my $cisco_chassis_card_descr = "1.3.6.1.4.1.9.3.6.11.1.3"; # Chassis card description |
| 244 |
my $cisco_chassis_card_slot = "1.3.6.1.4.1.9.3.6.11.1.7"; # Chassis card slot number |
| 245 |
my $cisco_chassis_card_state = "1.3.6.1.4.1.9.3.6.11.1.9"; # operating status of card - 1 : Not specified, 2 : Up, 3: Down, 4 : standby |
| 246 |
my @cisco_chassis_card_status_text = ("Unknown","Not specified","Up","Down","Standby"); |
| 247 |
my @cisco_chassis_card_status = (2,2,0,2,0); |
| 248 |
my $cisco_module_descr = "1.3.6.1.2.1.47.1.1.1.1.13"; # Chassis card description |
| 249 |
my $cisco_module_slot = "1.3.6.1.4.1.9.5.1.3.1.1.25"; # Chassis card slot number |
| 250 |
my $cisco_module_state = "1.3.6.1.4.1.9.9.117.1.2.1.1.2"; # operating status of card - 1:unknown, 2:ok, 3:disabled, 4:okButDiagFailed, 5:boot, 6:selfTest, 7:failed, 8:missing, 9:mismatchWithParent, |
| 251 |
# 10:mismatchConfig, 11:diagFailed, 12:dormant, 13:outOfServiceAdmin, 14:outOfServiceEnvTemp, 15:poweredDown, 16:poweredUp, |
| 252 |
# 17:powerDenied, 18:powerCycled, 19:okButPowerOverWarning, 20:okButPowerOverCritical, 21:syncInProgress |
| 253 |
my @cisco_module_status_text =("Unknown", "unknown", "OK", "Disabled", "OkButDiagFailed", "Boot", |
| 254 |
"SelfTest", "Failed", "Missing", "MismatchWithParent", "MismatchConfig", |
| 255 |
"DiagFailed", "Dormant", "OutOfServiceAdmin", "OutOfServiceEnvTemp", "PoweredDown", |
| 256 |
"PoweredUp", "PowerDenied", "PowerCycled", "OkButPowerOverWarning", |
| 257 |
"OkButPowerOverCritical", "SyncInProgress"); |
| 258 |
my @cisco_module_status = (3,3,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2); |
| 259 |
|
| 260 |
# Juniper routers (JUNOS) |
| 261 |
my $juniper_operating_descr = "1.3.6.1.4.1.2636.3.1.13.1.5"; # Component description |
| 262 |
my $juniper_operating_state = "1.3.6.1.4.1.2636.3.1.13.1.6"; # Operating status of component- Unknown(1), Running(2), Ready(3), Reset(4), RunningAtFullSpeed(5), Down(6), Standby(7) |
| 263 |
my @juniper_operating_status_text = ("--Invalid--","Unknown","Running","Ready","Reset","RunningAtFullSpeed","Down","Standby"); |
| 264 |
my @juniper_operating_status = (3,3,0,0,1,0,2,0); |
| 265 |
|
| 266 |
# Extreme switches |
| 267 |
my $extreme_slot_table = "1.3.6.1.4.1.1916.1.1.2.2.1"; |
| 268 |
my $extreme_slot_name = "1.3.6.1.4.1.1916.1.1.2.2.1.2"; # Component description |
| 269 |
my $extreme_slot_state = "1.3.6.1.4.1.1916.1.1.2.2.1.5"; # Operating status of component - NotPresent(1), testing(2), mismatch(3), failed(4), operational(5), powerdown(6), unknown(7) |
| 270 |
my $extreme_slot_serialnumber = "1.3.6.1.4.1.1916.1.1.2.2.1.6"; |
| 271 |
my @extreme_slot_state_text = ("--Invalid--","NotPresent","Testing","Mismatch","Failed","Operational","Powerdown","Unknown"); |
| 272 |
my @extreme_slot_nagios = (3,0,2,2,2,0,2,3); |
| 273 |
my $extreme_ps_table = "1.3.6.1.4.1.1916.1.1.1.27.1"; |
| 274 |
my $extreme_ps_status = "1.3.6.1.4.1.1916.1.1.1.27.1.2"; |
| 275 |
my @extreme_ps_status_text = ("--Invalid--","notPresent","presentOK","presentNotOK"); |
| 276 |
my @extreme_ps_nagios = (3,1,0,2); |
| 277 |
my $extreme_fan_table = "1.3.6.1.4.1.1916.1.1.1.9.1"; |
| 278 |
my $extreme_fan_number = "1.3.6.1.4.1.1916.1.1.1.9.1.1"; |
| 279 |
my $extreme_fan_operational = "1.3.6.1.4.1.1916.1.1.1.9.1.2"; |
| 280 |
my @extreme_fan_operational_text = ("--Invalid--","Operational","Not operational"); |
| 281 |
my @extreme_fan_nagios = (3,0,2); |
| 282 |
my $extreme_temperature_alarm = "1.3.6.1.4.1.1916.1.1.1.7.0"; |
| 283 |
my @extreme_temperature_alarm_text = ("--Invalid--","OverTemperature","OK"); |
| 284 |
my @extreme_temperature_nagios = (3,2,0); |
| 285 |
my $extreme_temperature_current = "1.3.6.1.4.1.1916.1.1.1.8.0"; |
| 286 |
|
| 287 |
|
| 288 |
# HP ProCurve switches |
| 289 |
my $procurve_operating_descr = "1.3.6.1.4.1.11.2.14.11.1.2.6.1.7"; # Component description |
| 290 |
my $procurve_operating_state = "1.3.6.1.4.1.11.2.14.11.1.2.6.1.4"; # Operating status of component - Unknown(1), Bad(2), Warning(3), Good(4), NotPresent(5) |
| 291 |
my @procurve_operating_status_text = ("--Invalid--","Unknown","Bad","Warning","Good","NotPresent"); |
| 292 |
my @procurve_operating_status = (3,3,2,1,0,4); |
| 293 |
|
| 294 |
# Netscreen |
| 295 |
my $netscreen_slot_operating_descr = "1.3.6.1.4.1.3224.21.5.1.2"; # Component description |
| 296 |
my $netscreen_slot_operating_state = "1.3.6.1.4.1.3224.21.5.1.3"; # Operating status of component - Fail?(0), Good(1) |
| 297 |
my @netscreen_slot_operating_status_text = ("Fail","Good"); |
| 298 |
my @netscreen_slot_operating_status = (2,0); |
| 299 |
my $netscreen_power_operating_descr = "1.3.6.1.4.1.3224.21.1.1.3"; # Component description |
| 300 |
my $netscreen_power_operating_state = "1.3.6.1.4.1.3224.21.1.1.2"; # Operating status of component - Fail(0), Good(1) |
| 301 |
my @netscreen_power_operating_status_text = ("Fail","Good"); |
| 302 |
my @netscreen_power_operating_status = (2,0); |
| 303 |
my $netscreen_fan_operating_descr = "1.3.6.1.4.1.3224.21.2.1.3"; # Component description |
| 304 |
my $netscreen_fan_operating_state = "1.3.6.1.4.1.3224.21.2.1.2"; # Operating status of component - Fail(0), Good(1), Not Installed(2) |
| 305 |
my @netscreen_fan_operating_status_text = ("Fail","Good","Not Installed"); |
| 306 |
my @netscreen_fan_operating_status = (2,0,4); |
| 307 |
|
| 308 |
# Cisco CISCO-ENTITY-SENSOR-MIB |
| 309 |
my $cisco_ios_xe_physicaldescr = "1.3.6.1.2.1.47.1.1.1.1.7"; |
| 310 |
my $cisco_ios_xe_type = "1.3.6.1.4.1.9.9.91.1.1.1.1.1"; |
| 311 |
my @cisco_ios_xe_type_text = ("not_specified","other","unknown","voltsAC","voltsDC","amperes","watts","hertz","celsius","percent","rpm","cmm","truthvalue","specialEnum","dBm"); |
| 312 |
my $cisco_ios_xe_scale = "1.3.6.1.4.1.9.9.91.1.1.1.1.2"; |
| 313 |
my @cisco_ios_xe_scale_power = ("0","-24","-21","-18","-15","12","e-9","e-6","e-3","e0","e3","e6","9","12","15","18","21","24"); |
| 314 |
my $cisco_ios_xe_precision = "1.3.6.1.4.1.9.9.91.1.1.1.1.3"; |
| 315 |
my $cisco_ios_xe_value = "1.3.6.1.4.1.9.9.91.1.1.1.1.4"; |
| 316 |
my $cisco_ios_xe_status = "1.3.6.1.4.1.9.9.91.1.1.1.1.5"; |
| 317 |
my @cisco_ios_xe_operating_text = ("--Invalid--","ok","unavailable","nonoperational"); |
| 318 |
my @cisco_ios_xe_operating_status = (0,1,2,3); |
| 319 |
my $cisco_ios_xe_threshold_severity = "1.3.6.1.4.1.9.9.91.1.2.1.1.2"; |
| 320 |
my $cisco_ios_xe_threshold_value = "1.3.6.1.4.1.9.9.91.1.2.1.1.4"; |
| 321 |
|
| 322 |
# Citrix NetScaler |
| 323 |
my $citrix_desc = "1.3.6.1.4.1.5951.4.1.1.41.7.1.1"; |
| 324 |
my $citrix_value = "1.3.6.1.4.1.5951.4.1.1.41.7.1.2"; |
| 325 |
my $citrix_high_availability_state = "1.3.6.1.4.1.5951.4.1.1.23.24.0"; |
| 326 |
my @citrix_high_availability_state_text = ("unknown","init","down","up","partialFail","monitorFail","monitorOk","completeFail","dumb","disabled","partialFailSsl","routemonitorFail"); |
| 327 |
my $citrix_ssl_engine_state = "1.3.6.1.4.1.5951.4.1.1.47.2.0"; |
| 328 |
my @citrix_ssl_engine_state_text = ("down","up"); |
| 329 |
|
| 330 |
# Transmode WDM MIB/OID |
| 331 |
my $transmode_table = "1.3.6.1.4.1.11857.1.1.3.2.1"; # Alarm Active Entry table |
| 332 |
my $transmode_alarm_rack = "1.3.6.1.4.1.11857.1.1.3.2.1.2"; # Non Acked Alarm rack |
| 333 |
my $transmode_alarm_slot = "1.3.6.1.4.1.11857.1.1.3.2.1.3"; # Non Acked Alarm slot |
| 334 |
my $transmode_alarm_descr = "1.3.6.1.4.1.11857.1.1.3.2.1.4"; # Non Acked Alarm description |
| 335 |
my $transmode_alarm_sev = "1.3.6.1.4.1.11857.1.1.3.2.1.5"; # Non Acked Alarm severity |
| 336 |
my $transmode_alarm_unit = "1.3.6.1.4.1.11857.1.1.3.2.1.6"; # Non Acked Alarm unit |
| 337 |
my $transmode_alarm_serial = "1.3.6.1.4.1.11857.1.1.3.2.1.7"; # Non Acked Alarm serial |
| 338 |
my $transmode_alarm_time_start = "1.3.6.1.4.1.11857.1.1.3.2.1.8"; # Time of Alarm Start |
| 339 |
my $transmode_alarm_time_end = "1.3.6.1.4.1.11857.1.1.3.2.1.9"; # Time of Alarm End |
| 340 |
my @transmode_alarm_status_text = ("Indeterminate","Critical","Major","Minor","Warning"); |
| 341 |
my @transmode_alarm_status = (1,2,2,1,1); |
| 342 |
|
| 343 |
|
| 344 |
# ============================================================================ |
| 345 |
# ============================== GLOBAL VARIABLES ============================ |
| 346 |
# ============================================================================ |
| 347 |
|
| 348 |
my $Version = '0.7'; # Version number of this script |
| 349 |
my $o_host = undef; # Hostname |
| 350 |
my $o_community = undef; # Community |
| 351 |
my $o_port = 161; # Port |
| 352 |
my $o_help = undef; # Want some help ? |
| 353 |
my $o_verb = undef; # Verbose mode |
| 354 |
my $o_version = undef; # Print version |
| 355 |
my $o_timeout = undef; # Timeout (Default 5) |
| 356 |
my $o_perf = undef; # Output performance data |
| 357 |
my $o_version1 = undef; # Use SNMPv1 |
| 358 |
my $o_version2 = undef; # Use SNMPv2c |
| 359 |
my $o_domain = undef; # Use IPv6 |
| 360 |
my $o_check_type = "cisco"; # Default check is "cisco" |
| 361 |
my @valid_types = ("cisco","nokia","bc","iron","foundry","linux","ciscoSW","extremeSW","juniper","procurve","netscreen","ciscoNEW","citrix","transmode"); |
| 362 |
my $o_temp = undef; # Max temp |
| 363 |
my $o_fan = undef; # Min fan speed |
| 364 |
my $o_login = undef; # Login for SNMPv3 |
| 365 |
my $o_passwd = undef; # Pass for SNMPv3 |
| 366 |
my $v3protocols = undef; # V3 protocol list. |
| 367 |
my $o_authproto = 'sha'; # Auth protocol |
| 368 |
my $o_privproto = 'aes'; # Priv protocol |
| 369 |
my $o_privpass = undef; # priv password |
| 370 |
|
| 371 |
|
| 372 |
# ============================================================================ |
| 373 |
# ============================== SUBROUTINES (FUNCTIONS) ===================== |
| 374 |
# ============================================================================ |
| 375 |
|
| 376 |
# Subroutine: Print version |
| 377 |
sub p_version { |
| 378 |
print "check_snmp_environment version : $Version\n"; |
| 379 |
} |
| 380 |
|
| 381 |
# Subroutine: Print Usage |
| 382 |
sub print_usage { |
| 383 |
print "Usage: $0 [-v] -H <host> [-6] -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -T (cisco|ciscoSW|ciscoNEW|nokia|bc|iron|foundry|linux|extremeSW|juniper|procurve|netscreen|citrix|transmode) [-F <rpm>] [-c <celcius>] [-f] [-t <timeout>] [-V]\n"; |
| 384 |
} |
| 385 |
|
| 386 |
# Subroutine: Check number |
| 387 |
sub isnnum { # Return true if arg is not a number |
| 388 |
my $num = shift; |
| 389 |
if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} |
| 390 |
return 1; |
| 391 |
} |
| 392 |
|
| 393 |
# Subroutine: Set final status |
| 394 |
sub set_status { # Return worst status with this order : OK, unknown, warning, critical |
| 395 |
my $new_status = shift; |
| 396 |
my $cur_status = shift; |
| 397 |
if ($new_status == 1 && $cur_status != 2) {$cur_status = $new_status;} |
| 398 |
if ($new_status == 2) {$cur_status = $new_status;} |
| 399 |
if ($new_status == 3 && $cur_status == 0) {$cur_status = $new_status;} |
| 400 |
return $cur_status; |
| 401 |
} |
| 402 |
|
| 403 |
# Subroutine: Check if SNMP table could be retrieved, otherwise give error |
| 404 |
sub check_snmp_result { |
| 405 |
my $snmp_table = shift; |
| 406 |
my $snmp_error_mesg = shift; |
| 407 |
|
| 408 |
# Check if table is defined and does not contain specified error message. |
| 409 |
# Had to do string compare it will not work with a status code |
| 410 |
if (!defined($snmp_table) && $snmp_error_mesg !~ /table is empty or does not exist/) { |
| 411 |
printf("ERROR: ". $snmp_error_mesg . " : UNKNOWN\n"); |
| 412 |
exit $ERRORS{"UNKNOWN"}; |
| 413 |
} |
| 414 |
} |
| 415 |
|
| 416 |
# Subroutine: Print complete help |
| 417 |
sub help { |
| 418 |
print "\nSNMP environmental plugin for Nagios\nVersion: ",$Version,"\n\n"; |
| 419 |
print_usage(); |
| 420 |
print <<EOT; |
| 421 |
|
| 422 |
Options: |
| 423 |
-v, --verbose |
| 424 |
Print extra debugging information |
| 425 |
-h, --help |
| 426 |
Print this help message |
| 427 |
-H, --hostname=HOST |
| 428 |
Hostname or IPv4/IPv6 address of host to check |
| 429 |
-6, --use-ipv6 |
| 430 |
Use IPv6 connection |
| 431 |
-C, --community=COMMUNITY NAME |
| 432 |
Community name for the host's SNMP agent |
| 433 |
-1, --v1 |
| 434 |
Use SNMPv1 |
| 435 |
-2, --v2c |
| 436 |
Use SNMPv2c (default) |
| 437 |
-l, --login=LOGIN ; -x, --passwd=PASSWD |
| 438 |
Login and auth password for SNMPv3 authentication |
| 439 |
If no priv password exists, implies AuthNoPriv |
| 440 |
-X, --privpass=PASSWD |
| 441 |
Priv password for SNMPv3 (AuthPriv protocol) |
| 442 |
-L, --protocols=<authproto>,<privproto> |
| 443 |
<authproto> : Authentication protocol (md5|sha : default sha) |
| 444 |
<privproto> : Priv protocole (des|aes : default aes) |
| 445 |
-P, --port=PORT |
| 446 |
SNMP port (Default 161) |
| 447 |
-T, --type=cisco|ciscoSW|ciscoNEW|nokia|bc|iron|foundry|linux|extremeSW|juniper|procurve|netscreen|citrix|transmode |
| 448 |
Environmental check : |
| 449 |
cisco __________: Cisco Systems : Fan, power-supply, voltage, temperature |
| 450 |
ciscoSW ________: Cisco Systems : Card and module status check |
| 451 |
ciscoNEW _______: Cisco Systems : Sensor check for devices that have the CISCO-ENTITY-SENSOR-MIB |
| 452 |
nokia __________: Nokia IP : Fan, power-supply |
| 453 |
bc _____________: Blue Coat Systems : Fan, power-supply, voltage, disk |
| 454 |
iron ___________: IronPort : Fan, power-supply, temperature |
| 455 |
foundry ________: Foundry Network : power supply, temperature |
| 456 |
linux __________: lm-sensors : Fan, voltage, temperature, misc |
| 457 |
extremeSW ______: Extreme Networks : Slot, power-supply, fan, temperature |
| 458 |
juniper ________: Juniper Networks : Component status check |
| 459 |
procurve _______: HP ProCurve : Fan, power-supply, temperature |
| 460 |
netscreen ______: NetScreen : Slot, fan, power-supply (ScreenOS 6.1 and newer) |
| 461 |
citrix _________: Citrix NetScaler : Fan, , voltage, temperture (thresholds are hardcoded), HA state, SSL engine |
| 462 |
transmode ______: Transmode Systems : Check alarm table that is not deactivated and not acknowledged |
| 463 |
-F, --fan=<rpm> |
| 464 |
Minimum fan rpm value (only needed for 'iron' & 'linux') |
| 465 |
-c, --celcius=<celcius> |
| 466 |
Maximum temp in degree celcius (only needed for 'iron' & 'linux') |
| 467 |
-f, --perfparse |
| 468 |
Perfparse compatible output |
| 469 |
-t, --timeout=INTEGER |
| 470 |
Timeout for SNMP in seconds (Default: 5) |
| 471 |
-V, --version |
| 472 |
Prints version number |
| 473 |
|
| 474 |
Notes: |
| 475 |
- Check the http://exchange.nagios.org website for new versions. |
| 476 |
- For questions, problems and patches send me an e-mail (michiel.timmmers AT gmx.net). |
| 477 |
|
| 478 |
EOT |
| 479 |
} |
| 480 |
|
| 481 |
# Subroutine: Verbose output |
| 482 |
sub verb { |
| 483 |
my $t=shift; |
| 484 |
print $t,"\n" if defined($o_verb); |
| 485 |
} |
| 486 |
|
| 487 |
# Subroutine: Verbose output |
| 488 |
sub check_options { |
| 489 |
Getopt::Long::Configure ("bundling"); |
| 490 |
GetOptions( |
| 491 |
'v' => \$o_verb, 'verbose' => \$o_verb, |
| 492 |
'h' => \$o_help, 'help' => \$o_help, |
| 493 |
'H:s' => \$o_host, 'hostname:s' => \$o_host, |
| 494 |
'p:i' => \$o_port, 'port:i' => \$o_port, |
| 495 |
'C:s' => \$o_community, 'community:s' => \$o_community, |
| 496 |
'l:s' => \$o_login, 'login:s' => \$o_login, |
| 497 |
'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd, |
| 498 |
'X:s' => \$o_privpass, 'privpass:s' => \$o_privpass, |
| 499 |
'L:s' => \$v3protocols, 'protocols:s' => \$v3protocols, |
| 500 |
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, |
| 501 |
'V' => \$o_version, 'version' => \$o_version, |
| 502 |
'6' => \$o_domain, 'use-ipv6' => \$o_domain, |
| 503 |
'1' => \$o_version1, 'v1' => \$o_version1, |
| 504 |
'2' => \$o_version2, 'v2c' => \$o_version2, |
| 505 |
'f' => \$o_perf, 'perfparse' => \$o_perf, |
| 506 |
'T:s' => \$o_check_type, 'type:s' => \$o_check_type, |
| 507 |
'F:i' => \$o_fan, 'fan:i' => \$o_fan, |
| 508 |
'c:i' => \$o_temp, 'celcius:i' => \$o_temp |
| 509 |
); |
| 510 |
|
| 511 |
# Check the -T option |
| 512 |
my $T_option_valid=0; |
| 513 |
foreach (@valid_types) { |
| 514 |
if ($_ eq $o_check_type) { |
| 515 |
$T_option_valid=1; |
| 516 |
} |
| 517 |
} |
| 518 |
if ( $T_option_valid == 0 ) { |
| 519 |
print "Invalid check type (-T)!\n"; |
| 520 |
print_usage(); |
| 521 |
exit $ERRORS{"UNKNOWN"}; |
| 522 |
} |
| 523 |
|
| 524 |
# Basic checks |
| 525 |
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) { |
| 526 |
print "Timeout must be >1 and <60 !\n"; |
| 527 |
print_usage(); |
| 528 |
exit $ERRORS{"UNKNOWN"}; |
| 529 |
} |
| 530 |
if (!defined($o_timeout)) { |
| 531 |
$o_timeout=5; |
| 532 |
} |
| 533 |
if (defined ($o_help) ) { |
| 534 |
help(); |
| 535 |
exit $ERRORS{"UNKNOWN"}; |
| 536 |
} |
| 537 |
|
| 538 |
if (defined($o_version)) { |
| 539 |
p_version(); |
| 540 |
exit $ERRORS{"UNKNOWN"}; |
| 541 |
} |
| 542 |
|
| 543 |
# check host and filter |
| 544 |
if ( ! defined($o_host) ) { |
| 545 |
print_usage(); |
| 546 |
exit $ERRORS{"UNKNOWN"}; |
| 547 |
} |
| 548 |
|
| 549 |
# Check IPv6 |
| 550 |
if (defined ($o_domain)) { |
| 551 |
$o_domain="udp/ipv6"; |
| 552 |
} else { |
| 553 |
$o_domain="udp/ipv4"; |
| 554 |
} |
| 555 |
|
| 556 |
# Check SNMP information |
| 557 |
if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) ){ |
| 558 |
print "Put SNMP login info!\n"; |
| 559 |
print_usage(); |
| 560 |
exit $ERRORS{"UNKNOWN"}; |
| 561 |
} |
| 562 |
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2)) ){ |
| 563 |
print "Can't mix SNMP v1,v2c,v3 protocols!\n"; |
| 564 |
print_usage(); |
| 565 |
exit $ERRORS{"UNKNOWN"}; |
| 566 |
} |
| 567 |
|
| 568 |
# Check SNMPv3 information |
| 569 |
if (defined ($v3protocols)) { |
| 570 |
if (!defined($o_login)) { |
| 571 |
print "Put SNMP V3 login info with protocols!\n"; |
| 572 |
print_usage(); |
| 573 |
exit $ERRORS{"UNKNOWN"}; |
| 574 |
} |
| 575 |
my @v3proto=split(/,/,$v3protocols); |
| 576 |
if ((defined ($v3proto[0])) && ($v3proto[0] ne "")) { |
| 577 |
$o_authproto=$v3proto[0]; |
| 578 |
} |
| 579 |
if (defined ($v3proto[1])) { |
| 580 |
$o_privproto=$v3proto[1]; |
| 581 |
} |
| 582 |
if ((defined ($v3proto[1])) && (!defined($o_privpass))) { |
| 583 |
print "Put SNMP v3 priv login info with priv protocols!\n"; |
| 584 |
print_usage(); |
| 585 |
exit $ERRORS{"UNKNOWN"}; |
| 586 |
} |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
|
| 591 |
# ============================================================================ |
| 592 |
# ============================== MAIN ======================================== |
| 593 |
# ============================================================================ |
| 594 |
|
| 595 |
check_options(); |
| 596 |
|
| 597 |
# Check gobal timeout if SNMP screws up |
| 598 |
if (defined($TIMEOUT)) { |
| 599 |
verb("Alarm at ".$TIMEOUT." + ".$o_timeout); |
| 600 |
alarm($TIMEOUT+$o_timeout); |
| 601 |
} else { |
| 602 |
verb("no global timeout defined : ".$o_timeout." + 15"); |
| 603 |
alarm ($o_timeout+15); |
| 604 |
} |
| 605 |
|
| 606 |
# Report when the script gets "stuck" in a loop or takes to long |
| 607 |
$SIG{'ALRM'} = sub { |
| 608 |
print "UNKNOWN: Script timed out\n"; |
| 609 |
exit $ERRORS{"UNKNOWN"}; |
| 610 |
}; |
| 611 |
|
| 612 |
# Connect to host |
| 613 |
my ($session,$error); |
| 614 |
if (defined($o_login) && defined($o_passwd)) { |
| 615 |
# SNMPv3 login |
| 616 |
verb("SNMPv3 login"); |
| 617 |
if (!defined ($o_privpass)) { |
| 618 |
# SNMPv3 login (Without encryption) |
| 619 |
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto"); |
| 620 |
($session, $error) = Net::SNMP->session( |
| 621 |
-domain => $o_domain, |
| 622 |
-hostname => $o_host, |
| 623 |
-version => 3, |
| 624 |
-username => $o_login, |
| 625 |
-authpassword => $o_passwd, |
| 626 |
-authprotocol => $o_authproto, |
| 627 |
-timeout => $o_timeout |
| 628 |
); |
| 629 |
} else { |
| 630 |
# SNMPv3 login (With encryption) |
| 631 |
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto"); |
| 632 |
($session, $error) = Net::SNMP->session( |
| 633 |
-domain => $o_domain, |
| 634 |
-hostname => $o_host, |
| 635 |
-version => 3, |
| 636 |
-username => $o_login, |
| 637 |
-authpassword => $o_passwd, |
| 638 |
-authprotocol => $o_authproto, |
| 639 |
-privpassword => $o_privpass, |
| 640 |
-privprotocol => $o_privproto, |
| 641 |
-timeout => $o_timeout |
| 642 |
); |
| 643 |
} |
| 644 |
} else { |
| 645 |
if ((defined ($o_version2)) || (!defined ($o_version1))) { |
| 646 |
# SNMPv2 login |
| 647 |
verb("SNMP v2c login"); |
| 648 |
($session, $error) = Net::SNMP->session( |
| 649 |
-domain => $o_domain, |
| 650 |
-hostname => $o_host, |
| 651 |
-version => 2, |
| 652 |
-community => $o_community, |
| 653 |
-port => $o_port, |
| 654 |
-timeout => $o_timeout |
| 655 |
); |
| 656 |
} else { |
| 657 |
# SNMPv1 login |
| 658 |
verb("SNMP v1 login"); |
| 659 |
($session, $error) = Net::SNMP->session( |
| 660 |
-domain => $o_domain, |
| 661 |
-hostname => $o_host, |
| 662 |
-version => 1, |
| 663 |
-community => $o_community, |
| 664 |
-port => $o_port, |
| 665 |
-timeout => $o_timeout |
| 666 |
); |
| 667 |
} |
| 668 |
} |
| 669 |
|
| 670 |
# Check if there are any problems with the session |
| 671 |
if (!defined($session)) { |
| 672 |
printf("ERROR opening session: %s.\n", $error); |
| 673 |
exit $ERRORS{"UNKNOWN"}; |
| 674 |
} |
| 675 |
|
| 676 |
my $exit_val=undef; |
| 677 |
|
| 678 |
|
| 679 |
# ============================================================================ |
| 680 |
# ============================== CISCO ======================================= |
| 681 |
# ============================================================================ |
| 682 |
|
| 683 |
if ($o_check_type eq "cisco") { |
| 684 |
|
| 685 |
verb("Checking cisco env"); |
| 686 |
|
| 687 |
# Get load table |
| 688 |
my $resultat = $session->get_table(Baseoid => $ciscoEnvMonMIB); |
| 689 |
&check_snmp_result($resultat,$session->error); |
| 690 |
|
| 691 |
# Get env data index |
| 692 |
my (@voltindex,@tempindex,@fanindex,@psindex)=(undef,undef,undef,undef); |
| 693 |
my ($voltexist,$tempexist,$fanexist,$psexist)=(0,0,0,0); |
| 694 |
my @oid=undef; |
| 695 |
foreach my $key ( keys %$resultat) { |
| 696 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 697 |
if ( $key =~ /$ciscoVoltageTableDesc/ ) { |
| 698 |
@oid=split (/\./,$key); |
| 699 |
$voltindex[$voltexist++] = pop(@oid); |
| 700 |
} |
| 701 |
if ( $key =~ /$ciscoTempTableDesc/ ) { |
| 702 |
@oid=split (/\./,$key); |
| 703 |
$tempindex[$tempexist++] = pop(@oid); |
| 704 |
} |
| 705 |
if ( $key =~ /$ciscoFanTableDesc/ ) { |
| 706 |
@oid=split (/\./,$key); |
| 707 |
$fanindex[$fanexist++] = pop(@oid); |
| 708 |
} |
| 709 |
if ( $key =~ /$ciscoPSTableDesc/ ) { |
| 710 |
@oid=split (/\./,$key); |
| 711 |
$psindex[$psexist++] = pop(@oid); |
| 712 |
} |
| 713 |
} |
| 714 |
|
| 715 |
if ( ($voltexist ==0) && ($tempexist ==0) && ($fanexist ==0) && ($psexist ==0) ) { |
| 716 |
print "No Environemental data found : UNKNOWN \n"; |
| 717 |
exit $ERRORS{"UNKNOWN"}; |
| 718 |
} |
| 719 |
|
| 720 |
my $perf_output=""; |
| 721 |
# Get the data |
| 722 |
my ($i,$cur_status)=(undef,undef); |
| 723 |
|
| 724 |
my $volt_global=0; |
| 725 |
my %volt_status; |
| 726 |
if ($fanexist !=0) { |
| 727 |
for ($i=0;$i < $voltexist; $i++) { |
| 728 |
$cur_status=$$resultat{$ciscoVoltageTableState. "." . $voltindex[$i]}; |
| 729 |
verb ($$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}); |
| 730 |
verb ($cur_status); |
| 731 |
if (!defined ($cur_status)) { ### Error TODO |
| 732 |
$volt_global=1; |
| 733 |
} |
| 734 |
if (defined($$resultat{$ciscoVoltageTableValue."." . $voltindex[$i]})) { |
| 735 |
$perf_output.=" '".$$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}."'=" ; |
| 736 |
$perf_output.=$$resultat{$ciscoVoltageTableValue."." . $voltindex[$i]}; |
| 737 |
} |
| 738 |
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { |
| 739 |
$volt_global= 1; |
| 740 |
$volt_status{$$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}}=$cur_status; |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
my $temp_global=0; |
| 747 |
my %temp_status; |
| 748 |
if ($tempexist !=0) { |
| 749 |
for ($i=0;$i < $tempexist; $i++) { |
| 750 |
$cur_status=$$resultat{$ciscoTempTableState . "." . $tempindex[$i]}; |
| 751 |
verb ($$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}); |
| 752 |
verb ($cur_status); |
| 753 |
if (!defined ($cur_status)) { ### Error TODO |
| 754 |
$temp_global=1; |
| 755 |
} |
| 756 |
if (defined($$resultat{$ciscoTempTableValue."." . $tempindex[$i]})) { |
| 757 |
$perf_output.=" '".$$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}."'=" ; |
| 758 |
$perf_output.=$$resultat{$ciscoTempTableValue."." . $tempindex[$i]}; |
| 759 |
} |
| 760 |
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { |
| 761 |
$temp_global= 1; |
| 762 |
$temp_status{$$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}}=$cur_status; |
| 763 |
} |
| 764 |
} |
| 765 |
} |
| 766 |
|
| 767 |
|
| 768 |
my $fan_global=0; |
| 769 |
my %fan_status; |
| 770 |
if ($fanexist !=0) { |
| 771 |
for ($i=0;$i < $fanexist; $i++) { |
| 772 |
$cur_status=$$resultat{$ciscoFanTableState . "." . $fanindex[$i]}; |
| 773 |
verb ($$resultat{$ciscoFanTableDesc .".".$fanindex[$i]}); |
| 774 |
verb ($cur_status); |
| 775 |
if (!defined ($cur_status)) { ### Error TODO |
| 776 |
$fan_global=1; |
| 777 |
} |
| 778 |
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { |
| 779 |
$fan_global= 1; |
| 780 |
$fan_status{$$resultat{$ciscoFanTableDesc .".".$fanindex[$i]}}=$cur_status; |
| 781 |
} |
| 782 |
} |
| 783 |
} |
| 784 |
|
| 785 |
my $ps_global=0; |
| 786 |
my %ps_status; |
| 787 |
if ($psexist !=0) { |
| 788 |
for ($i=0;$i < $psexist; $i++) { |
| 789 |
$cur_status=$$resultat{$ciscoPSTableState . "." . $psindex[$i]}; |
| 790 |
if (!defined ($cur_status)) { ### Error TODO |
| 791 |
$fan_global=1; |
| 792 |
} |
| 793 |
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { |
| 794 |
$ps_global= 1; |
| 795 |
$ps_status{$$resultat{$ciscoPSTableDesc .".".$psindex[$i]}}=$cur_status; |
| 796 |
} |
| 797 |
} |
| 798 |
} |
| 799 |
|
| 800 |
my $global_state=0; |
| 801 |
my $output=""; |
| 802 |
|
| 803 |
if ($fanexist !=0) { |
| 804 |
if ($fan_global ==0) { |
| 805 |
$output .= $fanexist." Fan OK"; |
| 806 |
$global_state=1 if ($global_state==0); |
| 807 |
} else { |
| 808 |
foreach (keys %fan_status) { |
| 809 |
$output .= "Fan " . $_ . ":" . $CiscoEnvMonState {$fan_status{$_}} ." "; |
| 810 |
if ($global_state < $CiscoEnvMonNagios{$fan_status{$_}} ) { |
| 811 |
$global_state = $CiscoEnvMonNagios{$fan_status{$_}} ; |
| 812 |
} |
| 813 |
} |
| 814 |
} |
| 815 |
} |
| 816 |
|
| 817 |
if ($psexist !=0) { |
| 818 |
$output .= ", " if ($output ne ""); |
| 819 |
if ($ps_global ==0) { |
| 820 |
$output .= $psexist." ps OK"; |
| 821 |
$global_state=1 if ($global_state==0); |
| 822 |
} else { |
| 823 |
foreach (keys %ps_status) { |
| 824 |
$output .= "ps " . $_ . ":" . $CiscoEnvMonState {$ps_status{$_}} ." "; |
| 825 |
if ($global_state < $CiscoEnvMonNagios{$ps_status{$_}} ) { |
| 826 |
$global_state = $CiscoEnvMonNagios{$ps_status{$_}} ; |
| 827 |
} |
| 828 |
} |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
if ($voltexist !=0) { |
| 833 |
$output .= ", " if ($output ne ""); |
| 834 |
if ($volt_global ==0) { |
| 835 |
$output .= $voltexist." volt OK"; |
| 836 |
$global_state=1 if ($global_state==0); |
| 837 |
} else { |
| 838 |
foreach (keys %volt_status) { |
| 839 |
$output .= "volt " . $_ . ":" . $CiscoEnvMonState {$volt_status{$_}} ." "; |
| 840 |
if ($global_state < $CiscoEnvMonNagios{$volt_status{$_}} ) { |
| 841 |
$global_state = $CiscoEnvMonNagios{$volt_status{$_}} ; |
| 842 |
} |
| 843 |
} |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
if ($tempexist !=0) { |
| 848 |
$output .= ", " if ($output ne ""); |
| 849 |
if ($temp_global ==0) { |
| 850 |
$output .= $tempexist." temp OK"; |
| 851 |
$global_state=1 if ($global_state==0); |
| 852 |
} else { |
| 853 |
foreach (keys %temp_status) { |
| 854 |
$output .= "temp " . $_ . ":" . $CiscoEnvMonState {$temp_status{$_}} ." "; |
| 855 |
if ($global_state < $CiscoEnvMonNagios{$temp_status{$_}} ) { |
| 856 |
$global_state = $CiscoEnvMonNagios{$temp_status{$_}} ; |
| 857 |
} |
| 858 |
} |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 863 |
$session->close; |
| 864 |
|
| 865 |
#print $output," : ",$Nagios_state[$global_state]," | ",$perf_output,"\n"; |
| 866 |
print $output," : ",$Nagios_state[$global_state],"\n"; |
| 867 |
$exit_val=$ERRORS{$Nagios_state[$global_state]}; |
| 868 |
|
| 869 |
exit $exit_val; |
| 870 |
|
| 871 |
} |
| 872 |
|
| 873 |
|
| 874 |
# ============================================================================ |
| 875 |
# ============================== NOKIA ======================================= |
| 876 |
# ============================================================================ |
| 877 |
|
| 878 |
if ($o_check_type eq "nokia") { |
| 879 |
|
| 880 |
verb("Checking nokia env"); |
| 881 |
|
| 882 |
# Define variables |
| 883 |
my $resultat; |
| 884 |
my ($fan_status,$ps_status,$temp_status)=(0,0,0); |
| 885 |
my ($fan_exist,$ps_exist,$temp_exist)=(0,0,0); |
| 886 |
my ($num_fan,$num_ps)=(0,0); |
| 887 |
my ($num_fan_nok,$num_ps_nok)=(0,0); |
| 888 |
my $global_status=0; |
| 889 |
my $output=""; |
| 890 |
|
| 891 |
# get temp |
| 892 |
$resultat = $session->get_table(Baseoid => $nokia_temp_tbl); |
| 893 |
|
| 894 |
if (defined($resultat)) { |
| 895 |
verb ("temp found"); |
| 896 |
$temp_exist=1; |
| 897 |
if ($$resultat{$nokia_temp} != 1) { |
| 898 |
$temp_status=2;$global_status=1; |
| 899 |
$output="Temp CRITICAL "; |
| 900 |
} else { |
| 901 |
$output="Temp OK "; |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
# Get fan table |
| 906 |
$resultat = $session->get_table(Baseoid => $nokia_fan_table); |
| 907 |
|
| 908 |
if (defined($resultat)) { |
| 909 |
$fan_exist=1; |
| 910 |
foreach my $key ( keys %$resultat) { |
| 911 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 912 |
if ( $key =~ /$nokia_fan_status/ ) { |
| 913 |
if ($$resultat{$key} != 1) { $fan_status=1; $num_fan_nok++} |
| 914 |
$num_fan++; |
| 915 |
} |
| 916 |
} |
| 917 |
if ($fan_status==0) { |
| 918 |
$output.= ", ".$num_fan." fan OK"; |
| 919 |
} else { |
| 920 |
$output.= ", ".$num_fan_nok."/".$num_fan." fan CRITICAL"; |
| 921 |
$global_status=2; |
| 922 |
} |
| 923 |
} |
| 924 |
|
| 925 |
# Get ps table |
| 926 |
$resultat = $session->get_table(Baseoid => $nokia_ps_table); |
| 927 |
|
| 928 |
if (defined($resultat)) { |
| 929 |
$ps_exist=1; |
| 930 |
foreach my $key ( keys %$resultat) { |
| 931 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 932 |
if ( $key =~ /$nokia_ps_status/ ) { |
| 933 |
if ($$resultat{$key} != 1) { $ps_status=1; $num_ps_nok++;} |
| 934 |
$num_ps++; |
| 935 |
} |
| 936 |
if ( $key =~ /$nokia_ps_temp/ ) { |
| 937 |
if ($$resultat{$key} != 1) { if ($ps_status==0) {$ps_status=2;$num_ps_nok++;} } |
| 938 |
} |
| 939 |
} |
| 940 |
if ($ps_status==0) { |
| 941 |
$output.= ", ".$num_ps." ps OK"; |
| 942 |
} elsif ($ps_status==2) { |
| 943 |
$output.= ", ".$num_ps_nok."/".$num_ps." ps WARNING (temp)"; |
| 944 |
if ($global_status != 2) {$global_status=1;} |
| 945 |
} else { |
| 946 |
$output.= ", ".$num_ps_nok."/".$num_ps." ps CRITICAL"; |
| 947 |
$global_status=2; |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 952 |
$session->close; |
| 953 |
|
| 954 |
verb ("status : $global_status"); |
| 955 |
|
| 956 |
if ( ($fan_exist+$ps_exist+$temp_exist) == 0) { |
| 957 |
print "No environemental informations found : UNKNOWN\n"; |
| 958 |
exit $ERRORS{"UNKNOWN"}; |
| 959 |
} |
| 960 |
|
| 961 |
if ($global_status==0) { |
| 962 |
print $output." : all OK\n"; |
| 963 |
exit $ERRORS{"OK"}; |
| 964 |
} |
| 965 |
|
| 966 |
if ($global_status==1) { |
| 967 |
print $output." : WARNING\n"; |
| 968 |
exit $ERRORS{"WARNING"}; |
| 969 |
} |
| 970 |
|
| 971 |
if ($global_status==2) { |
| 972 |
print $output." : CRITICAL\n"; |
| 973 |
exit $ERRORS{"CRITICAL"}; |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
|
| 978 |
# ============================================================================ |
| 979 |
# ============================== BLUECOAT ==================================== |
| 980 |
# ============================================================================ |
| 981 |
|
| 982 |
if ($o_check_type eq "bc") { |
| 983 |
|
| 984 |
verb("Checking bluecoat env"); |
| 985 |
|
| 986 |
# Define variables |
| 987 |
my $final_status = 0; |
| 988 |
my $output = ""; |
| 989 |
my $output_perf = ""; |
| 990 |
my $tmp_status_sensor; |
| 991 |
my $tmp_status_code; |
| 992 |
my ($num_fan,$num_other,$num_volt,$num_temp,$num_disk)=(0,0,0,0,0); |
| 993 |
my ($num_fan_ok,$num_other_ok,$num_volt_ok,$num_temp_ok,$num_disk_ok)=(0,0,0,0,0); |
| 994 |
my ($sens_name,$sens_status,$sens_scale,$sens_value,$sens_code,$sens_unit)=(undef,undef,undef,undef,undef,undef); |
| 995 |
|
| 996 |
# Get SNMP table(s) and check the result |
| 997 |
my $resultat_sensor = $session->get_table(Baseoid => $bc_sensor_table); |
| 998 |
&check_snmp_result($resultat_sensor,$session->error); |
| 999 |
my $resultat_disk = $session->get_table(Baseoid => $bc_dsk_table); |
| 1000 |
&check_snmp_result($resultat_disk,$session->error); |
| 1001 |
|
| 1002 |
# Check the sensor table |
| 1003 |
if (defined($resultat_sensor)) { |
| 1004 |
verb ("sensor table found"); |
| 1005 |
foreach my $key ( keys %$resultat_sensor) { |
| 1006 |
if ($key =~ /$bc_sensor_Name/) { |
| 1007 |
$sens_name = $$resultat_sensor{$key}; |
| 1008 |
$key =~ s/$bc_sensor_Name//; |
| 1009 |
|
| 1010 |
$sens_status = $$resultat_sensor{$bc_sensor_Status.$key}; |
| 1011 |
$sens_scale = $$resultat_sensor{$bc_sensor_Scale.$key}; |
| 1012 |
$sens_value = $$resultat_sensor{$bc_sensor_Value.$key} * 10 ** $sens_scale; |
| 1013 |
$sens_code = $$resultat_sensor{$bc_sensor_Code.$key}; |
| 1014 |
$sens_unit = $$resultat_sensor{$bc_sensor_Units.$key}; |
| 1015 |
$sens_scale = $$resultat_sensor{$bc_sensor_Scale.$key}; |
| 1016 |
|
| 1017 |
if ($sens_status != 1 || $sens_code != 1) { # check is there is something wrong with either the status or code |
| 1018 |
if ($output ne "") { $output.=", ";} |
| 1019 |
if ($sens_status != 1 && $sens_code != 1) { # If both the status and code are not reporting "ok" use the following output |
| 1020 |
$output .= $sens_name ." sensor ".$bc_SensorStatus[$sens_status].", reports ".$sens_value." ".$bc_mesure[$sens_unit]." (".$bc_SensorCode[$sens_code].")"; |
| 1021 |
} |
| 1022 |
if ($sens_status != 1 && $sens_code == 1) { # If only the status is not reporting "ok" |
| 1023 |
$output .= $sens_name ." sensor ".$bc_SensorStatus[$sens_status]; |
| 1024 |
} |
| 1025 |
if ($sens_status == 1 && $sens_code != 1) { # If only the code is not reporting "ok" |
| 1026 |
$output .= $sens_name ." reports ".$sens_value." ".$bc_mesure[$sens_unit]." (".$bc_SensorCode[$sens_code].")"; |
| 1027 |
} |
| 1028 |
|
| 1029 |
# Set the status |
| 1030 |
$tmp_status_sensor = $bc_status_sensor[$sens_status]; |
| 1031 |
$tmp_status_code = $bc_status_code[$sens_code]; |
| 1032 |
$final_status = &set_status($tmp_status_sensor,$final_status); |
| 1033 |
$final_status = &set_status($tmp_status_code,$final_status); |
| 1034 |
} |
| 1035 |
|
| 1036 |
# If performance data is enabled then output name with value |
| 1037 |
if (defined($o_perf)) { |
| 1038 |
if ($output_perf ne "") { $output_perf .=" ";} |
| 1039 |
$output_perf .= "'".$sens_name."'="; |
| 1040 |
my $perf_value = $sens_value; |
| 1041 |
$output_perf .= $perf_value; |
| 1042 |
} |
| 1043 |
|
| 1044 |
# Count fans sensors |
| 1045 |
if ($bc_mesure[$sens_unit] eq "rpm") { |
| 1046 |
$num_fan++; |
| 1047 |
if ($sens_status == 1 && $sens_code == 1) { $num_fan_ok++; } |
| 1048 |
} |
| 1049 |
|
| 1050 |
# Count temperature sensors |
| 1051 |
if ($bc_mesure[$sens_unit] eq "celsius") { |
| 1052 |
$num_temp++; |
| 1053 |
if ($sens_status == 1 && $sens_code == 1) { $num_temp_ok++; } |
| 1054 |
} |
| 1055 |
|
| 1056 |
# Count voltage sensors |
| 1057 |
if ($bc_mesure[$sens_unit] eq "volts") { |
| 1058 |
$num_volt++; |
| 1059 |
if ($sens_status == 1 && $sens_code == 1) { $num_volt_ok++; } |
| 1060 |
} |
| 1061 |
if (!$bc_mesure[$sens_unit] =~ /rpm|celsius|volts/) { |
| 1062 |
$num_other++; |
| 1063 |
if ($sens_status == 1 && $sens_code == 1) { $num_other_ok++;} |
| 1064 |
} |
| 1065 |
} |
| 1066 |
} |
| 1067 |
} |
| 1068 |
|
| 1069 |
# Check the disk table |
| 1070 |
if (defined($resultat_disk )) { |
| 1071 |
foreach my $key ( keys %$resultat_disk ) { |
| 1072 |
my ($dsk_name,$dsk_status)=(undef,undef); |
| 1073 |
if ( $key =~ /$bc_dsk_status/ ) { |
| 1074 |
$num_disk++; |
| 1075 |
$dsk_status=$bc_dsk_status_nagios[$$resultat_disk{$key}]; |
| 1076 |
$key =~ s/$bc_dsk_status//; |
| 1077 |
|
| 1078 |
if ( $dsk_status != 0) { |
| 1079 |
if ($output ne "") { $output.=", ";} |
| 1080 |
$output .= $$resultat_disk{$bc_dsk_vendor.$key} . "(S/N:".$$resultat_disk{$bc_dsk_serial.$key} ." MODEL:". $$resultat_disk{$bc_dsk_product.$key} . ") - ". $bc_DiskStatus[$$resultat_disk {$bc_dsk_status.$key}]; |
| 1081 |
$final_status = &set_status($dsk_status,$final_status); |
| 1082 |
} else { |
| 1083 |
$num_disk_ok++; |
| 1084 |
} |
| 1085 |
if($$resultat_disk{$bc_dsk_status.$key} == 6){ |
| 1086 |
$num_disk--; |
| 1087 |
$num_disk_ok--; |
| 1088 |
} |
| 1089 |
|
| 1090 |
} |
| 1091 |
} |
| 1092 |
} |
| 1093 |
|
| 1094 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1095 |
$session->close; |
| 1096 |
|
| 1097 |
if ($num_fan+$num_other+$num_volt+$num_temp+$num_disk == 0) { |
| 1098 |
print "No information found : UNKNOWN\n"; |
| 1099 |
exit $ERRORS{"UNKNOWN"}; |
| 1100 |
} |
| 1101 |
|
| 1102 |
if ($output ne "") {$output.=" : ";} |
| 1103 |
|
| 1104 |
if ($num_fan!=0) { |
| 1105 |
if ($num_fan == $num_fan_ok) { |
| 1106 |
$output.= $num_fan . " fan OK, "; |
| 1107 |
} else { |
| 1108 |
$output.= $num_fan_ok . "/" . $num_fan ." fan OK, "; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
|
| 1112 |
if ($num_temp!=0) { |
| 1113 |
if ($num_temp == $num_temp_ok) { |
| 1114 |
$output.= $num_temp . " temp OK, "; |
| 1115 |
} else { |
| 1116 |
$output.= $num_temp_ok . "/" . $num_temp ." temp OK, "; |
| 1117 |
} |
| 1118 |
} |
| 1119 |
|
| 1120 |
if ($num_volt!=0) { |
| 1121 |
if ($num_volt == $num_volt_ok) { |
| 1122 |
$output.= $num_volt . " volt OK, "; |
| 1123 |
} else { |
| 1124 |
$output.= $num_volt_ok . "/" . $num_volt ." volt OK, "; |
| 1125 |
} |
| 1126 |
} |
| 1127 |
|
| 1128 |
if ($num_other!=0) { |
| 1129 |
if ($num_other == $num_other_ok) { |
| 1130 |
$output.= $num_other . " other OK, "; |
| 1131 |
} else { |
| 1132 |
$output.= $num_other_ok . "/" . $num_other ." other OK, "; |
| 1133 |
} |
| 1134 |
} |
| 1135 |
|
| 1136 |
if ($num_disk!=0) { |
| 1137 |
if ($num_disk == $num_disk_ok) { |
| 1138 |
$output.= $num_disk . " disk OK"; |
| 1139 |
} else { |
| 1140 |
$output.= $num_disk_ok . "/" . $num_disk ." disk OK"; |
| 1141 |
} |
| 1142 |
} |
| 1143 |
|
| 1144 |
if ($final_status == 3) { |
| 1145 |
print $output," : UNKNOWN\n"; |
| 1146 |
exit $ERRORS{"UNKNOWN"}; |
| 1147 |
} |
| 1148 |
|
| 1149 |
if ($final_status == 2) { |
| 1150 |
print $output," : CRITICAL\n"; |
| 1151 |
exit $ERRORS{"CRITICAL"}; |
| 1152 |
} |
| 1153 |
|
| 1154 |
if ($final_status == 1) { |
| 1155 |
print $output," : WARNING\n"; |
| 1156 |
exit $ERRORS{"WARNING"}; |
| 1157 |
} |
| 1158 |
|
| 1159 |
print $output," : OK\n"; |
| 1160 |
exit $ERRORS{"OK"}; |
| 1161 |
} |
| 1162 |
|
| 1163 |
|
| 1164 |
# ============================================================================ |
| 1165 |
# ============================== IRONPORT ==================================== |
| 1166 |
# ============================================================================ |
| 1167 |
|
| 1168 |
if ($o_check_type eq "iron") { |
| 1169 |
|
| 1170 |
verb("Checking Ironport env"); |
| 1171 |
|
| 1172 |
my $resultat; |
| 1173 |
# status : 0=ok, 1=warn, 2=crit |
| 1174 |
my ($fan_status,$ps_status,$temp_status)=(0,0,0); |
| 1175 |
my ($fan_exist,$ps_exist,$temp_exist)=(0,0,0); |
| 1176 |
my ($num_fan,$num_ps,$num_temp)=(0,0,0); |
| 1177 |
my ($num_fan_nok,$num_ps_nok,$num_temp_nok)=(0,0,0); |
| 1178 |
my $global_status=0; |
| 1179 |
my $output=""; |
| 1180 |
# get temp if $o_temp is defined |
| 1181 |
if (defined($o_temp)) { |
| 1182 |
verb("Checking temp < $o_temp"); |
| 1183 |
$resultat = $session->get_table(Baseoid => $iron_tmp_table); |
| 1184 |
|
| 1185 |
if (defined($resultat)) { |
| 1186 |
verb ("temp found"); |
| 1187 |
$temp_exist=1; |
| 1188 |
foreach my $key ( keys %$resultat) { |
| 1189 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 1190 |
if ( $key =~ /$iron_tmp_celcius/ ) { |
| 1191 |
verb("Status : $$resultat{$key}"); |
| 1192 |
if ($$resultat{$key} > $o_temp) { |
| 1193 |
my @index_oid=split(/\./,$key); |
| 1194 |
my $index_oid_key=pop(@index_oid); |
| 1195 |
$output .= ",Temp : ". $$resultat{ $iron_tmp_name.".".$index_oid_key}." : ".$$resultat{$key}." C"; |
| 1196 |
$temp_status=2; |
| 1197 |
$num_temp_nok++; |
| 1198 |
} |
| 1199 |
$num_temp++; |
| 1200 |
} |
| 1201 |
} |
| 1202 |
if ($temp_status==0) { |
| 1203 |
$output.= ", ".$num_temp." temp < ".$o_temp." OK"; |
| 1204 |
} else { |
| 1205 |
$output.= ", ".$num_temp_nok."/".$num_temp." temp probes CRITICAL"; |
| 1206 |
$global_status=2; |
| 1207 |
} |
| 1208 |
} |
| 1209 |
} |
| 1210 |
|
| 1211 |
# Get fan status if $o_fan is defined |
| 1212 |
if (defined($o_fan)) { |
| 1213 |
verb("Checking fan > $o_fan"); |
| 1214 |
$resultat = $session->get_table(Baseoid => $iron_fan_table); |
| 1215 |
|
| 1216 |
if (defined($resultat)) { |
| 1217 |
verb ("fan found"); |
| 1218 |
$fan_exist=1; |
| 1219 |
foreach my $key ( keys %$resultat) { |
| 1220 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 1221 |
if ( $key =~ /$iron_fan_rpm/ ) { |
| 1222 |
verb("Status : $$resultat{$key}"); |
| 1223 |
if ($$resultat{$key} < $o_fan) { |
| 1224 |
my @index_oid=split(/\./,$key); |
| 1225 |
my $index_oid_key=pop(@index_oid); |
| 1226 |
$output .= ",Fan ". $$resultat{ $iron_fan_name.".".$index_oid_key}." : ".$$resultat{$key}." RPM"; |
| 1227 |
$fan_status=2; |
| 1228 |
$num_fan_nok++; |
| 1229 |
} |
| 1230 |
$num_fan++; |
| 1231 |
} |
| 1232 |
} |
| 1233 |
if ($fan_status==0) { |
| 1234 |
$output.= ", ".$num_fan." fan > ".$o_fan." OK"; |
| 1235 |
} else { |
| 1236 |
$output.= ", ".$num_fan_nok."/".$num_fan." fans CRITICAL"; |
| 1237 |
$global_status=2; |
| 1238 |
} |
| 1239 |
} |
| 1240 |
} |
| 1241 |
|
| 1242 |
# Get power supply status |
| 1243 |
verb("Checking PS"); |
| 1244 |
$resultat = $session->get_table(Baseoid => $iron_ps_table); |
| 1245 |
|
| 1246 |
if (defined($resultat)) { |
| 1247 |
verb ("ps found"); |
| 1248 |
$ps_exist=1; |
| 1249 |
foreach my $key ( keys %$resultat) { |
| 1250 |
verb("OID : $key, Desc : $$resultat{$key}"); |
| 1251 |
if ( $key =~ /$iron_ps_status/ ) { |
| 1252 |
verb("Status : $iron_ps_status_name[$$resultat{$key}]"); |
| 1253 |
if ($iron_ps_status_nagios[$$resultat{$key}] != 0) { |
| 1254 |
my @index_oid=split(/\./,$key); |
| 1255 |
my $index_oid_key=pop(@index_oid); |
| 1256 |
$output .= ",PS ". $$resultat{$iron_ps_name.".".$index_oid_key}." : ".$iron_ps_status_name[$$resultat{$key}]; |
| 1257 |
$ps_status=2; |
| 1258 |
$num_ps_nok++; |
| 1259 |
} |
| 1260 |
$num_ps++; |
| 1261 |
} |
| 1262 |
} |
| 1263 |
if ($ps_status==0) { |
| 1264 |
$output.= ", ".$num_ps." ps OK"; |
| 1265 |
} else { |
| 1266 |
$output.= ", ".$num_ps_nok."/".$num_ps." ps CRITICAL"; |
| 1267 |
$global_status=2; |
| 1268 |
} |
| 1269 |
} |
| 1270 |
|
| 1271 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1272 |
$session->close; |
| 1273 |
|
| 1274 |
verb ("status : $global_status"); |
| 1275 |
|
| 1276 |
if ( ($fan_exist+$ps_exist+$temp_exist) == 0) { |
| 1277 |
print "No environemental informations found : UNKNOWN\n"; |
| 1278 |
exit $ERRORS{"UNKNOWN"}; |
| 1279 |
} |
| 1280 |
|
| 1281 |
$output =~ s/^,//; |
| 1282 |
|
| 1283 |
if ($global_status==0) { |
| 1284 |
print $output." : all OK\n"; |
| 1285 |
exit $ERRORS{"OK"}; |
| 1286 |
} |
| 1287 |
|
| 1288 |
if ($global_status==1) { |
| 1289 |
print $output." : WARNING\n"; |
| 1290 |
exit $ERRORS{"WARNING"}; |
| 1291 |
} |
| 1292 |
|
| 1293 |
if ($global_status==2) { |
| 1294 |
print $output." : CRITICAL\n"; |
| 1295 |
exit $ERRORS{"CRITICAL"}; |
| 1296 |
} |
| 1297 |
} |
| 1298 |
|
| 1299 |
|
| 1300 |
# ============================================================================ |
| 1301 |
# ============================== FOUNDRY ===================================== |
| 1302 |
# ============================================================================ |
| 1303 |
|
| 1304 |
if ($o_check_type eq "foundry") { |
| 1305 |
|
| 1306 |
verb("Checking foundry env"); |
| 1307 |
|
| 1308 |
# Define variables |
| 1309 |
my $global_status = 0; |
| 1310 |
my $output = ""; |
| 1311 |
my @foundry_temp_oid=($foundry_temp,$foundry_temp_warn,$foundry_temp_crit); |
| 1312 |
|
| 1313 |
# Get SNMP table(s) and check the result |
| 1314 |
my $result_temp = $session->get_request(Varbindlist => \@foundry_temp_oid); |
| 1315 |
|
| 1316 |
my $temp_found=0; |
| 1317 |
if (defined($result_temp)) { |
| 1318 |
$temp_found=1; |
| 1319 |
#Temp found |
| 1320 |
$output = "Temp : " . $$result_temp{$foundry_temp} / 2; |
| 1321 |
if ($$result_temp{$foundry_temp} > $$result_temp{$foundry_temp_crit}) { # Temp above critical |
| 1322 |
$output.= " > ". $$result_temp{$foundry_temp_crit} / 2 . " : CRITICAL"; |
| 1323 |
$global_status=3; |
| 1324 |
} elsif ( $$result_temp{$foundry_temp} > $$result_temp{$foundry_temp_warn}) { # Temp above warning |
| 1325 |
$output.= " > ". $$result_temp{$foundry_temp_warn} / 2 . " : WARNING"; |
| 1326 |
$global_status=2; |
| 1327 |
} else { |
| 1328 |
$output.= " < ". $$result_temp{$foundry_temp_warn} / 2 . " : OK"; |
| 1329 |
$global_status=1; |
| 1330 |
} |
| 1331 |
} |
| 1332 |
|
| 1333 |
# Get PS table (TODO : Bug in FAN table, see with Foundry). |
| 1334 |
|
| 1335 |
my $result_ps = $session->get_table(Baseoid => $foundry_ps_table); |
| 1336 |
&check_snmp_result($result_ps,$session->error); |
| 1337 |
|
| 1338 |
my $ps_num=0; |
| 1339 |
if (defined($result_ps)) { |
| 1340 |
$output .=", " if defined($output); |
| 1341 |
foreach my $key ( keys %$result_ps) { |
| 1342 |
verb("OID : $key, Desc : $$result_ps{$key}"); |
| 1343 |
if ($$result_ps{$key} =~ /$foundry_ps_desc/) { |
| 1344 |
$ps_num++; |
| 1345 |
my @oid_list = split (/\./,$key); |
| 1346 |
my $index_ps = pop (@oid_list); |
| 1347 |
$index_ps= $foundry_ps_status . "." . $index_ps; |
| 1348 |
if (defined ($$result_ps{$index_ps})) { |
| 1349 |
if ($$result_ps{$index_ps} == 3) { |
| 1350 |
$output.="PS ".$$result_ps{$key}." : FAILURE"; |
| 1351 |
$global_status=3; |
| 1352 |
} elsif ($$result_ps{$index_ps} == 2) { |
| 1353 |
$global_status=1 if ($global_status==0); |
| 1354 |
} else { |
| 1355 |
$output.= "ps ".$$result_ps{$key}." : OTHER"; |
| 1356 |
} |
| 1357 |
} else { |
| 1358 |
$output.= "ps ".$$result_ps{$key}." : UNDEFINED STATUS"; |
| 1359 |
} |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
|
| 1365 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1366 |
$session->close; |
| 1367 |
|
| 1368 |
if (($ps_num+$temp_found) == 0) { |
| 1369 |
print "No data found : UNKNOWN\n"; |
| 1370 |
exit $ERRORS{"UNKNOWN"}; |
| 1371 |
} |
| 1372 |
|
| 1373 |
if ($global_status==1) { |
| 1374 |
print $output." : all OK\n"; |
| 1375 |
exit $ERRORS{"OK"}; |
| 1376 |
} |
| 1377 |
|
| 1378 |
if ($global_status==2) { |
| 1379 |
print $output." : WARNING\n"; |
| 1380 |
exit $ERRORS{"WARNING"}; |
| 1381 |
} |
| 1382 |
|
| 1383 |
if ($global_status==3) { |
| 1384 |
print $output." : CRITICAL\n"; |
| 1385 |
exit $ERRORS{"CRITICAL"}; |
| 1386 |
} |
| 1387 |
|
| 1388 |
print $output." : UNKNOWN\n"; |
| 1389 |
exit $ERRORS{"UNKNOWN"}; |
| 1390 |
|
| 1391 |
} |
| 1392 |
|
| 1393 |
|
| 1394 |
# ============================================================================ |
| 1395 |
# ============================== LINUX LM-SENSORS ============================ |
| 1396 |
# ============================================================================ |
| 1397 |
|
| 1398 |
if ($o_check_type eq "linux") { |
| 1399 |
|
| 1400 |
verb("Checking linux env"); |
| 1401 |
|
| 1402 |
# Define variables |
| 1403 |
my $output = ""; |
| 1404 |
my $index; |
| 1405 |
my ($sens_name,$sens_status,$sens_value,$sens_unit)=(undef,undef,undef,undef); |
| 1406 |
|
| 1407 |
# Get SNMP table(s) and check the result |
| 1408 |
my $resultat = $session->get_table(Baseoid => $linux_env_table); |
| 1409 |
&check_snmp_result($resultat,$session->error); |
| 1410 |
|
| 1411 |
foreach my $key ( keys %$resultat) { |
| 1412 |
if ($key =~ /$linux_temp_descr/) { |
| 1413 |
$sens_name=$$resultat{$key}; |
| 1414 |
$index=(split /\./,$key)[-1]; |
| 1415 |
$sens_value=$$resultat{$linux_temp_value.".".$index}/1000; |
| 1416 |
printf("TSensor %s : %.0f\n",$sens_name,$sens_value); |
| 1417 |
} |
| 1418 |
if ($key =~ /$linux_fan_descr/) { |
| 1419 |
$sens_name=$$resultat{$key}; |
| 1420 |
$index=(split /\./,$key)[-1]; |
| 1421 |
$sens_value=$$resultat{$linux_fan_value.".".$index}; |
| 1422 |
printf("FSensor %s : %.0f\n",$sens_name,$sens_value); |
| 1423 |
} |
| 1424 |
if ($key =~ /$linux_volt_descr/) { |
| 1425 |
$sens_name=$$resultat{$key}; |
| 1426 |
$index=(split /\./,$key)[-1]; |
| 1427 |
$sens_value=$$resultat{$linux_volt_value.".".$index}/1000; |
| 1428 |
printf("VSensor %s : %.2f\n",$sens_name,$sens_value); |
| 1429 |
} |
| 1430 |
if ($key =~ /$linux_misc_descr/) { |
| 1431 |
$sens_name=$$resultat{$key}; |
| 1432 |
$index=(split /\./,$key)[-1]; |
| 1433 |
$sens_value=$$resultat{$linux_misc_value.".".$index}; |
| 1434 |
printf("MSensor %s : %.2f\n",$sens_name,$sens_value); |
| 1435 |
} |
| 1436 |
} |
| 1437 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1438 |
$session->close; |
| 1439 |
|
| 1440 |
print "Not implemented yet : UNKNOWN\n"; |
| 1441 |
exit $ERRORS{"UNKNOWN"}; |
| 1442 |
} |
| 1443 |
|
| 1444 |
|
| 1445 |
# ============================================================================ |
| 1446 |
# ============================== CISCO CARD/MODULE =========================== |
| 1447 |
# ============================================================================ |
| 1448 |
|
| 1449 |
if ($o_check_type eq "ciscoSW") { |
| 1450 |
|
| 1451 |
verb("Checking ciscoSW env"); |
| 1452 |
|
| 1453 |
# Define variables |
| 1454 |
my $output =""; |
| 1455 |
my $final_status =0; |
| 1456 |
my $card_output =""; |
| 1457 |
my $modules_output =""; |
| 1458 |
my $tmp_status; |
| 1459 |
my $result_t; |
| 1460 |
my $index; |
| 1461 |
my @temp_oid; |
| 1462 |
my ($num_cards,$num_cards_ok,$num_modules,$num_modules_ok)=(0,0,0,0); |
| 1463 |
|
| 1464 |
# Get SNMP table(s) and check the result |
| 1465 |
my $resultat_c = $session->get_table(Baseoid => $cisco_chassis_card_state); |
| 1466 |
&check_snmp_result($resultat_c,$session->error); |
| 1467 |
my $resultat_m = $session->get_table(Baseoid => $cisco_module_state); |
| 1468 |
&check_snmp_result($resultat_m,$session->error); |
| 1469 |
|
| 1470 |
# Check cards |
| 1471 |
if (defined($resultat_c)) { |
| 1472 |
foreach my $key ( keys %$resultat_c) { |
| 1473 |
if ($key =~ /$cisco_chassis_card_state/) { |
| 1474 |
$num_cards++; |
| 1475 |
$tmp_status=$cisco_chassis_card_status[$$resultat_c{$key}]; |
| 1476 |
if ($tmp_status == 0) { |
| 1477 |
$num_cards_ok++; |
| 1478 |
} else { |
| 1479 |
$final_status=2; |
| 1480 |
$index=(split /\./,$key)[-1]; |
| 1481 |
@temp_oid=($cisco_chassis_card_descr.".".$index,$cisco_chassis_card_slot.".".$index); |
| 1482 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 1483 |
if (!defined($result_t)) { $card_output.="Invalid card(UNKNOWN)";} |
| 1484 |
else { |
| 1485 |
if ($card_output ne "") {$card_output.=", ";} |
| 1486 |
$card_output.= "Card slot " . $$result_t{$cisco_chassis_card_slot.".".$index}; |
| 1487 |
$card_output.= "(" .$$result_t{$cisco_chassis_card_descr.".".$index} ."): "; |
| 1488 |
$card_output.= "status " . $cisco_chassis_card_status_text[$$resultat_c{$key}]; |
| 1489 |
} |
| 1490 |
} |
| 1491 |
} |
| 1492 |
} |
| 1493 |
if ($card_output ne "") {$card_output.=", ";} |
| 1494 |
} |
| 1495 |
|
| 1496 |
# Check modules |
| 1497 |
if (defined($resultat_m)) { |
| 1498 |
foreach my $key ( keys %$resultat_m) { |
| 1499 |
if ($key =~ /$cisco_module_state/) { |
| 1500 |
$num_modules++; |
| 1501 |
$tmp_status=$cisco_module_status[$$resultat_m{$key}]; |
| 1502 |
if ($tmp_status == 0) { |
| 1503 |
$num_modules_ok++; |
| 1504 |
} else { |
| 1505 |
my $module_slot_present=0; |
| 1506 |
$index=(split /\./,$key)[-1]; |
| 1507 |
@temp_oid=($cisco_module_slot.".".$index); |
| 1508 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 1509 |
if (defined($result_t)) { |
| 1510 |
if ($modules_output ne "") {$modules_output.=", ";} |
| 1511 |
$modules_output.= "Module slot " . $$result_t{$cisco_module_slot.".".$index}; |
| 1512 |
$module_slot_present=1; |
| 1513 |
} |
| 1514 |
@temp_oid=($cisco_module_descr.".".$index); |
| 1515 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 1516 |
if (defined($result_t)) { |
| 1517 |
if ($module_slot_present == 1) { |
| 1518 |
$modules_output.= "(" .$$result_t{$cisco_module_descr.".".$index} ."): "; |
| 1519 |
} else { |
| 1520 |
if ($modules_output ne "") {$modules_output.=", ";} |
| 1521 |
$modules_output.= "Module (" .$$result_t{$cisco_module_descr.".".$index} ."): "; |
| 1522 |
} |
| 1523 |
$modules_output.= "status " . $cisco_module_status_text[$$resultat_m{$key}]; |
| 1524 |
$module_slot_present=1; |
| 1525 |
} |
| 1526 |
if ($module_slot_present == 0) { |
| 1527 |
$modules_output.="Invalid module(UNKNOWN) : status " . $cisco_module_status_text[$$resultat_m{$key}]; |
| 1528 |
} |
| 1529 |
if ($tmp_status == 1 && $final_status==0) { |
| 1530 |
$final_status=1; |
| 1531 |
} else { |
| 1532 |
$final_status=2; |
| 1533 |
} |
| 1534 |
} |
| 1535 |
} |
| 1536 |
} |
| 1537 |
} |
| 1538 |
|
| 1539 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1540 |
$session->close; |
| 1541 |
|
| 1542 |
if ($num_cards==0 && $num_modules==0) { |
| 1543 |
print "No cards/modules found : UNKNOWN\n"; |
| 1544 |
exit $ERRORS{"UNKNOWN"}; |
| 1545 |
} |
| 1546 |
$output=$card_output . $modules_output; |
| 1547 |
if ($output ne "") {$output.=" : ";} |
| 1548 |
if ($num_cards!=0) { |
| 1549 |
if ($num_cards == $num_cards_ok) { |
| 1550 |
$output.= $num_cards . " cards OK, "; |
| 1551 |
} else { |
| 1552 |
$output.= $num_cards_ok . "/" . $num_cards ." cards OK, "; |
| 1553 |
$final_status=2; |
| 1554 |
} |
| 1555 |
} |
| 1556 |
|
| 1557 |
if ($num_modules!=0) { |
| 1558 |
if ($num_modules == $num_modules_ok) { |
| 1559 |
$output.= $num_modules . " modules OK "; |
| 1560 |
} else { |
| 1561 |
$output.= $num_modules_ok . "/" . $num_modules ." modules OK "; |
| 1562 |
$final_status=2; |
| 1563 |
} |
| 1564 |
} |
| 1565 |
|
| 1566 |
if ($final_status == 2) { |
| 1567 |
print $output," : CRITICAL\n"; |
| 1568 |
exit $ERRORS{"CRITICAL"}; |
| 1569 |
} |
| 1570 |
|
| 1571 |
if ($final_status == 1) { |
| 1572 |
print $output," : WARNING\n"; |
| 1573 |
exit $ERRORS{"WARNING"}; |
| 1574 |
} |
| 1575 |
|
| 1576 |
print $output," : OK\n"; |
| 1577 |
exit $ERRORS{"OK"}; |
| 1578 |
} |
| 1579 |
|
| 1580 |
|
| 1581 |
# ============================================================================ |
| 1582 |
# ============================== JUNIPER ===================================== |
| 1583 |
# ============================================================================ |
| 1584 |
|
| 1585 |
if ($o_check_type eq "juniper") { |
| 1586 |
|
| 1587 |
verb("Checking juniper env"); |
| 1588 |
|
| 1589 |
# Define variables |
| 1590 |
my $output = ""; |
| 1591 |
my $final_status = 0; |
| 1592 |
my $card_output = ""; |
| 1593 |
my $ignore = ": Ignored: "; |
| 1594 |
my $tmp_status; |
| 1595 |
my $result_t; |
| 1596 |
my $index; |
| 1597 |
my @temp_oid; |
| 1598 |
my ($num_cards,$num_cards_ok)=(0,0); |
| 1599 |
|
| 1600 |
# Get SNMP table(s) and check the result |
| 1601 |
my $resultat_c = $session->get_table(Baseoid => $juniper_operating_state); |
| 1602 |
&check_snmp_result($resultat_c,$session->error); |
| 1603 |
|
| 1604 |
if (defined($resultat_c)) { |
| 1605 |
foreach my $key ( keys %$resultat_c) { |
| 1606 |
if ($key =~ /$juniper_operating_state/) { |
| 1607 |
$num_cards++; |
| 1608 |
$tmp_status=$juniper_operating_status[$$resultat_c{$key}]; |
| 1609 |
if ($tmp_status == 0) { |
| 1610 |
$num_cards_ok++; |
| 1611 |
} else { |
| 1612 |
$index = $key; |
| 1613 |
$index =~ s/^$juniper_operating_state.//; |
| 1614 |
@temp_oid=($juniper_operating_descr.".".$index); |
| 1615 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 1616 |
if ($$result_t{$juniper_operating_descr.".".$index} =~ /PCMCIA|USB|Flash|Fan Tray [0-9]$/ && $tmp_status == 3) { |
| 1617 |
$ignore.= "(" .$$result_t{$juniper_operating_descr.".".$index} ."),"; |
| 1618 |
} |
| 1619 |
|
| 1620 |
else { |
| 1621 |
$final_status = &set_status($tmp_status,$final_status); |
| 1622 |
if (!defined($result_t)) { |
| 1623 |
$card_output.="Invalid component(UNKNOWN)"; |
| 1624 |
} |
| 1625 |
else { |
| 1626 |
if ($card_output ne "") {$card_output.=", ";} |
| 1627 |
$card_output.= "(" .$$result_t{$juniper_operating_descr.".".$index} ."): "; |
| 1628 |
$card_output.= "status " . $juniper_operating_status_text[$$resultat_c{$key}]; |
| 1629 |
} |
| 1630 |
} |
| 1631 |
} |
| 1632 |
} |
| 1633 |
} |
| 1634 |
if ($card_output ne "") {$card_output.=", ";} |
| 1635 |
} |
| 1636 |
|
| 1637 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1638 |
$session->close; |
| 1639 |
|
| 1640 |
if ($num_cards==0) { |
| 1641 |
print "No components found : UNKNOWN\n"; |
| 1642 |
exit $ERRORS{"UNKNOWN"}; |
| 1643 |
} |
| 1644 |
$output=$card_output; |
| 1645 |
if ($output ne "") {$output.=" : ";} |
| 1646 |
if ($num_cards!=0) { |
| 1647 |
if ($num_cards == $num_cards_ok) { |
| 1648 |
$output.= $num_cards . " components OK"; |
| 1649 |
} else { |
| 1650 |
$output.= $num_cards_ok . "/" . $num_cards ." components OK" .$ignore; |
| 1651 |
} |
| 1652 |
} |
| 1653 |
|
| 1654 |
if ($final_status == 3) { |
| 1655 |
print $output," : UNKNOWN\n"; |
| 1656 |
exit $ERRORS{"UNKNOWN"}; |
| 1657 |
} |
| 1658 |
|
| 1659 |
if ($final_status == 2) { |
| 1660 |
print $output," : CRITICAL\n"; |
| 1661 |
exit $ERRORS{"CRITICAL"}; |
| 1662 |
} |
| 1663 |
|
| 1664 |
if ($final_status == 1) { |
| 1665 |
print $output," : WARNING\n"; |
| 1666 |
exit $ERRORS{"WARNING"}; |
| 1667 |
} |
| 1668 |
|
| 1669 |
print $output," : OK\n"; |
| 1670 |
exit $ERRORS{"OK"}; |
| 1671 |
} |
| 1672 |
|
| 1673 |
|
| 1674 |
# ============================================================================ |
| 1675 |
# ============================== EXTREME ===================================== |
| 1676 |
# ============================================================================ |
| 1677 |
|
| 1678 |
if ($o_check_type eq "extremeSW") { |
| 1679 |
|
| 1680 |
verb("Checking extreme env"); |
| 1681 |
|
| 1682 |
# Define variables |
| 1683 |
my $tmp_status; |
| 1684 |
my $index; |
| 1685 |
my $output = ""; |
| 1686 |
my $final_status = 0; |
| 1687 |
my $slot_output = ""; |
| 1688 |
my $ps_output = ""; |
| 1689 |
my $fan_output = ""; |
| 1690 |
my $temperature_output = ""; |
| 1691 |
my ($num_slot,$num_slot_ok) = (0,0); |
| 1692 |
my ($num_ps,$num_ps_ok) = (0,0); |
| 1693 |
my ($num_fan,$num_fan_ok) = (0,0); |
| 1694 |
my ($slot_name,$slot_state,$slot_serialnumber,$slot_state_text) = (undef,undef,undef,undef); |
| 1695 |
my ($ps_status,$ps_status_text) = (undef,undef); |
| 1696 |
my ($fan_number,$fan_operational,$fan_operational_text) = (undef,undef,undef); |
| 1697 |
my ($temperature_state,$temperature_state_text,$temperature_current) = (undef,undef,undef); |
| 1698 |
|
| 1699 |
# Get SNMP table(s) and check the result |
| 1700 |
my $resultat_slot = $session->get_table(Baseoid => $extreme_slot_table); |
| 1701 |
&check_snmp_result($resultat_slot,$session->error); |
| 1702 |
my $resultat_ps = $session->get_table(Baseoid => $extreme_ps_table); |
| 1703 |
&check_snmp_result($resultat_ps,$session->error); |
| 1704 |
my $resultat_fan = $session->get_table(Baseoid => $extreme_fan_table); |
| 1705 |
&check_snmp_result($resultat_fan,$session->error); |
| 1706 |
my @extreme_temp_alarm_oid =($extreme_temperature_alarm); |
| 1707 |
my $resultat_temp_alarm = $session->get_request( Varbindlist => \@extreme_temp_alarm_oid ); |
| 1708 |
my @extreme_temp_current_oid =($extreme_temperature_current); |
| 1709 |
my $resultat_temp_current = $session->get_request( Varbindlist => \@extreme_temp_current_oid ); |
| 1710 |
|
| 1711 |
# Check slot |
| 1712 |
if (defined($resultat_slot)) { |
| 1713 |
foreach my $key ( keys %$resultat_slot) { |
| 1714 |
if ($key =~ /$extreme_slot_name/) { |
| 1715 |
$key =~ s/$extreme_slot_name//; |
| 1716 |
|
| 1717 |
# Set the slot variables |
| 1718 |
$slot_name = $$resultat_slot{$extreme_slot_name.$key}; |
| 1719 |
$slot_state = $$resultat_slot{$extreme_slot_state.$key}; |
| 1720 |
$slot_state_text = $extreme_slot_state_text[$slot_state]; |
| 1721 |
$slot_serialnumber = $$resultat_slot{$extreme_slot_serialnumber.$key}; |
| 1722 |
$tmp_status = $extreme_slot_nagios[$slot_state]; |
| 1723 |
$final_status = &set_status($tmp_status,$final_status); |
| 1724 |
|
| 1725 |
if ($slot_state != 1){ |
| 1726 |
$num_slot++; |
| 1727 |
if ($tmp_status == 0) { |
| 1728 |
$num_slot_ok++; |
| 1729 |
} |
| 1730 |
|
| 1731 |
else { |
| 1732 |
if ($slot_output ne "") {$slot_output.=", ";} |
| 1733 |
$slot_output.= "(Slot: " . $slot_name; |
| 1734 |
$slot_output.= " Status: " . $slot_state_text; |
| 1735 |
$slot_output.= " S/N: " . $slot_serialnumber . ")"; |
| 1736 |
} |
| 1737 |
} |
| 1738 |
} |
| 1739 |
} |
| 1740 |
if ($slot_output ne "") {$slot_output.=", ";} |
| 1741 |
} |
| 1742 |
|
| 1743 |
# Check power-supply |
| 1744 |
if (defined($resultat_ps)) { |
| 1745 |
foreach my $key ( keys %$resultat_ps) { |
| 1746 |
if ($key =~ /$extreme_ps_status/) { |
| 1747 |
$num_ps++; |
| 1748 |
$key =~ s/$extreme_ps_status//; |
| 1749 |
|
| 1750 |
# Set the slot variables |
| 1751 |
$ps_status = $$resultat_ps{$extreme_ps_status.$key}; |
| 1752 |
$ps_status_text = $extreme_ps_status_text[$ps_status]; |
| 1753 |
$tmp_status = $extreme_ps_nagios[$ps_status]; |
| 1754 |
$final_status = &set_status($tmp_status,$final_status); |
| 1755 |
|
| 1756 |
if ($tmp_status == 0) { |
| 1757 |
$num_ps_ok++; |
| 1758 |
} |
| 1759 |
|
| 1760 |
else { |
| 1761 |
if ($ps_output ne "") {$ps_output.=", ";} |
| 1762 |
$ps_output.= "(Power-supply status: " . $ps_status_text . ")"; |
| 1763 |
} |
| 1764 |
} |
| 1765 |
} |
| 1766 |
if ($ps_output ne "") {$ps_output.=", ";} |
| 1767 |
} |
| 1768 |
|
| 1769 |
# Check fan |
| 1770 |
if (defined($resultat_fan)) { |
| 1771 |
foreach my $key ( keys %$resultat_fan) { |
| 1772 |
if ($key =~ /$extreme_fan_number/) { |
| 1773 |
$num_fan++; |
| 1774 |
$key =~ s/$extreme_fan_number//; |
| 1775 |
|
| 1776 |
# Set the slot variables |
| 1777 |
$fan_number = $$resultat_fan{$extreme_fan_number.$key}; |
| 1778 |
$fan_operational = $$resultat_fan{$extreme_fan_operational.$key}; |
| 1779 |
$fan_operational_text = $extreme_fan_operational_text[$fan_operational]; |
| 1780 |
$tmp_status = $extreme_fan_nagios[$fan_operational]; |
| 1781 |
$final_status = &set_status($tmp_status,$final_status); |
| 1782 |
|
| 1783 |
if ($tmp_status == 0) { |
| 1784 |
$num_fan_ok++; |
| 1785 |
} |
| 1786 |
|
| 1787 |
else { |
| 1788 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 1789 |
$fan_output.= "(Fan: " . $fan_number; |
| 1790 |
$fan_output.= " Status: " . $fan_operational_text . ")"; |
| 1791 |
} |
| 1792 |
} |
| 1793 |
} |
| 1794 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 1795 |
} |
| 1796 |
|
| 1797 |
# Check temperature |
| 1798 |
if (defined($resultat_temp_alarm) && defined($resultat_temp_current)){ |
| 1799 |
$temperature_state = $$resultat_temp_alarm{$extreme_temperature_alarm}; |
| 1800 |
$temperature_state_text = $extreme_temperature_alarm_text[$temperature_state]; |
| 1801 |
$temperature_current = $$resultat_temp_current{$extreme_temperature_current}; |
| 1802 |
|
| 1803 |
$tmp_status = $extreme_temperature_nagios[$temperature_state]; |
| 1804 |
$final_status = &set_status($tmp_status,$final_status); |
| 1805 |
|
| 1806 |
$temperature_output.= "Temp: " . $temperature_state_text; |
| 1807 |
$temperature_output.= " (" . $temperature_current . " celcius)"; |
| 1808 |
} |
| 1809 |
|
| 1810 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1811 |
$session->close; |
| 1812 |
|
| 1813 |
if ($num_slot == 0 && $num_ps == 0 && $num_fan == 0) { |
| 1814 |
print "No slot/power-supply/fan found : UNKNOWN\n"; |
| 1815 |
exit $ERRORS{"UNKNOWN"}; |
| 1816 |
} |
| 1817 |
|
| 1818 |
$output=$slot_output . $ps_output . $fan_output; |
| 1819 |
|
| 1820 |
if ($output ne "") {$output.=": ";} |
| 1821 |
|
| 1822 |
if ($num_slot != 0) { |
| 1823 |
if ($num_slot == $num_slot_ok) { |
| 1824 |
$output.= $num_slot . " slots OK, "; |
| 1825 |
} else { |
| 1826 |
$output.= $num_slot_ok . "/" . $num_slot ." slots OK, "; |
| 1827 |
} |
| 1828 |
} |
| 1829 |
|
| 1830 |
if ($num_ps != 0) { |
| 1831 |
if ($num_ps == $num_ps_ok) { |
| 1832 |
$output.= $num_ps . " power-supply OK, "; |
| 1833 |
} else { |
| 1834 |
$output.= $num_ps_ok . "/" . $num_ps ." power-supply OK, "; |
| 1835 |
} |
| 1836 |
} |
| 1837 |
|
| 1838 |
if ($num_fan != 0) { |
| 1839 |
if ($num_fan == $num_fan_ok) { |
| 1840 |
$output.= $num_fan . " fans OK, "; |
| 1841 |
} else { |
| 1842 |
$output.= $num_fan_ok . "/" . $num_fan ." fans OK, "; |
| 1843 |
} |
| 1844 |
} |
| 1845 |
|
| 1846 |
$output.= $temperature_output; |
| 1847 |
|
| 1848 |
if ($final_status == 3) { |
| 1849 |
print $output," : UNKNOWN\n"; |
| 1850 |
exit $ERRORS{"UNKNOWN"}; |
| 1851 |
} |
| 1852 |
|
| 1853 |
if ($final_status == 2) { |
| 1854 |
print $output," : CRITICAL\n"; |
| 1855 |
exit $ERRORS{"CRITICAL"}; |
| 1856 |
} |
| 1857 |
|
| 1858 |
if ($final_status == 1) { |
| 1859 |
print $output," : WARNING\n"; |
| 1860 |
exit $ERRORS{"WARNING"}; |
| 1861 |
} |
| 1862 |
|
| 1863 |
print $output," : OK\n"; |
| 1864 |
exit $ERRORS{"OK"}; |
| 1865 |
} |
| 1866 |
|
| 1867 |
|
| 1868 |
# ============================================================================ |
| 1869 |
# ============================== HP PROCURVE ================================= |
| 1870 |
# ============================================================================ |
| 1871 |
|
| 1872 |
if ($o_check_type eq "procurve") { |
| 1873 |
|
| 1874 |
verb("Checking procurve env"); |
| 1875 |
|
| 1876 |
# Define variables |
| 1877 |
my $output = ""; |
| 1878 |
my $final_status = 0; |
| 1879 |
my $power_output = ""; |
| 1880 |
my $fan_output = ""; |
| 1881 |
my $temp_output = ""; |
| 1882 |
my $tmp_status; |
| 1883 |
my $index; |
| 1884 |
my @temp_oid; |
| 1885 |
my ($num_power,$num_power_ok,$num_fan,$num_fan_ok,$num_temp,$num_temp_ok)=(0,0,0,0,0,0); |
| 1886 |
|
| 1887 |
# Get SNMP table(s) and check the result |
| 1888 |
my $resultat_state = $session->get_table(Baseoid => $procurve_operating_state); |
| 1889 |
&check_snmp_result($resultat_state,$session->error); |
| 1890 |
my $resultat_descr = $session->get_table(Baseoid => $procurve_operating_descr); |
| 1891 |
&check_snmp_result($resultat_descr,$session->error); |
| 1892 |
|
| 1893 |
if (defined($resultat_state)) { |
| 1894 |
foreach my $key ( keys %$resultat_state) { |
| 1895 |
if ($key =~ /$procurve_operating_state/) { |
| 1896 |
|
| 1897 |
$tmp_status=$procurve_operating_status[$$resultat_state{$key}]; |
| 1898 |
|
| 1899 |
$index = $key; |
| 1900 |
$index =~ s/^$procurve_operating_state.//; |
| 1901 |
|
| 1902 |
my $description = $$resultat_descr{$procurve_operating_descr.".".$index}; |
| 1903 |
|
| 1904 |
if ($description =~ /Power/ ) {$num_power++;} |
| 1905 |
if ($description =~ /Fan/ ) {$num_fan++;} |
| 1906 |
if ($description =~ /temperature/ ) {$num_temp++;} |
| 1907 |
|
| 1908 |
if ($description =~ /Power/ && $tmp_status == 0) {$num_power_ok++;} |
| 1909 |
if ($description =~ /Fan/ && $tmp_status == 0) {$num_fan_ok++;} |
| 1910 |
if ($description =~ /temperature/ && $tmp_status == 0) {$num_temp_ok++;} |
| 1911 |
|
| 1912 |
if ($tmp_status != 0) { |
| 1913 |
if ($description =~ /Power/ && $tmp_status == 4) {$num_power--;} |
| 1914 |
if ($description =~ /Fan/ && $tmp_status == 4) {$num_fan--;} |
| 1915 |
if ($description =~ /temperature/ && $tmp_status == 4) {$num_temp--;} |
| 1916 |
|
| 1917 |
if ($tmp_status != 4) { |
| 1918 |
if ($tmp_status == 1 && $final_status != 2) {$final_status=$tmp_status;} |
| 1919 |
if ($tmp_status == 2) {$final_status=$tmp_status;} |
| 1920 |
if ($tmp_status == 3 && $final_status == 0) {$final_status=$tmp_status;} |
| 1921 |
|
| 1922 |
if ($description =~ /Power/ ) { |
| 1923 |
if (!defined($description)) {$power_output.="Invalid power(UNKNOWN)";} |
| 1924 |
else { |
| 1925 |
if ($power_output ne "") {$power_output.=", ";} |
| 1926 |
$power_output.= "(".$description."): "; |
| 1927 |
$power_output.= "status " . $procurve_operating_status_text[$$resultat_state{$key}]; |
| 1928 |
} |
| 1929 |
} |
| 1930 |
|
| 1931 |
if ($description =~ /Fan/ ) { |
| 1932 |
if (!defined($description)) {$fan_output.="Invalid fan(UNKNOWN)";} |
| 1933 |
else { |
| 1934 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 1935 |
$fan_output.= "(".$description."): "; |
| 1936 |
$fan_output.= "status " . $procurve_operating_status_text[$$resultat_state{$key}]; |
| 1937 |
} |
| 1938 |
} |
| 1939 |
|
| 1940 |
if ($description =~ /temperature/ ) { |
| 1941 |
if (!defined($description)) {$power_output.="Invalid temp(UNKNOWN)";} |
| 1942 |
else { |
| 1943 |
if ($temp_output ne "") {$temp_output.=", ";} |
| 1944 |
$temp_output.= "(".$description."): "; |
| 1945 |
$temp_output.= "status " . $procurve_operating_status_text[$$resultat_state{$key}]; |
| 1946 |
} |
| 1947 |
} |
| 1948 |
} |
| 1949 |
} |
| 1950 |
} |
| 1951 |
} |
| 1952 |
if ($power_output ne "") {$power_output.=", ";} |
| 1953 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 1954 |
if ($temp_output ne "") {$temp_output.=", ";} |
| 1955 |
} |
| 1956 |
|
| 1957 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 1958 |
$session->close; |
| 1959 |
|
| 1960 |
if ($num_power==0 && $num_fan==0 && $num_temp==0) { |
| 1961 |
print "No power/fan/temp found : UNKNOWN\n"; |
| 1962 |
exit $ERRORS{"UNKNOWN"}; |
| 1963 |
} |
| 1964 |
|
| 1965 |
$output=$power_output . $fan_output . $temp_output; |
| 1966 |
if ($output ne "") {$output.=" : ";} |
| 1967 |
|
| 1968 |
if ($num_power!=0) { |
| 1969 |
if ($num_power == $num_power_ok) { |
| 1970 |
$output.= $num_power . " power OK, "; |
| 1971 |
} else { |
| 1972 |
$output.= $num_power_ok . "/" . $num_power ." power OK, "; |
| 1973 |
} |
| 1974 |
} |
| 1975 |
|
| 1976 |
if ($num_fan!=0) { |
| 1977 |
if ($num_fan == $num_fan_ok) { |
| 1978 |
$output.= $num_fan . " fan OK, "; |
| 1979 |
} else { |
| 1980 |
$output.= $num_fan_ok . "/" . $num_fan ." fan OK, "; |
| 1981 |
} |
| 1982 |
} |
| 1983 |
|
| 1984 |
if ($num_temp!=0) { |
| 1985 |
if ($num_temp == $num_temp_ok) { |
| 1986 |
$output.= $num_temp . " temp OK"; |
| 1987 |
} else { |
| 1988 |
$output.= $num_temp_ok . "/" . $num_temp ." temp OK"; |
| 1989 |
} |
| 1990 |
} |
| 1991 |
|
| 1992 |
if ($final_status == 3) { |
| 1993 |
print $output," : UNKNOWN\n"; |
| 1994 |
exit $ERRORS{"UNKNOWN"}; |
| 1995 |
} |
| 1996 |
|
| 1997 |
if ($final_status == 2) { |
| 1998 |
print $output," : CRITICAL\n"; |
| 1999 |
exit $ERRORS{"CRITICAL"}; |
| 2000 |
} |
| 2001 |
|
| 2002 |
if ($final_status == 1) { |
| 2003 |
print $output," : WARNING\n"; |
| 2004 |
exit $ERRORS{"WARNING"}; |
| 2005 |
} |
| 2006 |
|
| 2007 |
print $output," : OK\n"; |
| 2008 |
exit $ERRORS{"OK"}; |
| 2009 |
} |
| 2010 |
|
| 2011 |
|
| 2012 |
# ============================================================================ |
| 2013 |
# ============================== NETSCREEN =================================== |
| 2014 |
# ============================================================================ |
| 2015 |
|
| 2016 |
if ($o_check_type eq "netscreen") { |
| 2017 |
|
| 2018 |
verb("Checking netscreen env"); |
| 2019 |
|
| 2020 |
# Define variables |
| 2021 |
my $output = ""; |
| 2022 |
my $final_status = 0; |
| 2023 |
my $slot_output = ""; |
| 2024 |
my $power_output = ""; |
| 2025 |
my $fan_output = ""; |
| 2026 |
my $tmp_status; |
| 2027 |
my $result_t; |
| 2028 |
my $index; |
| 2029 |
my @temp_oid; |
| 2030 |
my ($num_slot,$num_slot_ok,$num_power,$num_power_ok,$num_fan,$num_fan_ok)=(0,0,0,0,0,0); |
| 2031 |
|
| 2032 |
# Get SNMP table(s) and check the result |
| 2033 |
my $resultat_s = $session->get_table(Baseoid => $netscreen_slot_operating_state); |
| 2034 |
&check_snmp_result($resultat_s,$session->error); |
| 2035 |
my $resultat_p = $session->get_table(Baseoid => $netscreen_power_operating_state); |
| 2036 |
&check_snmp_result($resultat_p,$session->error); |
| 2037 |
my $resultat_f = $session->get_table(Baseoid => $netscreen_fan_operating_state); |
| 2038 |
&check_snmp_result($resultat_f,$session->error); |
| 2039 |
|
| 2040 |
# Check if the ScreenOS version is not below 6.1 or 5GT, these are not supported |
| 2041 |
my @netscreen_os_oid = ($sysdescr); |
| 2042 |
my $netscreen_version = $session->get_request(Varbindlist => \@netscreen_os_oid); |
| 2043 |
if( ($$netscreen_version{$sysdescr} !~ /version 6.[1-9]/) || ($$netscreen_version{$sysdescr} =~ /5GT/) ) |
| 2044 |
{ |
| 2045 |
print "Not checked, ScreenOS version below 6.1 and/or 5GT: OK\n"; |
| 2046 |
exit $ERRORS{"OK"}; |
| 2047 |
} |
| 2048 |
|
| 2049 |
# Check slots |
| 2050 |
if (defined($resultat_s)) { |
| 2051 |
foreach my $key ( keys %$resultat_s) { |
| 2052 |
if ($key =~ /$netscreen_slot_operating_state/) { |
| 2053 |
$num_slot++; |
| 2054 |
$tmp_status = $netscreen_slot_operating_status[$$resultat_s{$key}]; |
| 2055 |
$final_status = &set_status($tmp_status,$final_status); |
| 2056 |
|
| 2057 |
if ($tmp_status == 0) { |
| 2058 |
$num_slot_ok++; |
| 2059 |
} else { |
| 2060 |
$index = $key; |
| 2061 |
$index =~ s/^$netscreen_slot_operating_state.//; |
| 2062 |
@temp_oid=($netscreen_slot_operating_descr.".".$index); |
| 2063 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2064 |
|
| 2065 |
if (!defined($result_t)) {$slot_output.="Invalid slot(UNKNOWN)";} |
| 2066 |
|
| 2067 |
else { |
| 2068 |
if ($slot_output ne "") {$slot_output.=", ";} |
| 2069 |
$slot_output.= "(" .$$result_t{$netscreen_slot_operating_descr.".".$index} ."): "; |
| 2070 |
$slot_output.= "status " . $netscreen_slot_operating_status_text[$$resultat_s{$key}]; |
| 2071 |
} |
| 2072 |
} |
| 2073 |
} |
| 2074 |
} |
| 2075 |
if ($slot_output ne "") {$slot_output.=", ";} |
| 2076 |
} |
| 2077 |
|
| 2078 |
# Check power |
| 2079 |
if (defined($resultat_p)) { |
| 2080 |
foreach my $key ( keys %$resultat_p) { |
| 2081 |
if ($key =~ /$netscreen_power_operating_state/) { |
| 2082 |
$num_power++; |
| 2083 |
$tmp_status = $netscreen_power_operating_status[$$resultat_p{$key}]; |
| 2084 |
$final_status = &set_status($tmp_status,$final_status); |
| 2085 |
|
| 2086 |
if ($tmp_status == 0) { |
| 2087 |
$num_power_ok++; |
| 2088 |
} else { |
| 2089 |
$index = $key; |
| 2090 |
$index =~ s/^$netscreen_power_operating_state.//; |
| 2091 |
@temp_oid=($netscreen_power_operating_descr.".".$index); |
| 2092 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2093 |
|
| 2094 |
if (!defined($result_t)) {$slot_output.="Invalid power(UNKNOWN)";} |
| 2095 |
|
| 2096 |
else { |
| 2097 |
if ($power_output ne "") {$power_output.=", ";} |
| 2098 |
$power_output.= "(" .$$result_t{$netscreen_power_operating_descr.".".$index} ."): "; |
| 2099 |
$power_output.= "status " . $netscreen_power_operating_status_text[$$resultat_p{$key}]; |
| 2100 |
} |
| 2101 |
} |
| 2102 |
} |
| 2103 |
} |
| 2104 |
if ($power_output ne "") {$power_output.=", ";} |
| 2105 |
} |
| 2106 |
|
| 2107 |
# Check fans |
| 2108 |
if (defined($resultat_f)) { |
| 2109 |
foreach my $key ( keys %$resultat_f) { |
| 2110 |
if ($key =~ /$netscreen_fan_operating_state/) { |
| 2111 |
$num_fan++; |
| 2112 |
$tmp_status = $netscreen_fan_operating_status[$$resultat_f{$key}]; |
| 2113 |
$final_status = &set_status($tmp_status,$final_status); |
| 2114 |
if ($tmp_status == 0) { |
| 2115 |
$num_fan_ok++; |
| 2116 |
} else { |
| 2117 |
if($tmp_status == 4) { |
| 2118 |
$num_fan--; |
| 2119 |
} else { |
| 2120 |
$index = $key; |
| 2121 |
$index =~ s/^$netscreen_fan_operating_state.//; |
| 2122 |
@temp_oid=($netscreen_fan_operating_descr.".".$index); |
| 2123 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2124 |
|
| 2125 |
if (!defined($result_t)) {$fan_output.="Invalid fan(UNKNOWN)";} |
| 2126 |
|
| 2127 |
else { |
| 2128 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 2129 |
$fan_output.= "(" .$$result_t{$netscreen_fan_operating_descr.".".$index} ."): "; |
| 2130 |
$fan_output.= "status " . $netscreen_fan_operating_status_text[$$resultat_f{$key}]; |
| 2131 |
} |
| 2132 |
} |
| 2133 |
} |
| 2134 |
} |
| 2135 |
} |
| 2136 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 2137 |
} |
| 2138 |
|
| 2139 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 2140 |
$session->close; |
| 2141 |
|
| 2142 |
if ($num_slot==0 && $num_power==0 && $num_fan==0) { |
| 2143 |
print "No slot/power/fan found : UNKNOWN\n"; |
| 2144 |
exit $ERRORS{"UNKNOWN"}; |
| 2145 |
} |
| 2146 |
|
| 2147 |
$output=$slot_output . $power_output . $fan_output; |
| 2148 |
if ($output ne "") {$output.=" : ";} |
| 2149 |
|
| 2150 |
if ($num_slot!=0) { |
| 2151 |
if ($num_slot == $num_slot_ok) { |
| 2152 |
$output.= $num_slot . " slots OK, "; |
| 2153 |
} else { |
| 2154 |
$output.= $num_slot_ok . "/" . $num_slot ." slots OK, "; |
| 2155 |
} |
| 2156 |
} |
| 2157 |
|
| 2158 |
if ($num_power!=0) { |
| 2159 |
if ($num_power == $num_power_ok) { |
| 2160 |
$output.= $num_power . " power OK, "; |
| 2161 |
} else { |
| 2162 |
$output.= $num_power_ok . "/" . $num_power ." power OK "; |
| 2163 |
} |
| 2164 |
} |
| 2165 |
|
| 2166 |
if ($num_fan!=0) { |
| 2167 |
if ($num_fan == $num_fan_ok) { |
| 2168 |
$output.= $num_fan . " fans OK"; |
| 2169 |
} else { |
| 2170 |
$output.= $num_fan_ok . "/" . $num_fan ." fans OK"; |
| 2171 |
} |
| 2172 |
} |
| 2173 |
|
| 2174 |
if ($final_status == 3) { |
| 2175 |
print $output," : UNKNOWN\n"; |
| 2176 |
exit $ERRORS{"UNKNOWN"}; |
| 2177 |
} |
| 2178 |
|
| 2179 |
if ($final_status == 2) { |
| 2180 |
print $output," : CRITICAL\n"; |
| 2181 |
exit $ERRORS{"CRITICAL"}; |
| 2182 |
} |
| 2183 |
|
| 2184 |
if ($final_status == 1) { |
| 2185 |
print $output," : WARNING\n"; |
| 2186 |
exit $ERRORS{"WARNING"}; |
| 2187 |
} |
| 2188 |
|
| 2189 |
print $output," : OK\n"; |
| 2190 |
exit $ERRORS{"OK"}; |
| 2191 |
} |
| 2192 |
|
| 2193 |
|
| 2194 |
# ============================================================================ |
| 2195 |
# ============================== CISCO (CISCO-ENTITY-SENSOR-MIB) ============= |
| 2196 |
# ============================================================================ |
| 2197 |
|
| 2198 |
if ($o_check_type eq "ciscoNEW") { |
| 2199 |
|
| 2200 |
verb("Checking Cisco CISCO-ENTITY-SENSOR-MIB env"); |
| 2201 |
|
| 2202 |
# Define variables |
| 2203 |
my $output = ""; |
| 2204 |
my $final_status = 0; |
| 2205 |
my $sensor_output = ""; |
| 2206 |
my $tmp_status; |
| 2207 |
my $result_t; |
| 2208 |
my $index; |
| 2209 |
my @temp_oid; |
| 2210 |
my ($num_sensors,$num_sensors_ok,$num_thresholds,$num_thresholds_ok) = (0,0,0,0); |
| 2211 |
|
| 2212 |
# Get SNMP table(s) and check the result |
| 2213 |
my $resultat_status = $session->get_table(Baseoid => $cisco_ios_xe_status); |
| 2214 |
&check_snmp_result($resultat_status,$session->error); |
| 2215 |
my $resultat_type = $session->get_table(Baseoid => $cisco_ios_xe_type); |
| 2216 |
&check_snmp_result($resultat_type,$session->error); |
| 2217 |
my $resultat_precision = $session->get_table(Baseoid => $cisco_ios_xe_precision); |
| 2218 |
&check_snmp_result($resultat_precision,$session->error); |
| 2219 |
my $resultat_value = $session->get_table(Baseoid => $cisco_ios_xe_value); |
| 2220 |
&check_snmp_result($resultat_value,$session->error); |
| 2221 |
my $resultat_threshold_value = $session->get_table(Baseoid => $cisco_ios_xe_threshold_value); |
| 2222 |
&check_snmp_result($resultat_threshold_value,$session->error); |
| 2223 |
my $resultat_threshold_severity = $session->get_table(Baseoid => $cisco_ios_xe_threshold_severity); |
| 2224 |
&check_snmp_result($resultat_threshold_severity,$session->error); |
| 2225 |
|
| 2226 |
if (defined($resultat_status)) { |
| 2227 |
foreach my $key ( keys %$resultat_status) { |
| 2228 |
if ($key =~ /$cisco_ios_xe_status/) { |
| 2229 |
$num_sensors++; |
| 2230 |
|
| 2231 |
$tmp_status=$cisco_ios_xe_operating_status[$$resultat_status{$key}]; |
| 2232 |
|
| 2233 |
$index = $key; |
| 2234 |
$index =~ s/^$cisco_ios_xe_status.//; |
| 2235 |
|
| 2236 |
if ($tmp_status == 1) { |
| 2237 |
$num_sensors_ok++; |
| 2238 |
|
| 2239 |
# Get sensor TYPE |
| 2240 |
my $CiscoType = $$resultat_type{$cisco_ios_xe_type.".".$index}; |
| 2241 |
|
| 2242 |
if ($CiscoType == 8) { |
| 2243 |
|
| 2244 |
# Get sensor PRECISION |
| 2245 |
my $CiscoPrecision = $$resultat_precision{$cisco_ios_xe_precision.".".$index}; |
| 2246 |
|
| 2247 |
if ($CiscoPrecision == 0){ |
| 2248 |
|
| 2249 |
# Get sensor THRESHOLD VALUE 1 |
| 2250 |
my $CiscoThreshold_value1 = $$resultat_threshold_value{$cisco_ios_xe_threshold_value.".".$index.".1"}; |
| 2251 |
|
| 2252 |
if (defined($CiscoThreshold_value1)){ |
| 2253 |
|
| 2254 |
# Get sensor VALUE |
| 2255 |
my $CiscoValue = $$resultat_value{$cisco_ios_xe_value.".".$index}; |
| 2256 |
|
| 2257 |
# Get sensor THRESHOLD SEVERITY 2 |
| 2258 |
my $CiscoThreshold_severity2 = $$resultat_threshold_severity{$cisco_ios_xe_threshold_severity.".".$index.".2"}; |
| 2259 |
|
| 2260 |
if ($CiscoThreshold_severity2 ne "noSuchInstance") { |
| 2261 |
$num_thresholds++; |
| 2262 |
|
| 2263 |
if (($CiscoValue < $CiscoThreshold_value1) || ($CiscoThreshold_severity2 == 10)){ |
| 2264 |
$num_thresholds_ok++; |
| 2265 |
} else { |
| 2266 |
$final_status=2; |
| 2267 |
|
| 2268 |
# Get sensor DESCRIPTION |
| 2269 |
@temp_oid=($cisco_ios_xe_physicaldescr.".".$index); |
| 2270 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2271 |
|
| 2272 |
if ($output ne "") {$output.=", ";} |
| 2273 |
$output.= "(" .$$result_t{$cisco_ios_xe_physicaldescr.".".$index}.": ".$CiscoValue." Celsius)"; |
| 2274 |
} |
| 2275 |
} |
| 2276 |
} |
| 2277 |
} |
| 2278 |
} |
| 2279 |
|
| 2280 |
} else { |
| 2281 |
$final_status=2; |
| 2282 |
|
| 2283 |
# Get sensor DESCRIPTION |
| 2284 |
@temp_oid=($cisco_ios_xe_physicaldescr.".".$index); |
| 2285 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2286 |
|
| 2287 |
if ($tmp_status == 2){ |
| 2288 |
if ($output ne "") {$output.=", ";} |
| 2289 |
$output.= "(" .$$result_t{$cisco_ios_xe_physicaldescr.".".$index}.": sensor unavailable)"; |
| 2290 |
} |
| 2291 |
if ($tmp_status == 3){ |
| 2292 |
if ($output ne "") {$output.=", ";} |
| 2293 |
$output.= "(" .$$result_t{$cisco_ios_xe_physicaldescr.".".$index}.": sensor nonoperational)"; |
| 2294 |
} |
| 2295 |
} |
| 2296 |
} |
| 2297 |
} |
| 2298 |
} |
| 2299 |
|
| 2300 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 2301 |
$session->close; |
| 2302 |
|
| 2303 |
if ($num_sensors==0) { |
| 2304 |
print "No components found : UNKNOWN\n"; |
| 2305 |
exit $ERRORS{"UNKNOWN"}; |
| 2306 |
} |
| 2307 |
|
| 2308 |
if ($output ne "") {$output.=" : ";} |
| 2309 |
if ($num_sensors!=0) { |
| 2310 |
if (($num_sensors == $num_sensors_ok) && ($num_thresholds == $num_thresholds_ok)){ |
| 2311 |
$output.= $num_sensors . " sensors reported OK (".$num_thresholds." thresholds reported OK)"; |
| 2312 |
} else { |
| 2313 |
$output.= $num_sensors_ok . "/" . $num_sensors ." sensors reported OK (".$num_thresholds." sensors using thresholds)"; |
| 2314 |
} |
| 2315 |
} |
| 2316 |
|
| 2317 |
if ($final_status == 3) { |
| 2318 |
print $output," : UNKNOWN\n"; |
| 2319 |
exit $ERRORS{"UNKNOWN"}; |
| 2320 |
} |
| 2321 |
|
| 2322 |
if ($final_status == 2) { |
| 2323 |
print $output," : CRITICAL\n"; |
| 2324 |
exit $ERRORS{"CRITICAL"}; |
| 2325 |
} |
| 2326 |
|
| 2327 |
if ($final_status == 1) { |
| 2328 |
print $output," : WARNING\n"; |
| 2329 |
exit $ERRORS{"WARNING"}; |
| 2330 |
} |
| 2331 |
|
| 2332 |
print $output," : OK\n"; |
| 2333 |
exit $ERRORS{"OK"}; |
| 2334 |
} |
| 2335 |
|
| 2336 |
|
| 2337 |
# ============================================================================ |
| 2338 |
# ============================== CITRIX NETSCALER ============================ |
| 2339 |
# ============================================================================ |
| 2340 |
|
| 2341 |
if ($o_check_type eq "citrix") { |
| 2342 |
|
| 2343 |
verb("Checking citrix"); |
| 2344 |
|
| 2345 |
# Define variables |
| 2346 |
my $output = ""; |
| 2347 |
my $final_status = 0; |
| 2348 |
my $voltage_output = ""; |
| 2349 |
my $powersupply_output = ""; |
| 2350 |
my $fan_output = ""; |
| 2351 |
my $temp_output = ""; |
| 2352 |
my $ha_state_output = ""; |
| 2353 |
my $ssl_engine_output = ""; |
| 2354 |
my $ha_state_and_ssl_engine = ""; |
| 2355 |
my $result_t; |
| 2356 |
my $index; |
| 2357 |
my @temp_oid; |
| 2358 |
my $using_voltage_threshold; |
| 2359 |
my ($num_voltage,$num_voltage_ok,$num_powersupply,$num_powersupply_ok,$num_fan,$num_fan_ok,$num_temp,$num_temp_ok)=(0,0,0,0,0,0); |
| 2360 |
|
| 2361 |
# Get SNMP table(s) and check the result |
| 2362 |
my $resultat_status = $session->get_table(Baseoid => $citrix_desc); |
| 2363 |
&check_snmp_result($resultat_status,$session->error); |
| 2364 |
my $resultat_value = $session->get_table(Baseoid => $citrix_value); |
| 2365 |
&check_snmp_result($resultat_value,$session->error); |
| 2366 |
|
| 2367 |
if (defined($resultat_status)) { |
| 2368 |
foreach my $key ( keys %$resultat_status) { |
| 2369 |
if ($key =~ /$citrix_desc/) { |
| 2370 |
my $reported_counter_name = $$resultat_status{$key}; |
| 2371 |
$using_voltage_threshold = 0; |
| 2372 |
|
| 2373 |
$index = $key; |
| 2374 |
$index =~ s/^$citrix_desc.//; |
| 2375 |
|
| 2376 |
my $reported_counter_value = $$resultat_value{$citrix_value.".".$index}; |
| 2377 |
|
| 2378 |
# Thresholds are hardcoded and are based on the "Citrix NetScaler SNMP OID Reference - Release 9.2" document. |
| 2379 |
# If a threshold for a specific component is not available in this document then a logical threshold has been picked. |
| 2380 |
|
| 2381 |
if ($reported_counter_name =~ /Voltage/ ) { |
| 2382 |
$num_voltage++; my $ha_state_and_ssl_engine =""; |
| 2383 |
|
| 2384 |
# Measures the +5V power supply in millivolt |
| 2385 |
if ($reported_counter_name =~ /\+5.0VSupplyVoltage/ ){ |
| 2386 |
$using_voltage_threshold = 1; |
| 2387 |
if (($reported_counter_value > 4500 ) && ($reported_counter_value < 5500)) { |
| 2388 |
$num_voltage_ok++; |
| 2389 |
} else { |
| 2390 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2391 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2392 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2393 |
$final_status = 2; |
| 2394 |
} |
| 2395 |
} |
| 2396 |
|
| 2397 |
# Measures the +12V power supply in millivolt |
| 2398 |
if ($reported_counter_name =~ /\+12.0VSupplyVoltage/ ){ |
| 2399 |
$using_voltage_threshold = 1; |
| 2400 |
if (($reported_counter_value > 10800 ) && ($reported_counter_value < 13200)) { |
| 2401 |
$num_voltage_ok++; |
| 2402 |
} else { |
| 2403 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2404 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2405 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2406 |
$final_status = 2; |
| 2407 |
} |
| 2408 |
} |
| 2409 |
|
| 2410 |
# Measures the -5V power supply in millivolt |
| 2411 |
if ($reported_counter_name =~ /\-5.0VSupplyVoltage/ ){ |
| 2412 |
$using_voltage_threshold = 1; |
| 2413 |
if (($reported_counter_value > -5500 ) && ($reported_counter_value < -4500)) { |
| 2414 |
$num_voltage_ok++; |
| 2415 |
} else { |
| 2416 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2417 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2418 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2419 |
$final_status = 2; |
| 2420 |
} |
| 2421 |
} |
| 2422 |
|
| 2423 |
# Measures the -12V power supply in millivolt |
| 2424 |
if ($reported_counter_name =~ /\-12.0VSupplyVoltage/ ){ |
| 2425 |
$using_voltage_threshold = 1; |
| 2426 |
if (($reported_counter_value > -13200 ) && ($reported_counter_value < -10800)) { |
| 2427 |
$num_voltage_ok++; |
| 2428 |
} else { |
| 2429 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2430 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2431 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2432 |
$final_status = 2; |
| 2433 |
} |
| 2434 |
} |
| 2435 |
|
| 2436 |
# Measures the +3.3V main and standby power supply in millivolt |
| 2437 |
if ($reported_counter_name =~ /3.3VSupplyVoltage/ ){ |
| 2438 |
$using_voltage_threshold = 1; |
| 2439 |
if (($reported_counter_value > 2970 ) && ($reported_counter_value < 3630)) { |
| 2440 |
$num_voltage_ok++; |
| 2441 |
} else { |
| 2442 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2443 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2444 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2445 |
$final_status = 2; |
| 2446 |
} |
| 2447 |
|
| 2448 |
|
| 2449 |
} |
| 2450 |
|
| 2451 |
# Measures the +5V standby power supply in millivolt |
| 2452 |
if ($reported_counter_name =~ /PowerSupply5vStandbyVoltage/ ){ |
| 2453 |
$using_voltage_threshold = 1; |
| 2454 |
if (($reported_counter_value > 4500 ) && ($reported_counter_value < 5500)) { |
| 2455 |
$num_voltage_ok++; |
| 2456 |
} else { |
| 2457 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2458 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2459 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2460 |
$final_status = 2; |
| 2461 |
} |
| 2462 |
} |
| 2463 |
|
| 2464 |
# Measures the processor core voltage in millivolt |
| 2465 |
if ($reported_counter_name =~ /CPU0CoreVoltage|CPU1CoreVoltage/ ){ |
| 2466 |
$using_voltage_threshold = 1; |
| 2467 |
if (($reported_counter_value > 1080 ) && ($reported_counter_value < 1650)) { |
| 2468 |
$num_voltage_ok++; |
| 2469 |
} else { |
| 2470 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2471 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2472 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2473 |
$final_status = 2; |
| 2474 |
} |
| 2475 |
} |
| 2476 |
|
| 2477 |
# If no defined voltage description is found, uses the following thresholds |
| 2478 |
if ($using_voltage_threshold == 0){ |
| 2479 |
if (($reported_counter_value > 1000 ) && ($reported_counter_value < 6000)){ |
| 2480 |
$num_voltage_ok++; |
| 2481 |
} else { |
| 2482 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2483 |
$voltage_output.= "(" .$reported_counter_name.": "; |
| 2484 |
$voltage_output.= $reported_counter_value." mV)"; |
| 2485 |
$final_status = 2; |
| 2486 |
} |
| 2487 |
} |
| 2488 |
} |
| 2489 |
|
| 2490 |
# Power Supply check. No documentation available about possible values. "3" appears to be "OK", so anything other then that will be reported |
| 2491 |
if ($reported_counter_name =~ /PowerSupply1FailureStatus|PowerSupply2FailureStatus/ ) { |
| 2492 |
$num_powersupply++; |
| 2493 |
if ($reported_counter_value == 3 ){ |
| 2494 |
$num_powersupply_ok++; |
| 2495 |
} else { |
| 2496 |
if ($powersupply_output ne "") {$powersupply_output.=", ";} |
| 2497 |
$powersupply_output.= "(" .$reported_counter_name.": "; |
| 2498 |
$powersupply_output.= $reported_counter_value." Failure)"; |
| 2499 |
$final_status = 2; |
| 2500 |
} |
| 2501 |
} |
| 2502 |
|
| 2503 |
# Fan speed threshold in RPM. Documentation is not clear about the thresholds |
| 2504 |
if ($reported_counter_name =~ /Fan/ ) { |
| 2505 |
$num_fan++; |
| 2506 |
if (($reported_counter_value > 5000 ) && ($reported_counter_value < 15000)){ |
| 2507 |
$num_fan_ok++; |
| 2508 |
} else { |
| 2509 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 2510 |
$fan_output.= "(" .$reported_counter_name.": "; |
| 2511 |
$fan_output.= $reported_counter_value." RPM)"; |
| 2512 |
$final_status = 2; |
| 2513 |
} |
| 2514 |
} |
| 2515 |
|
| 2516 |
# It looks like Citrix NetScaler devices are based on Intel XEON processors. Most of them appear to have a maximum operation temperature of 75 degrees Celsius. |
| 2517 |
if ($reported_counter_name =~ /CPU0Temperature|CPU1Temperature/ ) { |
| 2518 |
$num_temp++; |
| 2519 |
if (($reported_counter_value > 50 ) && ($reported_counter_value < 72)){ |
| 2520 |
$num_temp_ok++; |
| 2521 |
} else { |
| 2522 |
if ($temp_output ne "") {$temp_output.=", ";} |
| 2523 |
$temp_output.= "(" .$reported_counter_name.": "; |
| 2524 |
$temp_output.= $reported_counter_value." Celsius)"; |
| 2525 |
$final_status = 2; |
| 2526 |
} |
| 2527 |
} |
| 2528 |
|
| 2529 |
# Internal temperature in degrees Celsius. No defined threshold in documentation. |
| 2530 |
if ($reported_counter_name =~ /InternalTemperature/ ) { |
| 2531 |
$num_temp++; |
| 2532 |
if (($reported_counter_value > 20 ) && ($reported_counter_value < 40)){ |
| 2533 |
$num_temp_ok++; |
| 2534 |
} else { |
| 2535 |
if ($temp_output ne "") {$temp_output.=", ";} |
| 2536 |
$temp_output.= "(" .$reported_counter_name.": "; |
| 2537 |
$temp_output.= $reported_counter_value." Celsius)"; |
| 2538 |
$final_status = 2; |
| 2539 |
} |
| 2540 |
} |
| 2541 |
} |
| 2542 |
} |
| 2543 |
|
| 2544 |
# Get High Availability State |
| 2545 |
@temp_oid=($citrix_high_availability_state); |
| 2546 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2547 |
my $ha_cur_state = $$result_t{$citrix_high_availability_state}; |
| 2548 |
if (defined($ha_cur_state)){ |
| 2549 |
$ha_state_output.= "HA State " . $citrix_high_availability_state_text[$ha_cur_state]; |
| 2550 |
if ($ha_cur_state != 3){ |
| 2551 |
$final_status = 2; |
| 2552 |
} |
| 2553 |
} |
| 2554 |
|
| 2555 |
# Get High Availability State |
| 2556 |
@temp_oid=($citrix_ssl_engine_state); |
| 2557 |
$result_t = $session->get_request( Varbindlist => \@temp_oid); |
| 2558 |
my $ssl_engine_state = $$result_t{$citrix_ssl_engine_state}; |
| 2559 |
if (defined($ssl_engine_state)){ |
| 2560 |
$ssl_engine_output.= "SSL Engine " . $citrix_ssl_engine_state_text[$ssl_engine_state]; |
| 2561 |
if ($ssl_engine_state != 1){ |
| 2562 |
$final_status = 2; |
| 2563 |
} |
| 2564 |
} |
| 2565 |
|
| 2566 |
if ((defined($ha_cur_state)) && (defined($ssl_engine_state))){$ha_state_and_ssl_engine = " (".$ha_state_output.", ".$ssl_engine_output.")"}; |
| 2567 |
if ((defined($ha_cur_state)) && (!defined($ssl_engine_state))){$ha_state_and_ssl_engine = " - (".$ha_state_output.")"}; |
| 2568 |
if ((!defined($ha_cur_state)) && (defined($ssl_engine_state))){$ha_state_and_ssl_engine = " - (".$ssl_engine_output.")"}; |
| 2569 |
|
| 2570 |
if ($voltage_output ne "") {$voltage_output.=", ";} |
| 2571 |
if ($powersupply_output ne "") {$powersupply_output.=", ";} |
| 2572 |
if ($fan_output ne "") {$fan_output.=", ";} |
| 2573 |
if ($temp_output ne "") {$temp_output.=", ";} |
| 2574 |
} |
| 2575 |
|
| 2576 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 2577 |
$session->close; |
| 2578 |
|
| 2579 |
if ($num_voltage==0 && $num_fan==0 && $num_temp==0) { |
| 2580 |
print "No power/fan/temp found : UNKNOWN\n"; |
| 2581 |
exit $ERRORS{"UNKNOWN"}; |
| 2582 |
} |
| 2583 |
|
| 2584 |
$output=$voltage_output . $fan_output . $temp_output ; |
| 2585 |
|
| 2586 |
if ($output ne "") {$output.=" : ";} |
| 2587 |
|
| 2588 |
if ($num_powersupply!=0) { |
| 2589 |
if ($num_powersupply == $num_powersupply_ok) { |
| 2590 |
$output.= $num_powersupply . " powersupply OK, "; |
| 2591 |
} else { |
| 2592 |
$output.= $num_powersupply_ok . "/" . $num_powersupply ." powersupply OK, "; |
| 2593 |
} |
| 2594 |
} |
| 2595 |
|
| 2596 |
if ($num_voltage!=0) { |
| 2597 |
if ($num_voltage == $num_voltage_ok) { |
| 2598 |
$output.= $num_voltage . " voltage OK, "; |
| 2599 |
} else { |
| 2600 |
$output.= $num_voltage_ok . "/" . $num_voltage ." voltage OK, "; |
| 2601 |
} |
| 2602 |
} |
| 2603 |
|
| 2604 |
if ($num_fan!=0) { |
| 2605 |
if ($num_fan == $num_fan_ok) { |
| 2606 |
$output.= $num_fan . " fan OK, "; |
| 2607 |
} else { |
| 2608 |
$output.= $num_fan_ok . "/" . $num_fan ." fan OK, "; |
| 2609 |
} |
| 2610 |
} |
| 2611 |
|
| 2612 |
if ($num_temp!=0) { |
| 2613 |
if ($num_temp == $num_temp_ok) { |
| 2614 |
$output.= $num_temp . " temp OK"; |
| 2615 |
} else { |
| 2616 |
$output.= $num_temp_ok . "/" . $num_temp ." temp OK"; |
| 2617 |
} |
| 2618 |
} |
| 2619 |
|
| 2620 |
|
| 2621 |
$output.= $ha_state_and_ssl_engine; |
| 2622 |
|
| 2623 |
|
| 2624 |
if ($final_status == 3) { |
| 2625 |
print $output," : UNKNOWN\n"; |
| 2626 |
exit $ERRORS{"UNKNOWN"}; |
| 2627 |
} |
| 2628 |
|
| 2629 |
if ($final_status == 2) { |
| 2630 |
print $output," : CRITICAL\n"; |
| 2631 |
exit $ERRORS{"CRITICAL"}; |
| 2632 |
} |
| 2633 |
|
| 2634 |
if ($final_status == 1) { |
| 2635 |
print $output," : WARNING\n"; |
| 2636 |
exit $ERRORS{"WARNING"}; |
| 2637 |
} |
| 2638 |
|
| 2639 |
print $output," : OK\n"; |
| 2640 |
exit $ERRORS{"OK"}; |
| 2641 |
|
| 2642 |
} |
| 2643 |
|
| 2644 |
|
| 2645 |
# ============================================================================ |
| 2646 |
# ============================== TRANSMODE =================================== |
| 2647 |
# ============================================================================ |
| 2648 |
|
| 2649 |
if ($o_check_type eq "transmode") { |
| 2650 |
|
| 2651 |
verb("Checking transmode env"); |
| 2652 |
|
| 2653 |
# Define variables |
| 2654 |
my $final_status = 0; |
| 2655 |
my $tmp_status = undef; |
| 2656 |
my $num_alarms = 0; |
| 2657 |
my $num_ignored = 0; |
| 2658 |
my $alarm_output = ""; |
| 2659 |
my $output = ""; |
| 2660 |
my ($alarm_serv,$alarm_serv_txt,$alarm_descr,$alarm_time_start,$alarm_time_end,$alarm_rack,$alarm_slot,$alarm_unit)=(undef,undef,undef,undef,undef,undef,undef,undef); |
| 2661 |
|
| 2662 |
# Get SNMP table(s) and check the result |
| 2663 |
my $resultat_c = $session->get_table(Baseoid => $transmode_table); |
| 2664 |
&check_snmp_result($resultat_c,$session->error); |
| 2665 |
|
| 2666 |
if (defined($resultat_c)) { |
| 2667 |
foreach my $key ( keys %$resultat_c) { |
| 2668 |
if ($key =~ /$transmode_alarm_sev/) { |
| 2669 |
$alarm_serv = $$resultat_c{$key}; |
| 2670 |
$key =~ s/$transmode_alarm_sev//; |
| 2671 |
|
| 2672 |
# Set the alarm variables |
| 2673 |
$alarm_descr = $$resultat_c{$transmode_alarm_descr.$key}; |
| 2674 |
$alarm_time_start = $$resultat_c{$transmode_alarm_time_start.$key}; |
| 2675 |
$alarm_time_end = $$resultat_c{$transmode_alarm_time_end.$key}; |
| 2676 |
$alarm_rack = $$resultat_c{$transmode_alarm_rack.$key}; |
| 2677 |
$alarm_slot = $$resultat_c{$transmode_alarm_slot.$key}; |
| 2678 |
$alarm_unit = $$resultat_c{$transmode_alarm_unit.$key}; |
| 2679 |
$alarm_serv_txt = $transmode_alarm_status_text[$alarm_serv]; |
| 2680 |
$tmp_status = $transmode_alarm_status[$alarm_serv]; |
| 2681 |
|
| 2682 |
# Ignore client related alarms or alarms that are deactivated |
| 2683 |
if (($alarm_descr =~ /client|Client/ ) || ($alarm_time_end =~ /[0-9]{4}[-][0-9]{2}[-][0-9]{2}/)) { |
| 2684 |
$num_ignored++; |
| 2685 |
} |
| 2686 |
|
| 2687 |
# Print reported alarms that are not ignored |
| 2688 |
else { |
| 2689 |
$final_status = &set_status($tmp_status,$final_status); |
| 2690 |
$num_alarms++; |
| 2691 |
$alarm_output .= "Rack:" . $alarm_rack; |
| 2692 |
$alarm_output .= " Slot:" . $alarm_slot; |
| 2693 |
$alarm_output .= " Unit:" . $alarm_unit; |
| 2694 |
$alarm_output .= " Desc:" . $alarm_descr; |
| 2695 |
$alarm_output .= " Time:" . $alarm_time_start; |
| 2696 |
$alarm_output .= " Sev:" . $alarm_serv_txt .","; |
| 2697 |
} |
| 2698 |
} |
| 2699 |
} |
| 2700 |
} |
| 2701 |
|
| 2702 |
# Clear the SNMP Transport Domain and any errors associated with the object. |
| 2703 |
$session->close; |
| 2704 |
|
| 2705 |
if ($num_alarms == 0) { |
| 2706 |
print "No alarms found : OK\n"; |
| 2707 |
exit $ERRORS{"OK"}; |
| 2708 |
} |
| 2709 |
|
| 2710 |
$output=$alarm_output; |
| 2711 |
|
| 2712 |
if ($output ne "") {$output.=" : ";} |
| 2713 |
|
| 2714 |
if ($num_alarms != 0) { |
| 2715 |
$output .= $num_alarms . " Active alarm(s) found, ".$num_ignored." ignored"; |
| 2716 |
} |
| 2717 |
|
| 2718 |
if ($final_status == 3) { |
| 2719 |
print $output," : UNKNOWN\n"; |
| 2720 |
exit $ERRORS{"UNKNOWN"}; |
| 2721 |
} |
| 2722 |
|
| 2723 |
if ($final_status == 2) { |
| 2724 |
print $output," : CRITICAL\n"; |
| 2725 |
exit $ERRORS{"CRITICAL"}; |
| 2726 |
} |
| 2727 |
|
| 2728 |
if ($final_status == 1) { |
| 2729 |
print $output," : WARNING\n"; |
| 2730 |
exit $ERRORS{"WARNING"}; |
| 2731 |
} |
| 2732 |
|
| 2733 |
print $output," : OK\n"; |
| 2734 |
exit $ERRORS{"OK"}; |
| 2735 |
} |
| 2736 |
|
| 2737 |
|
| 2738 |
# ============================================================================ |
| 2739 |
# ============================== NO CHECK DEFINED ============================ |
| 2740 |
# ============================================================================ |
| 2741 |
|
| 2742 |
print "Unknown check type : UNKNOWN\n"; |
| 2743 |
exit $ERRORS{"UNKNOWN"}; |
| 2744 |
|