This support forum board is for support questions relating to
Nagios XI , our flagship commercial network monitoring solution.
bosecorp
Posts: 929 Joined: Thu Jun 26, 2014 1:00 pm
Post
by bosecorp » Fri Oct 14, 2016 7:25 am
Hi
I am trying to do couple things.
I want to switch from using the phone number on the user to the "Addon Address 1"field in the contact.
Code: Select all
echo "$HOSTOUTPUT$" | grep -v "orphan" >/dev/null && /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
the second thing I am trying to do is create another notification handler so only uses the "Email Address" field in the contact. using again the command below
Code: Select all
echo "$HOSTOUTPUT$" | grep -v "orphan" >/dev/null && /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
Last edited by
rkennedy on Mon Oct 24, 2016 11:43 am, edited 2 times in total.
Reason: code block
lmiltchev
Bugs find me
Posts: 13589 Joined: Mon May 23, 2011 12:15 pm
Post
by lmiltchev » Fri Oct 14, 2016 9:57 am
In addition to the $CONTACTEMAIL$ macro, you should have $CONTACTADDRESSx$ macro in your command ($CONTACTADDRESS1$, $CONTACTADDRESS2$, ...). See our Nagios Core documentation on the topic.
addressx: Address directives are used to define additional "addresses" for the contact. These addresses can be anything - cell phone numbers, instant messaging addresses, etc. Depending on how you configure your notification commands, they can be used to send out an alert to the contact. Up to six addresses can be defined using these directives (address1 through address6). The $CONTACTADDRESSx$ macro will contain this value.
https://assets.nagios.com/downloads/nag ... ml#contact
Example:
define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ $CONTACTADDRESS1$
}
Let us know if this helped.
Be sure to check out our
Knowledgebase for helpful articles and solutions!
bosecorp
Posts: 929 Joined: Thu Jun 26, 2014 1:00 pm
Post
by bosecorp » Fri Oct 14, 2016 1:28 pm
So, will it be something like this
Code: Select all
echo "$HOSTOUTPUT$" | grep -v "orphan" >/dev/null && /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$,$CONTACTADDRESS1$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
should I put coma or spaces between. that is the part wasn't clear to me with reading the documentation
Last edited by
dwhitfield on Fri Oct 14, 2016 1:58 pm, edited 1 time in total.
Reason: code block
ssax
Dreams In Code
Posts: 7682 Joined: Wed Feb 11, 2015 12:54 pm
Post
by ssax » Fri Oct 14, 2016 2:10 pm
They should be comma separated as you have, is that not working for you?
bosecorp
Posts: 929 Joined: Thu Jun 26, 2014 1:00 pm
Post
by bosecorp » Fri Oct 14, 2016 2:12 pm
I want to make sure before I put this into production. because the syntax isn't; clear on the documentation
bosecorp
Posts: 929 Joined: Thu Jun 26, 2014 1:00 pm
Post
by bosecorp » Fri Oct 14, 2016 3:16 pm
I tried and looks like didn't work.
are these contacts required to have a user?
ssax
Dreams In Code
Posts: 7682 Joined: Wed Feb 11, 2015 12:54 pm
Post
by ssax » Mon Oct 17, 2016 9:43 am
Yes, in order to use the XI notification handlers they need to have an associated user.
I took a look at the code though and it seems that the XI notification handlers don't currently support it, the way it works now is to pull the email address from the user and it will ignore the contactemail information passed into the command.
bosecorp
Posts: 929 Joined: Thu Jun 26, 2014 1:00 pm
Post
by bosecorp » Sun Oct 23, 2016 4:43 pm
I figured it out. I am found another notification handler that uses only the contact fields
thanks a lot. you can close the ticket
rkennedy
Posts: 6579 Joined: Mon Oct 05, 2015 11:45 am
Post
by rkennedy » Mon Oct 24, 2016 11:42 am
Awesome, will close it out.
/close
Former Nagios Employee