Page 1 of 1

did not eval into defined data

Posted: Fri Apr 12, 2019 6:11 pm
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?

Re: did not eval into defined data

Posted: Mon Apr 15, 2019 2:16 pm
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"`

Re: did not eval into defined data

Posted: Tue Apr 16, 2019 7:28 pm
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.)

Re: did not eval into defined data

Posted: Wed Apr 17, 2019 4:13 pm
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"`

Re: did not eval into defined data

Posted: Wed Apr 17, 2019 4:22 pm
by dclose
Not needed. There is no "grep" in the output lines, with or without an error.

Re: did not eval into defined data

Posted: Thu Apr 18, 2019 11:13 am
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.

Re: did not eval into defined data

Posted: Thu Apr 18, 2019 11:47 am
by dclose
Yes, fixed. Thanks. Was there something I should have selected to mark the answer?

Re: did not eval into defined data

Posted: Thu Apr 18, 2019 4:37 pm
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