Custom variable apear to not be working in commands

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cloberjewels
Posts: 23
Joined: Wed Sep 21, 2011 10:59 am

Custom variable apear to not be working in commands

Post by cloberjewels »

Hi,

I'm running Nagios XI 2011R3.2

I have a Service Template called unix-service with a custom variable: _from_address = nagiosunix
I have a Service called check_cpu that checks for high cpu usage and it imports the Service Template unix-service.

I copied the notify-service-by-email creating notify-service-by-email-custom that includes the above custom variable:

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\n$_FROM_ADDRESS$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -- -f $_FROM_ADDRESS$

This would allow the FROM email address to be customized based on the custom variable. It would also display the output of the custom variable in the body of the email.

When check_cpu detects a warning or critical condition it sends an email but it doesn't appear the custom variable was passed to the command.

The from address is [email protected]

I was expecting: [email protected]

In the body of the email on the last line is just a $ too.

I read the section in the documentation on custom variables: http://nagios.sourceforge.net/docs/3_0/ ... tvars.html

Are custom variables support in commands?

Thanks,
Chris
cloberjewels
Posts: 23
Joined: Wed Sep 21, 2011 10:59 am

Re: Custom variable apear to not be working in commands

Post by cloberjewels »

Nevermind - figured it out. Custom variables are prepended with HOST or SERVICE so the custom variable is

$_SERVICEFROM_ADDRESS

in my case.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Custom variable apear to not be working in commands

Post by sreinhardt »

You are correct! Thanks for letting us know its working!
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.
Locked