Custom Variables not working

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cockraml
Posts: 28
Joined: Tue May 07, 2013 8:10 am

Custom Variables not working

Post by cockraml »

I can't get custom variables working with a new nagios XI install. I put a test plugin out to make sure it wasn't my plugin. I defined my custom variables in my host template. This works for our nagios core installation, but not nagios xi. Any help would be appreciated.

From objects.cache:

Code: Select all

define host {
	host_name	myhost
	alias	myhost
        ...
        _OS_TYPE	Solaris
	_POC_GROUP	Unix Team
	}
I have the below test plugin running for myhost:

Code: Select all

#!/bin/bash

if [ "1" ]; then
env
echo
echo $NAGIOS_HOSTOS_TYPE

echo "DONE"
date

fi > /tmp/test.bash.txt 2>&1


exit 0



output of /tmp/test.bash.txt:

Code: Select all

TERM=linux
PATH=/sbin:/usr/sbin:/bin:/usr/bin
RUNLEVEL=3
runlevel=3
PWD=/
LANGSH_SOURCED=1
LANG=en_US.UTF-8
PREVLEVEL=N
previous=N
CONSOLETYPE=vt
SHLVL=4
UPSTART_INSTANCE=
UPSTART_EVENTS=runlevel
UPSTART_JOB=rc
_=/bin/env


DONE
Mon May 20 15:11:37 EDT 2013
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Custom Variables not working

Post by sreinhardt »

I certainly could be incorrect, please do link me to documentation if I am, but I don't believe that is possible. By default Nagios should not export all variables to the env variable for OS use, they are instead used internally with the program and passed to the scripts via defined commands or handlers. These variables are then expanded before exec-ing the full command. You could certainly define your check to send the $_OS_TYPES$ variable and have your script accept and use that.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
cockraml
Posts: 28
Joined: Tue May 07, 2013 8:10 am

Re: Custom Variables not working

Post by cockraml »

Thanks. I figured it out. I had to change the below in nagios.cfg
enable_environment_macros=1
Locked