Unlimited setenv() breaks large output plugins.

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
tombo
Posts: 2
Joined: Fri Apr 25, 2014 12:23 pm

Unlimited setenv() breaks large output plugins.

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Unlimited setenv() breaks large output plugins.

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
tombo
Posts: 2
Joined: Fri Apr 25, 2014 12:23 pm

Re: Unlimited setenv() breaks large output plugins.

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Unlimited setenv() breaks large output plugins.

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jfrickson

Re: Unlimited setenv() breaks large output plugins.

Post by jfrickson »

How large of an environment variable is causing the problem, and on what system? Linux and Solaris both have pretty big limits.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Unlimited setenv() breaks large output plugins.

Post 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.
Former Nagios employee
Locked