Nagios Exchange Nagios Exchange
  • Home
  • Directory
  • Library
  • Support
  • About

Advanced Search

Build precise queries to find exactly what you need

Search Logic

Select compatible versions

Press ESC to close

Sign In Sign Up
  • Home
  • Directory
  • Library
  • Support
  • About
Plugins4391Themes and Skins11Add-ons741Documentation283Graphics and Logos36View All Categories
LinuxSecuritySNMPFile SystemCloud
New Listings Recently Updated Listings Most Favored Listings Most Popular Listings Most Rated Listings Most Reviewed Listings
Random Project
Cisco check_snmp_cisco_wlc – Check the avaibility of Cisco WLC Access Points
4.3 (8)
77.2K
RSS Feed
Newest Listings Updated Listings
Top Contributors
Julien DESMAREST (6)Yoann LAMY (6)Davide Lemma (4)deskwork_itunes142 (4)Claudio Kuenzler (2)
See More
Newest Contributors
sowoii (1)Nitatemic (1)cjdepaul (1)ixs (1)messefreeze (2)
See More

Copyright © 2009-2025 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home > cesar
c

cesar

@brixsat

User Stats

Member Since: December 12, 2018

Favorites0

Views0

Projects2

check EdgeRouter 6p
Network and Systems Management
check EdgeRouter 6p
This script allows you to monitor the Ubiquiti Networks EdgeRouter 6P load, network, and disk space. At the moment only the disk space has warning…
0.0 (0)
2K
0
cesar
GPL
EdgeRouter 6p
Network and Systems Management
EdgeRouter 6p
This script allows you to monitor the Ubiquiti Networks EdgeRouter 6P load, network, and disk space. At the moment only the disk space has warning…
0.0 (0)
2.1K
0
cesar
GPL
Check postgres replication

not working on psql 10

Postgres 10 does not work. ERROR: function pg_last_xlog_replay_location() does not exist and other errors.

Reviewed 7 years ago

check_stack_netgear.sh

I made a litle improvement

I added nagios performance data and check for errors, multicast, unicast and octetcs. Enjoy. #!/bin/bash ## # # receive statusinfo from netgear switches # # you can get all snmp-options with: # snmpwalk -m ALL -v 2c -c MYCOMMUNITY MYIPADDRESS .1.3.6.1.2.1 # # # Usage: # ./check_netgear_switch -h IP-ADDRESS -c SNMP-COMMUNITY -s STATUSCHECK # # # 2020-02-18: Version 1.3 \ Pit Wenkin # ## SYSUPTIME=0 SYSCONTACT='' SYSNAME='' SYSLOCATION='' SNMPVersion="2c" SNMPCommunity="public" SNMPTimeout="10" SNMPPort="161" #OID declarations OID_SYSDESCRIPTION="1.3.6.1.2.1.1.1.0" OID_SYSOBJECTID="1.3.6.1.2.1.1.2.0" OID_SYSUPTIME="1.3.6.1.2.1.1.3.0" OID_SYSCONTACT="1.3.6.1.2.1.1.4.0" OID_SYSNAME="1.3.6.1.2.1.1.5.0" OID_SYSLOCATION="1.3.6.1.2.1.1.6.0" OID_SYSSERVICES="1.3.6.1.2.1.1.7.0" OID_IFOPERSTATUS=".1.3.6.1.2.1.2.2.1.8" OID_IFLASTCHANGE=".1.3.6.1.2.1.2.2.1.9" # nagios return values export STATE_OK=0 export STATE_WARNING=1 export STATE_CRITICAL=2 export STATE_UNKNOWN=3 export STATE_DEPENDENT=4 intReturn=$STATE_OK # Memory free OID_MEM_FREE=".1.3.6.1.4.1.4526.11.1.1.4.1" # Memory available OID_MEM_AVAILABLE=".1.3.6.1.4.1.4526.11.1.1.4.2" # An estimate of the interface's current bandwidth in bits per second OID_IF_SPEED=".1.3.6.1.2.1.2.2.1.5" ## ## Multicast ## # The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were addressed to a multicast address at this sub-layer. For a MAC layer protocol, this includes both Group and Functional addresses. OID_IN_MULTICAST_PACKETS=".1.3.6.1.2.1.31.1.1.1.2" # The total number of packets that higher-level protocols requested be transmitted, and which were addressed to a multicast address at this sub-layer, including those that were discarded or not sent. For a MAC layer protocol, this includes both Group and Functional addresses. OID_OUT_MULTICAST_PACKETS=".1.3.6.1.2.1.31.1.1.1.4" ## ## Broadcast ## # The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were addressed to a broadcast address at this sub-layer. OID_IN_BROADCAST_PACKETS=".1.3.6.1.2.1.31.1.1.1.3" # The total number of packets that higher-level protocols requested be transmitted, and which were addressed to a broadcast address at this sub-layer, including those that were discarded or not sent. OID_OUT_BROADCAST_PACKETS=".1.3.6.1.2.1.31.1.1.1.5" ## ## Octets ## # The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifInOctets. OID_IF_IN_OCTETS=".1.3.6.1.2.1.31.1.1.1.6" # The total number of octets transmitted out of the interface, including framing characters. This object is a 64-bit version of ifOutOctets. OID_IF_OUT_OCTETS=".1.3.6.1.2.1.31.1.1.1.10" ## ## Unicast ## # The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were not addressed to a multicast or broadcast address at this sub-layer. This object is a 64-bit version of ifInUcastPkts." OID_IF_IN_UNICAST=".1.3.6.1.2.1.31.1.1.1.7" # The total number of packets that higher-level protocols requested be transmitted, and which were not addressed to a multicast or broadcast address at this sub-layer, including those that were discarded or not sent. This object is a 64-bit version of ifOutUcastPkts. OID_IF_OUT_UNICAST=".1.3.6.1.2.1.31.1.1.1.11" ## ## Errors ## # For packet-oriented interfaces, the number of inbound packets that contained errors preventing them from being deliverable to a higher-layer protocol. For character-oriented or fixed-length interfaces, the number of inbound transmission units that contained errors preventing them from being deliverable to a higher-layer protocol. OID_IF_IN_ERRORS=".1.3.6.1.2.1.2.2.1.14" # For packet-oriented interfaces, the number of outbound packets that could not be transmitted because of errors. For character-oriented or fixed-length interfaces, the number of outbound transmission units that could not be transmitted because of errors. OID_IF_OUT_ERRORS=".1.3.6.1.2.1.2.2.1.20" usage() { echo "usage: ./check_netgear_switch -h [hostname] -c [community] -s [status]" echo "options:" echo " -h [snmp hostname] Hostname" echo " -c [community name] community name (ex: public)" echo " -p [snmp port] port for snmp request (default: 161)" echo " -P [port] port to check" echo " -n [number of ports] number of physical ports on device" echo " -o [options] additional options" echo " d only ports that are down (or anything except up)" echo " u only ports that are up" echo " -s [check] Check to be executed" echo " info System infos" echo " port Check statius specific port ('P' option)" echo " ports Listing of ports ('n' option defines number of port to check)" echo " uptime System uptime" echo " ports-octets Data on port (nagios perf output)" echo " ports-unicast Unicast on port (nagios perf output)" echo " ports-multicast Multicast on port (nagios perf output)" echo " ports-nagios Multicast/Unicast/Octets on port (nagios perf output)" echo " uptime System uptime" echo " -t [timeout] duration before doing an timeout in seconds - default 10s" echo "" echo "examples: ./check_netgear_switch -h 1.2.3.4 -c public -s info" echo " ./check_netgear_switch -h 1.2.3.4 -p 4321 -c public -s uptime -t 30" echo " ./check_netgear_switch -h 1.2.3.4 -c public -s ports -n 28" echo " ./check_netgear_switch -h 1.2.3.4 -c public -s port -P 1" exit 3 } if [ "$1" == "--help" ]; then usage; exit 0 fi while getopts c:h:n:o:p:P:s:t: OPTNAME; do case "$OPTNAME" in h) hostname="$OPTARG";; c) SNMPCommunity="$OPTARG";; o) options="$OPTARG";; n) ports="$OPTARG";; p) SNMPPort="$OPTARG";; P) port="$OPTARG";; s) status="$OPTARG";; t) SNMPTimeout="$OPTARG";; esac done function up_time { time=$1 pre=$2 suf=$3 up=$4 #returns uptime as human readable string if [[ $time =~ (.*):(.*):(.*):(.*).(.*) ]]; then DAYS=${BASH_REMATCH[1]} HOURS=${BASH_REMATCH[2]} MINUTES=${BASH_REMATCH[3]} SECONDS=${BASH_REMATCH[4]} MILLISECONDS=${BASH_REMATCH[5]} output=$output"$pre$DAYS days $HOURS hours $MINUTES minutes$suf" if [ $DAYS == "0" ] && [ $HOURS == "0" ] && [ $MINUTES -lt "5" ]; then intReturn=$STATE_CRITICAL if [ "$up" != '' ]; then output=$up"$pre$DAYS days $HOURS hours $MINUTES minutes$suf"$output fi else if [ $intReturn -lt $STATE_CRITICAL ] && [ $DAYS == "0" ] && [ $HOURS == "0" ] && [ $MINUTES -lt "15" ]; then intReturn=$STATE_WARNING if [ "$up" != '' ]; then output=$up"$pre$DAYS days $HOURS hours $MINUTES minutes$suf"$output fi fi fi fi } function get_timestamp { t=$1 if [[ $t =~ (.*):(.*):(.*):(.*).(.*) ]]; then DAYS=${BASH_REMATCH[1]} HOURS=${BASH_REMATCH[2]} MINUTES=${BASH_REMATCH[3]} SECONDS=${BASH_REMATCH[4]} MILLISECONDS=${BASH_REMATCH[5]} ALL=$((10#$DAYS*24*60*60*1000 + 10#$HOURS*60*60*1000 + 10#$MINUTES*60*1000 + 10#$SECONDS*1000 + 10#$MILLISECONDS)) echo $ALL fi } function sub_time { t1=$1 t2=$2; #substracts one uptime from another T1ALL=$(get_timestamp $t1) T2ALL=$(get_timestamp $t2) if [[ T1ALL != '' && T2ALL != '' ]]; then TS=$((T1ALL - T2ALL)) DAYS=$(($TS/(24*60*60*1000))) TS=$(($TS-($DAYS*24*60*60*1000))) HOURS=$(($TS/(60*60*1000))) TS=$(($TS-($HOURS*60*60*1000))) MINUTES=$(($TS/(60*1000))) TS=$(($TS-($MINUTES*60*1000))) SECONDS=$(($TS/(1000))) MILLSECONDS=$(($TS-$SECONDS)) echo "$DAYS:$HOURS:$MINUTES:$SECONDS.$MILLISECONDS" else echo 'ERROR' fi } if [ "$hostname" = "" ] || [ "$SNMPCommunity" = "" ] ; then usage else SNMPArgs=" -OQne -v $SNMPVersion -c $SNMPCommunity -t $SNMPTimeout $hostname:$SNMPPort" case "$status" in info) info=`snmpget $SNMPArgs $OID_SYSDESCRIPTION $OID_SYSUPTIME $OID_SYSCONTACT $OID_SYSNAME $OID_SYSLOCATION 2> /dev/null` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL ; else SYSDESCRIPTION=$(echo "$info" | grep $OID_SYSDESCRIPTION | sed 's/.* = //g' | sed 's/"//g') SYSUPTIME=$(echo "$info" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') SYSCONTACT=$(echo "$info" | grep $OID_SYSCONTACT | sed 's/.* = //g' | sed 's/"//g') SYSNAME=$(echo "$info" | grep $OID_SYSNAME | sed 's/.* = //g' | sed 's/"//g') SYSLOCATION=$(echo "$info" | grep $OID_SYSLOCATION | sed 's/.* = //g' | sed 's/"//g') if [ "$SYSDESCRIPTION" != "" ] ; then output="Description - $SYSDESCRIPTIONn" fi if [ "$SYSUPTIME" != "" ] ; then up_time $SYSUPTIME 'Uptime - ' output=$output"n" fi if [ "$SYSCONTACT" != "" ] ; then output=$output"Contact - $SYSCONTACTn" fi if [ "$SYSNAME" != "" ] ; then output=$output"Name - $SYSNAMEn" fi if [ "$SYSLOCATION" != "" ] ; then output=$output"Location - $SYSLOCATION" fi if [ "$output" == "" ] ; then output="No information returned" intReturn=$STATE_WARNING fi fi ;; ports) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFOPERSTATUS.$i $OID_IFLASTCHANGE.$i " done PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portChange[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFLASTCHANGE.$((i)) " | tr -d 'n' | sed 's/.* = //g' | sed 's/"//g') case ${portStatus[$i]} in "1") portText[$i]="Up"; ;; "2") portText[$i]="Down"; ;; "3") portText[$i]="Testing"; ;; "4") portText[$i]="Unknown"; ;; "5") portText[$i]="Dormant"; ;; "6") portText[$i]="Not present"; ;; "7") portText[$i]="Lower layer down"; ;; esac if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Port $i - ${portText[$i]}t"; portUptime=$(sub_time $SYSUPTIME ${portChange[$i]}) up_time $portUptime '(since ' " ago)n" "Port $i - ${portText[$i]}t"; fi done fi fi ;; port) if [ "$port" == "" ] ; then output="Please define port to check"; intReturn=$STATE_UNKNOWN; else PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_IFOPERSTATUS.$port $OID_IFLASTCHANGE.$port` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else portStatus=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((port)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portChange=$(echo "$PORTSTATUS" | grep "$OID_IFLASTCHANGE.$((port)) " | tr -d 'n' | sed 's/.* = //g' | sed 's/"//g') SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') case $portStatus in "1") portText="Up"; intReturn=$STATE_OK;; "2") portText="Down"; intReturn=$STATE_CRITICAL;; "3") portText="Testing"; intReturn=$STATE_WARNING;; "4") portText="Unknown"; intReturn=$STATE_UNKNOWN;; "5") portText="Dormant"; intReturn=$STATE_CRITICAL;; "6") portText="Not present"; intReturn=$STATE_CRITICAL;; "7") portText="Lower layer down"; intReturn=$STATE_CRITICAL;; esac output=$output"Port $port - $portTextt"; portUptime=$(sub_time $SYSUPTIME $portChange) up_time $portUptime '(since ' " ago)n"; fi fi ;; uptime) SYSUPTIME=`snmpget $SNMPArgs $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g'` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host"; intReturn=$STATE_CRITICAL; else up_time $SYSUPTIME 'Uptime - ' fi ;; ports-multicast) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFOPERSTATUS.$i $OID_IFLASTCHANGE.$i $OID_IN_MULTICAST_PACKETS.$i $OID_OUT_MULTICAST_PACKETS.$i " done PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else output="Ok | " SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portChange[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFLASTCHANGE.$((i)) " | tr -d 'n' | sed 's/.* = //g' | sed 's/"//g') portInMulticast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IN_MULTICAST_PACKETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutMulticast[$i]=$(echo "$PORTSTATUS" | grep "$OID_OUT_MULTICAST_PACKETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') case ${portStatus[$i]} in "1") portText[$i]="Up"; ;; # Up "2") portText[$i]="Down"; ;; # Down "3") portText[$i]="Testing"; ;; # Testing "4") portText[$i]="Unknown"; ;; # Unknown "5") portText[$i]="Dormant"; ;; # Dormant "6") portText[$i]="Not present"; ;; # Not present "7") portText[$i]="Lower layer down"; ;; # Lower layer down esac if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Port_${i}_status=${portStatus[$i]}; Multicast_IN_$i=${portInMulticast[$i]};$MC_W;$MC_C;; Multicast_OUT_$i=${portOutMulticast[$i]};$MC_W;$MC_C;; " fi done fi fi ;; ports-unicast) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_UNICAST.$i $OID_IF_OUT_UNICAST.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else output="Ok | " SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInUnicast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_UNICAST.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutUnicast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_UNICAST.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Unicast_IN_$i=${portInUnicast[$i]};$UC_W;$UC_C;; Unicast_OUT_$i=${portOutUnicast[$i]};$UC_W;$UC_C;; " fi done fi fi ;; ports-octets) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_OCTETS.$i $OID_IF_OUT_OCTETS.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else output="Ok | " SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_OCTETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_OCTETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Octets_IN_$i=${portInStatus[$i]};$UC_W;$UC_C;; Octets_OUT_$i=${portOutStatus[$i]};$UC_W;$UC_C;; " fi done fi fi ;; ports-errors) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_ERRORS.$i $OID_IF_OUT_ERRORS.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else output="Ok | " SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_ERRORS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_ERRORS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Errors_IN_$i=${portInStatus[$i]};$EC_W;$EC_C;; Errors_OUT_$i=${portOutStatus[$i]};$EC_W;$EC_C;; " fi done fi fi ;; ports-nagios) if [ "$ports" == "" ] ; then output="Please define number of ports"; intReturn=$STATE_UNKNOWN; else ## ## Octets ## OID_PORTSTATUS="" for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_OCTETS.$i $OID_IF_OUT_OCTETS.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else output="Ok | " SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_OCTETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_OCTETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Octets_IN_$i=${portInStatus[$i]};$UC_W;$UC_C;; Octets_OUT_$i=${portOutStatus[$i]};$UC_W;$UC_C;; " fi done fi ## ## Unicast ## OID_PORTSTATUS="" for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_UNICAST.$i $OID_IF_OUT_UNICAST.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output==$output"CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInUnicast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_UNICAST.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutUnicast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_UNICAST.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Unicast_IN_$i=${portInUnicast[$i]};$UC_W;$UC_C;; Unicast_OUT_$i=${portOutUnicast[$i]};$UC_W;$UC_C;; " fi done fi ## ## Multicast ## OID_PORTSTATUS="" for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFOPERSTATUS.$i $OID_IFLASTCHANGE.$i $OID_IN_MULTICAST_PACKETS.$i $OID_OUT_MULTICAST_PACKETS.$i " done PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portChange[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFLASTCHANGE.$((i)) " | tr -d 'n' | sed 's/.* = //g' | sed 's/"//g') portInMulticast[$i]=$(echo "$PORTSTATUS" | grep "$OID_IN_MULTICAST_PACKETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutMulticast[$i]=$(echo "$PORTSTATUS" | grep "$OID_OUT_MULTICAST_PACKETS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') case ${portStatus[$i]} in "1") portText[$i]="Up"; ;; # Up "2") portText[$i]="Down"; ;; # Down "3") portText[$i]="Testing"; ;; # Testing "4") portText[$i]="Unknown"; ;; # Unknown "5") portText[$i]="Dormant"; ;; # Dormant "6") portText[$i]="Not present"; ;; # Not present "7") portText[$i]="Lower layer down"; ;; # Lower layer down esac if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Port_${i}_status=${portStatus[$i]}; Multicast_IN_$i=${portInMulticast[$i]};$MC_W;$MC_C;; Multicast_OUT_$i=${portOutMulticast[$i]};$MC_W;$MC_C;; " fi done fi ## ## Errors ## OID_PORTSTATUS="" for i in `seq 1 $ports`; do OID_PORTSTATUS="$OID_PORTSTATUS $OID_IFLASTCHANGE.$i $OID_IF_IN_ERRORS.$i $OID_IF_OUT_ERRORS.$i " done # echo snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS PORTSTATUS=`snmpget $SNMPArgs $OID_SYSUPTIME $OID_PORTSTATUS` if [ "$?" != "0" ] ; then output="CRITICAL - Problem with SNMP request, check user/password/host" intReturn=$STATE_CRITICAL; else SYSUPTIME=$(echo "$PORTSTATUS" | grep $OID_SYSUPTIME | sed 's/.* = //g' | sed 's/"//g') for i in `seq 1 $ports`; do portStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IFOPERSTATUS.$((i)) " | cut -d "=" -f2 | sed 's/^[ t]*//;s/[ t]*$//') portInStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_IN_ERRORS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') portOutStatus[$i]=$(echo "$PORTSTATUS" | grep "$OID_IF_OUT_ERRORS.$((i)) " | sed 's/.* = //g' | sed 's/"//g') if [ ( "$options" = "" ) -o ( "$options" = "u" -a "${portStatus[$i]}" = "1" ) -o ( "$options" = "d" -a "${portStatus[$i]}" != "1" ) ] ; then output=$output"Errors_IN_$i=${portInStatus[$i]};$EC_W;$EC_C;; Errors_OUT_$i=${portOutStatus[$i]};$EC_W;$EC_C;; " fi done fi ## ## End ## fi ;; *) usage; exit 0 ;; esac echo -e $output exit $intReturn fi

Reviewed 5 years ago

No Favorites Found

Copyright © 2009-2025 Nagios Enterprises, LLC. All rights reserved.

Privacy PolicyTerms of UseTrademarks
Home Browse Submit Profile