Unlimited setenv() breaks large output plugins.
Posted: Fri Apr 25, 2014 12:42 pm
Hi
Process env is limited. When nagios try to run check that had large perfdata and output in previous run , it will fail with :
System cannot run shell command, when env is filled.
My dirty solution to this problem is ( base/utils.c ) in set_environment_var () :
--
Kind regards
Marek Grzybowski
Process env is limited. When nagios try to run check that had large perfdata and output in previous run , it will fail with :
Fail will happen every second check run.Warning: Return code of 127 for check of service 'xxxx' on host 'yyyy' was out of bounds.
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