SNMP Monitoring a VPN interface that changes

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.
rjesse
Posts: 3
Joined: Tue May 02, 2017 9:44 am

SNMP Monitoring a VPN interface that changes

Post by rjesse »

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
User avatar
rhassing
Posts: 412
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: SNMP Monitoring a VPN interface that changes

Post by rhassing »

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
Image
rjesse
Posts: 3
Joined: Tue May 02, 2017 9:44 am

Re: SNMP Monitoring a VPN interface that changes

Post by rjesse »

I guess the script would have to modify the nagios conf file and restart nagios?
dwhitfield
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

Post by dwhitfield »

@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!
User avatar
rhassing
Posts: 412
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: SNMP Monitoring a VPN interface that changes

Post by rhassing »

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
Image
dwhitfield
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

Post by dwhitfield »

@rjesse, please let us know if that solution works for you.

Thanks again @rhassing!
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: SNMP Monitoring a VPN interface that changes

Post by tacolover101 »

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.
dwhitfield
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

Post by dwhitfield »

tacolover101 wrote:perl isn't necessarily needed
I was thinking the same thing, but figured perl might be particularly useful since it was suggested. Thanks @tacolover101!
User avatar
rhassing
Posts: 412
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: SNMP Monitoring a VPN interface that changes

Post by rhassing »

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 :-)
Rob Hassing
Image
rjesse
Posts: 3
Joined: Tue May 02, 2017 9:44 am

Re: SNMP Monitoring a VPN interface that changes

Post by rjesse »

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.
Locked