SNMP Monitoring a VPN interface that changes
SNMP Monitoring a VPN interface that changes
I'm using nagios to monitor the status of a VPN tunnel port via SNMP (check_snmp), I have no issues monitoring except from time to time the VPN times out and reestablishes a connection. When this happens the port number changes.
I can always find the new port number via the following mibs as the name remains at tun15. Is there anyway to script nagios to lookup the interface name then use the interface number to check the status? ie in this case interface 72.
IF-MIB::ifDescr.72 = STRING: tun15
IF-MIB::ifName.72 = STRING: tun15
Rick
I can always find the new port number via the following mibs as the name remains at tun15. Is there anyway to script nagios to lookup the interface name then use the interface number to check the status? ie in this case interface 72.
IF-MIB::ifDescr.72 = STRING: tun15
IF-MIB::ifName.72 = STRING: tun15
Rick
Re: SNMP Monitoring a VPN interface that changes
you could write a perl script that checks for the tun15 and make it report the number (72 in this case) and than do the snmp check for that number
Rob Hassing
Re: SNMP Monitoring a VPN interface that changes
I guess the script would have to modify the nagios conf file and restart nagios?
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: SNMP Monitoring a VPN interface that changes
@rjesse, that's certainly one way to do it.
You could also put all of the logic in the same script, that way you don't need to change any files. Well, you change it once. However, this means you're checking it every time Nagios runs and it sounds like you only need to check it when it goes down. I guess it just depends on how often "time to time" is and what you feel will be easier to manage.
@rhassing, thanks!
You could also put all of the logic in the same script, that way you don't need to change any files. Well, you change it once. However, this means you're checking it every time Nagios runs and it sounds like you only need to check it when it goes down. I guess it just depends on how often "time to time" is and what you feel will be easier to manage.
@rhassing, thanks!
Re: SNMP Monitoring a VPN interface that changes
you could create a script with something like this, but you would have to do some perl around it. I have no time, otherwise I could have made the script for you:
Code: Select all
$nr=`/usr/bin/snmpwalk -v 2c -c $opt_C $host IF-MIB::ifDescr | /bin/grep tun15| /usr/bin/awk -F' ' '{print \$1}' | /usr/bin/awk -F. '{print \$NF}' `;
$vpnstatus=`/usr/bin/snmpget -v 2c -c $opt_C $host IF-MIB::ifOperStatus.$nr`;
Rob Hassing
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: SNMP Monitoring a VPN interface that changes
perl isn't necessarily needed, could still use bash. something like this might help as a good 'base line' for what can be done - https://github.com/rcknag/nagios-plugin ... rocurve.sh
the other option, i'm pretty sure check_snmp can handle standard OID's so you might be able to utilize that.
the other option, i'm pretty sure check_snmp can handle standard OID's so you might be able to utilize that.
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: SNMP Monitoring a VPN interface that changes
I was thinking the same thing, but figured perl might be particularly useful since it was suggested. Thanks @tacolover101!tacolover101 wrote:perl isn't necessarily needed
Re: SNMP Monitoring a VPN interface that changes
It can also be done in bash, that's for sure.
You could also use any other language you would prefer.
I just had an example I used in a perl script, but it's almost bash if you leaver out some \'es
You could also use any other language you would prefer.
I just had an example I used in a perl script, but it's almost bash if you leaver out some \'es
Rob Hassing
Re: SNMP Monitoring a VPN interface that changes
Thanks everyone for the tips and samples, I have a working shell script outside of Nagios, I just need to figure out how to get it working inside Nagios as a plugin, some quick learning for me. I'll post my solution when i get it working.