Not able to call custom variables from bash script
Posted: Tue Jan 12, 2021 4:17 pm
I'm running Nagios XI 5.7.3 and I'm struggling trying to get custom variables to pass to the check script via the environment variables.
In short:
- nagios.cfg contains "enable_environment_macros=1"
- Service check contains a free variable "_TEST" with value "Test123"
- check calls a bash script that executes "echo $NAGIOS_SERVICETESTVAR"
- Service detail reads "NAGIOS_SERVICETESTVAR="
I added "( set -o posix ; set ) > /tmp/vars-test.txt" to output the variables from the session and don't see any of the Nagios variables in there.
I have a bunch of templates that feed variables up to hosts and services and we noticed that they apparently stopped working some time ago (I have no idea when since the checks were just passing), but it was before the 5.7 upgrade as well as before implementing mod-gearman for distributed monitoring, so I don't know if either of those changed how this would work or if there's something else I'm overlooking.
Thanks!
Scott
In short:
- nagios.cfg contains "enable_environment_macros=1"
- Service check contains a free variable "_TEST" with value "Test123"
- check calls a bash script that executes "echo $NAGIOS_SERVICETESTVAR"
- Service detail reads "NAGIOS_SERVICETESTVAR="
I added "( set -o posix ; set ) > /tmp/vars-test.txt" to output the variables from the session and don't see any of the Nagios variables in there.
I have a bunch of templates that feed variables up to hosts and services and we noticed that they apparently stopped working some time ago (I have no idea when since the checks were just passing), but it was before the 5.7 upgrade as well as before implementing mod-gearman for distributed monitoring, so I don't know if either of those changed how this would work or if there's something else I'm overlooking.
Thanks!
Scott