Critical: Return code of 139 is out of bounds

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.
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Critical: Return code of 139 is out of bounds

Post by Ravil »

Hello!
I have Nagios Core 3.5. I connected the UPS to Nagios and wrote plugin to control its parametrs. It worked a month, but tonight I got this error: Return code of 139 is out of bounds. This error appeared only one request. Next, everything was back in OK condition.
What this error mean?
P.S. Sorry for dirty English :)
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Critical: Return code of 139 is out of bounds

Post by slansing »

Are you running the plugin on the nagios server? What are it's permissions, and can you attach it here? Along with the command definition in commands.cfg, and it's service definition? Thanks!
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Critical: Return code of 139 is out of bounds

Post by eloyd »

It worked a month, but tonight I got this error: Return code of 139 is out of bounds. This error appeared only one request. Next, everything was back in OK condition.
As @slansing said, we would need to know the command and service definitions to know what command you are executing, but my guess is that your plugin saw a problem but did not report it properly to Nagios. In other words, checking the UPS either timed out or returned an error code 139, which got passed back up to Nagios without being properly translated into a 1 (for WARNING) or 2 (for CRITICAL).
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Critical: Return code of 139 is out of bounds

Post by Ravil »

slansing wrote:Are you running the plugin on the nagios server? What are it's permissions, and can you attach it here? Along with the command definition in commands.cfg, and it's service definition? Thanks!
Yes, I use plugin on the nagios server.
file commands.cfg:

Code: Select all

#The battery capacity 
define command{
        command_name    check_apc_capacity
        command_line    $USER1$/check_apc_capacity $ARG1$ $ARG2$ $ARG3$ $HOSTADDRESS$
        }
permissions:

Code: Select all

ls -l
-rwxr-xr-x. 1 root   root     1696 Апр  9  2014 check_apc_capacity
file services.cfg:

Code: Select all

#The battery capacity
define service{
        use                             local-service
        hostgroup_name                  APC_smart_UPS
        service_description             Доступная ёмкость батарей
        check_command                   check_apc_capacity!public!pass1!pass2
        }
The plugin is written in python, and he could not pass such a mistake nagios. If the plugin has generated an exception nagios would not display it, and would have written "(null)" in the status information.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Critical: Return code of 139 is out of bounds

Post by eloyd »

Plugins which do not adequately check for error conditions can (and do) send improper results back to Nagios.

Can you share the source of the plugin with us? It looks like you might be checking via SNMP:
Plugins which do not adequately check for error conditions can (and do) send improper results back to Nagios.
It's entirely possible that the script is not parsing the error condition correctly, and since it only happened once, I am guessing that it was during an error.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Critical: Return code of 139 is out of bounds

Post by sreinhardt »

Couldn't agree more with eloyd! If you could share the plugin or a link to it, that would likely help a fair amount in seeing what this plugin is doing incorrectly.
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.
User avatar
josnavch
Posts: 9
Joined: Wed May 28, 2014 3:35 pm

Re: Critical: Return code of 139 is out of bounds

Post by josnavch »

Hi Ravil

I see that the plugin has root permissions can try running as nagios from the console to rule than a permissions issue.

further validate a recommendation that the folder where the plugins also have the same permissions and run nagios nagios plugins with full path.

JN
Jose Navarrete
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Critical: Return code of 139 is out of bounds

Post by slansing »

Good ideas @josnavch, let us know what your results are Ravil. Thanks! Out of bounds errors are usually permissions related.
Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Critical: Return code of 139 is out of bounds

Post by Ravil »

eloyd wrote:Plugins which do not adequately check for error conditions can (and do) send improper results back to Nagios.

Can you share the source of the plugin with us? It looks like you might be checking via SNMP:
Plugins which do not adequately check for error conditions can (and do) send improper results back to Nagios.
It's entirely possible that the script is not parsing the error condition correctly, and since it only happened once, I am guessing that it was during an error.

Code: Select all

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import argparse
import re
import subprocess

def createParser ():
        parser = argparse.ArgumentParser()
        parser.add_argument ('u')
        parser.add_argument ('A')
        parser.add_argument ('X')
        parser.add_argument ('H')

        return parser

per = createParser()
namespace = per.parse_args()
#__________________________________________________________________

flag_error = 0
result = subprocess.Popen('snmpwalk -v 3 -u ' + namespace.u + ' -a SHA -A ' + namespace.A + ' -x AES -X ' + namespace.X + ' -l authPriv ' + namespace.H + ' upsInput', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
(result_out, result_error) = result.communicate()

if result_out == '':
        read = result_error
        flag_error = 1
else:
        read = result_out

if flag_error == 1:
        out = re.findall ('^.*$',read, re.M)
        print " ;; ".join ([out[i] for i in range(len(out))])
        sys.exit (0) # UNKNOWN
#__________________________________________________________________

message = ""
flag_critical = 0

InVolt = re.search ('^.*PrecInputLineVoltage.*: (\d+).*$', read, re.M)
if InVolt != None:
	InVoltDiv = int(InVolt.group(1))/10
	InVoltMod = int(InVolt.group(1))%10

	message += "Напряжение: "+str(InVoltDiv)+","+str(InVoltMod)+" В "

	if InVoltDiv > 264:
		message += "(больше 264 В) ;; "
		flag_critical = 1
	elif InVoltDiv < 176:
	        message += "(меньше 176 В) ;; "
	        flag_critical = 1
	else:
		message += ";; "
else:
 	message += "Напряжение: нет данных ;; "
 	
InFreq = re.search ('^.*PrecInputFrequency.*: (\w+)$', read, re.M)
if InFreq != None:
	InFreqDiv = int(InFreq.group(1))/10
	InFreqMod = int(InFreq.group(1))%10

	message += "Частота: "+str(InFreqDiv)+","+str(InFreqMod)+" Гц "
	if InFreqDiv > 55:
		message += "(больше 55 Гц) ;; "
		flag_critical = 1 
	elif InFreqDiv < 45:
		message += "(меньше 45 Гц) ;; "
		flag_critical = 1
	else:
		message += ";;"
else:
	message += "Частота: нет данных"
	
if flag_critical == 1:
	print message
	sys.exit(2)
else:
        print message
        sys.exit(0)


Ravil
Posts: 43
Joined: Thu Feb 20, 2014 9:30 pm

Re: Critical: Return code of 139 is out of bounds

Post by Ravil »

josnavch wrote:Hi Ravil

I see that the plugin has root permissions can try running as nagios from the console to rule than a permissions issue.

further validate a recommendation that the folder where the plugins also have the same permissions and run nagios nagios plugins with full path.

JN
Ok, Thank you, follow your advice. Hope this helps
Locked