coltras
coltras

Reputation: 27

Nagios - Interface IP Check Script

I'm a bit of a novice with Linux & Nagios plugins but I need to setup alerts for when router interfaces loses their IP's (so when it is seen as 0.0.0.0). I did a little research of other peoples scripts and wrote the below script named check_ip.pl:

$snmpIfIP = '.1.3.6.1.4.1.23695.2.1.3.1.1.3.0.0';
$noip = "0.0.0.0";
if ($snmpIfIP != $noip) {
echo "Interface has an IP";
exit 0 } else { echo "No IP on Interface"; exit 2 }

In Nagios, I then assigned this to a check_command: $USER1$/check_ip.pl

Assigned a template to use this check command and created a service from this template. SNMP between the Nagios server and the Router is working - However i'm getting "(Return code of 126 is out of bounds - plugin may not be executable)" - so i've done something wrong with the plugin code!

I know the following is correct:

Can anyone offer advice / how the plugin file needs to be written please?

Many Thanks.

Upvotes: 1

Views: 280

Answers (1)

Nagios Support
Nagios Support

Reputation: 561

Is your plugin actually in the $USER1$ directory? $USER1$ is /usr/local/nagios/libexec in most cases.

You'll need to make sure that not only is your plugin executable:

chmod +x /usr/local/nagios/libexec/check_ip.pl

But also that it is executable (and owned) by the Nagios user:

chown nagios:nagios /usr/local/nagios/libexec/check_ip.pl

If you've tested your script and it's working properly when ran manually, then this should resolve your issue!

However, the code you posted isn't a full plugin. What I see won't return what you're looking for. Is there something specifically you need help with regarding the code?

Also, make sure you check out the Nagios Plugin Development Guidelines!

Upvotes: 3

Related Questions