Nagios and Environment Variables


I’m running Nagios 3.0.3 on Scientific Linux 5.2
I have a problem when the server running nagios is rebooted, the environment variables that nagios has when executing plugins does not load any of my env variables (ie JAVA_HOME, CATALINA_HOME), breaking several of my plugins; However, if i restart nagios from the command line as root using “/etc/init.d/nagios restart” all my environment variables get loaded properly and the plugins that try to use them work normally.

Could someone please explain why this is happening and how to fix it so my environment variables get loaded properly after a reboot?

Thank you,
Michael Paterson


i’ve found a temporary fix to this problem by changing the /etc/init.d/nagios script to run /etc/profile before starting nagios

                echo -n "Starting nagios:"
                $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
                if  $? -eq 0 ]; then
                        source /etc/profile # added this line
                        su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"

still looking for a better solution / reason why this is happening

Michael P.


From where do you try to load env variables when the server restarts? Where are those variables defined. Are they in /etc/init.d /nagios script?

Have you done update-rc.d properly?