Page 1 of 1

Unlimited setenv() breaks large output plugins.

Posted: Fri Apr 25, 2014 12:42 pm
by tombo
Hi
Process env is limited. When nagios try to run check that had large perfdata and output in previous run , it will fail with :
Warning: Return code of 127 for check of service 'xxxx' on host 'yyyy' was out of bounds.
Fail will happen every second check run.

System cannot run shell command, when env is filled.

My dirty solution to this problem is ( base/utils.c ) in set_environment_var () :

Code: Select all

        /* set the environment variable */
        if(set==TRUE){
          if ( strlen((value==NULL)?"":value) < 8192 ) {
#ifdef HAVE_SETENV
                setenv(name,(value==NULL)?"":value,1);
#else
                /* needed for Solaris and systems that don't have setenv() */
                /* this will leak memory, but in a "controlled" way, since lost memory should be freed when the child process exits */
                asprintf(&env_string,"%s=%s",name,(value==NULL)?"":value);
                if(env_string)
                        putenv(env_string);
#endif
          }else{
             logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Size of %s is %i, Skipping setenv.\n",name,strlen((value==NULL)?"":value));
             setenv(name,"",1);    
          }

--
Kind regards
Marek Grzybowski

Re: Unlimited setenv() breaks large output plugins.

Posted: Fri Apr 25, 2014 1:13 pm
by abrist
Thanks for the bug report. I have imported the issue to gihub:
https://github.com/nagios-plugins/nagio ... /issues/32

What version of the plugins are you running?

Re: Unlimited setenv() breaks large output plugins.

Posted: Mon Apr 28, 2014 6:20 am
by tombo
Hi
Thanks, but i think that this issue has nothing to do with the nagios-plugins . You will come across it, If You write plugin that outputs megabytes of performance data. This is rare case , but we hit this nagios limit twice ( custom pluginis based on naglio lib ) . Besides this issue with setenv(), nagios very well handles "gigantic" performance output. We use "graphios", to send this data to graphite ( few thousends metrics in single nagios chceck ). It working nicely.

--
Kind Regards
Marek Grzybowski

Re: Unlimited setenv() breaks large output plugins.

Posted: Mon Apr 28, 2014 11:45 am
by abrist
Oh, my mistake - was pushing through a number of bug reports for plugins on Friday. I will open an internal bug report for core.
EDIT: Internal bug report submitted. Keep an eye on the next few core release changelogs. Cheers.

Re: Unlimited setenv() breaks large output plugins.

Posted: Mon Aug 03, 2015 11:33 am
by jfrickson
How large of an environment variable is causing the problem, and on what system? Linux and Solaris both have pretty big limits.

Re: Unlimited setenv() breaks large output plugins.

Posted: Mon Aug 03, 2015 11:45 am
by tmcdonald
I am going to close this thread since @tombo has not been online in quite some time. If this thread needs to be re-opened for any reason, feel free to PM me or another moderator.