Hello,
I was not entirely sure if this was possible with Nagios, but are we able to have Nagios check for switch port capacity and send alerts? For example, if our switches are down to 5 free ports ('not connect') I would like Nagios to send an alert for this. I've been trying to think of a way to do this but I'm not really sure how to go about doing so.
Any help would be greatly appreciated.
Thank you.
Switch Port Capacity Alert
Re: Switch Port Capacity Alert
This would take a custom script that walks your ports, greps for down, if less that 6, exits with a warning. For example:
check_ports.sh:
You would use the script as such:
For example:
check_ports.sh:
Code: Select all
#!/bin/bash
ADDRESS=$1
COMMUNITY=$2
PORTS=$3
COUNT=$(snmpwalk -v1 -c $COMMUNITY $ADDRESS ifOperStatus | grep down | 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
Code: Select all
./check_ports.sh <ip address> <community string> <number of ports to warn under>Code: Select all
./check_ports.sh 127.0.0.1 public 6Former 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.
"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.
Re: Switch Port Capacity Alert
Wow, awesome. Thank you!
I will give this a shot and let you know if I have any issues.
I will give this a shot and let you know if I have any issues.
Re: Switch Port Capacity Alert
This works great, however, I am trying to enter it into a cfg.
I've defined the command as follows:
The check_command in the defined service looks like this:
check_command check_ports!-H 10.10.1.2 secret 5
However, it's not working the way it was when I ran the command manually. Any thoughts?
Thanks again!
I've defined the command as follows:
Code: Select all
define command{
command_name check_ports
command_line $USER1$/check_ports $ARG1$ $ARG2$ $ARG3$
}check_command check_ports!-H 10.10.1.2 secret 5
However, it's not working the way it was when I ran the command manually. Any thoughts?
Thanks again!
Re: Switch Port Capacity Alert
Dump the -H from the check_command:
Code: Select all
check_command check_ports!10.10.1.2 secret 5Former 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.
"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.
Re: Switch Port Capacity Alert
Does this have any issues with 52 port switches? It doesn't seem to be reporting for them:
root@vmnagios libexec]# ./check_ports 10.10.8.4 secret 8
Timeout: No Response from 10.10.8.4
WARNING! Less than 8 ports free | 'ports free'=0
However, on our 24 port switches it works fine. Any ideas?
root@vmnagios libexec]# ./check_ports 10.10.8.4 secret 8
Timeout: No Response from 10.10.8.4
WARNING! Less than 8 ports free | 'ports free'=0
However, on our 24 port switches it works fine. Any ideas?
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Switch Port Capacity Alert
First thought would be that snmp is not enabled on that switch. It seems that you are not getting a response. A simple nmap can verify.
nmap -p 161 -sU 10.10.8.4
nmap -p 161 -sU 10.10.8.4
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.