check_snmp_environment.pl: check did not exit properly

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
opierp
Posts: 5
Joined: Tue Nov 05, 2013 10:46 pm
Location: San Jose, California

check_snmp_environment.pl: check did not exit properly

Post by opierp »

I really like the plugin check_snmp_environment.pl! I am able to execute the plugin from the command line but have not been able to make it work in Nagios. All the comments I see on the Nagios plugins page are positive so I must be doing something simply wrong in my scripts.

I am running Nagios 3.5.0 on OpenSUSE 12.1.

I successfully executed the plugin from the command line targeting a variety of Cisco platforms. Here is the command line for 10.231.135.131.

./check_snmp_environment.pl –H 10.231.135.131 -2 –T cisco –C s2436608

Linux returns:
1 Fan OK, 1 ps OK: OK

This is how the plugin is translated in commands.cfg.

# 'check_snmp_environment' command definition
define command {
command_name check_cisco_env
command_line $USER1$/check_snmp_environment.pl -H $HOSTADDRESS$ $ARG1$
}

Here is the rest of the configuration information.

define servicegroup {
servicegroup_name MPI
alias Mail Processing Infrastructure
members 10.231.135.131, PING, 10.231.135.132, PING
}

define hostgroup {
hostgroup_name MPI_CORE_C2960G-24TC-L
alias MPI_CORE_C2960G-24TC-L
}

define host {
use generic-switch
host_name 10.231.135.131
address 10.231.135.131
alias SAJSCAMSW01
icon_image_alt SAJSCAMSW01
icon_image switch_core_mpi.png
statusmap_image switch_core_mpi.png
hostgroups MPI_CORE_C2960G-24TC-L
}

define host {
use generic-switch
host_name 10.231.135.132
address 10.231.135.132
alias SAJSCAMSW02
icon_image_alt SAJSCAMSW02
icon_image switch_core_mpi.png
statusmap_image switch_core_mpi.png
hostgroups MPI_CORE_C2960G-24TC-L
parents 10.231.135.131
}

define service {
use local-service
hostgroup_name MPI_CORE_C2960G-24TC-L
service_description PING
check_command check_ping!200.0,20%!600.0,60%
normal_check_interval 5
retry_check_interval 1
}

define service {
use local-service
hostgroup_name MPI_CORE_C2960G-24TC-L
service_description A30 - Power Supply
check_command check_snmp!-P 2c -C s2436608 -o SNMPv2-SMI::enterprises.9.9.13.1.5.1.3.1003 -c1
}

define service {
use local-service
hostgroup_name MPI_CORE_C2960G-24TC-L
service_description A20 - Fan
check_command check_snmp!-P 2c -C s2436608 -o SNMPv2-SMI::enterprises.9.9.13.1.4.1.3.1004 -c1
}

define service {
use local-service
hostgroup_name MPI_CORE_C2960G-24TC-L
service_description A45 - Environment Status
check_command check_cisco_env!-2 -T cisco -C s2436608
}


I left the services that check specific OIDs for fan and power; these are working. However I want to get check_snmp_environment.pl working as I have to check environmental status on a large number of diverse Cisco platforms and this plugin would save me a lot of time and effort.

I appreciate any help anyone is able to provide.

Thanks,

Richard Opie, Equipment Specialist
US Postal Service
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_snmp_environment.pl: check did not exit properly

Post by ssax »

If you run this command and force a check, what does the output say?

Code: Select all

tail -f /usr/local/nagios/var/nagios.log
opierp
Posts: 5
Joined: Tue Nov 05, 2013 10:46 pm
Location: San Jose, California

Re: check_snmp_environment.pl: check did not exit properly

Post by opierp »

This is the contents of nagios.log as per your suggested command.

[1431694599] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431694899] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431695199] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431695499] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431695799] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431695799] SERVICE NOTIFICATION: nagiosadmin;10.231.135.131;A45 - Environment Status;CRITICAL;notify-service-by-email;(Service check did not exit properly)
[1431695830] Warning: Contact 'nagiosadmin' service notification command '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: A45 - Environment Status\nHost: SAJSCAMSW01\nAddress: 10.231.135.131\nState: CRITICAL\n\nDate/Time: Fri May 15 06:16:39 PDT 2015\n\nAdditional Info:\n\n(Service check did not exit properly)\n" | /usr/bin/mail -s "** PROBLEM Service Alert: SAJSCAMSW01/A45 - Environment Status is CRITICAL **" nagios@localhost' timed out after 30 seconds
[1431695966] Auto-save of retention data completed successfully.
[1431696100] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly!
[1431696400] Warning: Check of service 'A45 - Environment Status' on host '10.231.135.131' did not exit properly

I took the additional step of enabling debug with full verbose in nagios.cfg. This is the significant message:

[1431697780.202272] [016.0] [pid=16697] Embedded Perl failed to compile /usr/lib/nagios/plugins/check_snmp_environment.pl, compile error **ePN failed to compile /usr/lib/nagios/plugins/check_snmp_environment.pl: "Variable "$Version" will not stay shared at (eval 1) line 379," at /usr/lib/nagios/p1.pl line 160.
- skipping plugin

So the Linux-resident Perl interpreter does not find any problem with the check but the Nagios embedded interpreter fails.

What do you suggest now?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: check_snmp_environment.pl: check did not exit properly

Post by jdalrymple »

Using The Embedded Perl Interpreter wrote: Plugin-Specific Use of the Perl Interpreter

Beginning with Nagios 3, you can specify which Perl plugins or scripts should or should not be run under the embedded Perl interpreter. This is particularly useful if you have troublesome Perl scripts which do not work well with the Perl interpreter.

To explicitly tell Nagios whether or not to use the embedded Perl interpreter for a particular perl script, add one of the following entries to your Perl script/plugin...

To tell Nagios to use the Perl interpreter for a particular script, add this line to the Perl script:


# nagios: +epn

To tell Nagios to NOT use the embedded Perl interpreter for a particular script, add this line to the Perl script:


# nagios: -epn

Either line must be located within the first 10 lines of a script for Nagios to detect it.
opierp
Posts: 5
Joined: Tue Nov 05, 2013 10:46 pm
Location: San Jose, California

Re: check_snmp_environment.pl: check did not exit properly

Post by opierp »

I just added '# nagios: -epn' to the plugin and that corrected the problem; thanks!
Locked