did not eval into defined data

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

did not eval into defined data

Postby dclose » Fri Apr 12, 2019 6:11 pm

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

Re: did not eval into defined data

Postby ssax » Mon Apr 15, 2019 2:16 pm

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"`
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4108
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Postby dclose » Tue Apr 16, 2019 7:28 pm

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

Re: did not eval into defined data

Postby ssax » Wed Apr 17, 2019 4:13 pm

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"`
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4108
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Postby dclose » Wed Apr 17, 2019 4:22 pm

Not needed. There is no "grep" in the output lines, with or without an error.
dclose
 
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: did not eval into defined data

Postby ssax » Thu Apr 18, 2019 11:13 am

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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
ssax
Dreams In Code
 
Posts: 4108
Joined: Wed Feb 11, 2015 12:54 pm

Re: did not eval into defined data

Postby dclose » Thu Apr 18, 2019 11:47 am

Yes, fixed. Thanks. Was there something I should have selected to mark the answer?
dclose
 
Posts: 6
Joined: Mon Feb 26, 2018 8:18 pm

Re: did not eval into defined data

Postby scottwilkerson » Thu Apr 18, 2019 4:37 pm

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

Nope.

Glad it is resolved, Locking thread
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 15057
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 14 guests