did not eval into defined data

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
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

did not eval into defined data

Post by dclose »

I have an MRTG system (running on Fedora 29) which uses an external bash script to collect some of the data. My problem occurs when the script takes too long to complete and is abnormally terminated by the system. The script exit code is 137, KILL (9) + abnormal (128). I can't trap on this value so MRTG does not receive any output. The log shows errors like, "did not eval into defined data". With no new data to process, MRTG generates graphs with horizontal straight lines, implying that the return values did not change. But that's misleading at best and probably actually wrong.

I'd like MRTG to treat this case as through the script returned zeros. If I could trap on the exit condition, that would be trivial, but that isn't possible. Is there a way to instruct MRTG to treat this case as though the script returned zeros? If not, are there any other suggestions that would accomplish the same thing?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Post by ssax »

My recommendation would be for you to update your external script to timeout within a period of time, if that timeout is hit, return zero. That should do what you're looking for.

Another example would be something like this (you'll need to see if this works for you):
- Set X to the number of seconds it should at MAX take to return

Code: Select all

Target[target_name]: `timeout X /path/to/your/script.sh blah blah blah || printf "0\n0\n0\ntarget_name"`
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: did not eval into defined data

Post by dclose »

Thank you, ssax. Even without the timeout prefix, your suggestion catches the error and outputs the alternate values (all zeros). Unfortunately, the kill outputs "Killed" to standard out first, meaning that the output effectively consists of five lines with the zeros in the wrong places. The form,

Code: Select all

/path/to/your/script.sh blah blah blah | grep -v Killed || printf "0\n0\n0\ntarget_name"`
seems to delete the extra line. (If output is normal, grep finds the expected four lines and returns 0. If Killed is present, grep finds nothing else so returns 1 and omits Killed.)
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Post by ssax »

Does this work?

Code: Select all

/path/to/your/script.sh blah blah blah | grep -v Killed | grep -v grep || printf "0\n0\n0\ntarget_name"`
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: did not eval into defined data

Post by dclose »

Not needed. There is no "grep" in the output lines, with or without an error.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Post by ssax »

Are you still having issues or is it working as expected? It kind of sounds like you were just telling me your resolution but I want to make sure.
dclose
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: did not eval into defined data

Post by dclose »

Yes, fixed. Thanks. Was there something I should have selected to mark the answer?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: did not eval into defined data

Post by scottwilkerson »

dclose wrote:Yes, fixed. Thanks. Was there something I should have selected to mark the answer?
Nope.

Glad it is resolved, Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked