check_ports Issue on 52 Port Switches

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

check_ports Issue on 52 Port Switches

Post by and1100 »

Hello,

I've notice the check_ports script that was directed to me by these forums (thank you!) is having issues on 52 port switches. It seems that the script is thinking that our 52 port switches have only 24 ports, or it is scanning the first 24 ports. As a result, it throws WARNINGS.

Here is the script:

Code: Select all

#!/bin/bash
ADDRESS=$1
COMMUNITY=$2
PORTS=$3

COUNT=$(snmpwalk -v1 -c $COMMUNITY $ADDRESS ifOperStatus | grep notPresent | wc -l)

if [ $COUNT -lt $PORTS ]; then
        echo "WARNING! Less than $PORTS ports free | 'ports free'=$COUNT"
        exit 1
else
        echo "OK! $PORTS ports or more free! | 'ports free'=$COUNT"
        exit 0
fi
Is there any way to modify this for 52 port switches? I did not see where it's pulling the count from. Thank you!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_ports Issue on 52 Port Switches

Post by abrist »

This looks like my script, so I guess this is my problem :P
Lets check what the walk outputs:

Code: Select all

snmpwalk -v1 -c $COMMUNITY $ADDRESS ifOperStatus
(replace $COMMUNITY and $ADDRESS with the actual values for one of your 52 port switches)
Post the output in code wraps.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

Re: check_ports Issue on 52 Port Switches

Post by and1100 »

Hi Abrist,

Thank you for the response. I will grab you some outputs shortly!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_ports Issue on 52 Port Switches

Post by abrist »

Great!
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked