Page 2 of 3
Re: Issues with setting up alerting
Posted: Thu Jan 20, 2011 5:48 pm
by dbsaust
Sorry crossed wires here, could you point me in the direction of any documentation you have on configuring pager alerts and using multiple email address on the contact page
Nagios.png
Re: Issues with setting up alerting
Posted: Fri Jan 21, 2011 10:27 am
by rdedon
Re: Issues with setting up alerting
Posted: Sun Jan 23, 2011 6:36 pm
by dbsaust
I do need help, still looking for an answer in my last post??, I have already read through all of your documentation, but it does not go into any detail how to configure contacts, so alerts go to multiple addresses ie.
I want one alert to go to $CONTACTEMAIL$
whilst also sending to $CONTACTPAGER$
and another going to $CONTACTADDRESS1$
and another going to $CONTACTADDRESS2$
the help button states 'Depending on how you configure your notification commands' but i can not locate any reference to where i need to input these parameters?
Re: Issues with setting up alerting
Posted: Mon Jan 24, 2011 11:16 am
by rdedon
Okay, your setup is a bit more customized than the general documentation can provide help with.
-Log into CCM and go to Commands on the left.
-Go to page 5
-Edit xi_host_notification_handler
-in the command line field add another macro like --contactemail="$CONTACTEMAIL$"
Re: Issues with setting up alerting
Posted: Mon Jan 24, 2011 8:14 pm
by dbsaust
Ok, thanks for confirming all this. It looks like i have been on the right track, yet alerting is still only going to user contact details and not to the contact contact details.
This might be a long post but i need to explain clearly the steps i have done to get this working. *FYI all these steps were performed using the front end web portal.
1) user created DanC with email address [email protected] Auth level = User (Read only access)
2) contacts updated to reflect the following
Code: Select all
define contact {
contact_name DanC
alias Dan Carpenter
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period DanC_notification_times
service_notification_period DanC_notification_times
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f,s
host_notification_commands xi_host_notification_handler
service_notification_commands xi_service_notification_handler
email [email protected]
pager [email protected]
address1 [email protected]
address2 [email protected]
host_notifications_enabled 1
service_notifications_enabled 1
use xi_contact_generic
}
3) DanC_notification_times set to
Code: Select all
define timeperiod {
timeperiod_name DanC_notification_times
alias Notification Times for DanC
tuesday 00:00-24:00
monday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
sunday 00:00-24:00
}
4) xi_host_notification_handler set to
Code: Select all
define command {
command_name xi_host_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --contactemail="$CONTACTPAGER$" --contactemail="$CONTACTADDRESS1$" --contactemail=$"CONTACTADDRESS2$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
}
5) Contact added to Infrastructure contact group
Code: Select all
define contactgroup {
contactgroup_name Infrastructure
alias Infrastructure
members DanC
}
6) Infrastructure contact group added to Host AAAATEST
Code: Select all
define host {
host_name AAAATEST
use xiwizard_windowsdesktop_host
address 10.215.193.143
hostgroups Test
max_check_attempts 1
check_interval 1
retry_interval 1
contacts null
contact_groups Infrastructure
notification_interval 60
notification_period 24x7
first_notification_delay 0
notification_options d,u,r,f,s
notifications_enabled 1
icon_image windowsxp.png
statusmap_image windowsxp.png
_xiwizard windowsdesktop
register 1
}
7) via portal go to Host Status Detail >> AAAATEST >>> Advanced >> Send Custom notification > *forced *Broadcast >> commit
Log file shows
Host Service Type Time Contact Notification Command Information
AAAATEST N/A CUSTOM (UP) 01-25-2011 12:10:45 DanC xi_host_notification_handler OK - 10.215.193.143: rta 35.069ms, lost 0%
8) Result
only one email received at
[email protected]
Please if you have time to review all of this, can you see if something is wrong, because it all looks to me like it should work?
Re: Issues with setting up alerting
Posted: Tue Jan 25, 2011 11:13 am
by mguthrie
The contact definitions look right, but I think the issue is with the command definition. Bear with this as we're testing this ourselves. Most users use the XI email and SMS alerts through the user account settings. Try the following:
define command {
command_name xi_host_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --contactpager="$CONTACTPAGER$" --contactaddress1="$CONTACTADDRESS1$" --contactaddress2=$"CONTACTADDRESS2$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
}
Re: Issues with setting up alerting
Posted: Wed Jan 26, 2011 6:40 pm
by dbsaust
Hi, i have corrected the code in the command as you have suggested, but still not notifications.
I would have also like to have used your SMS settings from the User management, but it appears to only cater for USA carrier's and we are based in NSW Australia.
I can't understand why such a basic customisation for using contacts is not working? Am I the only client to use Nagios contacts? surly not.
Re: Issues with setting up alerting
Posted: Thu Jan 27, 2011 11:12 am
by mguthrie
Ok, so after some discussion with our lead developer, it sounds like XI has essentially hijacked the contact/notification system in order to allow use of the user management features of XI and allow for things like SMS alerts and RSS notifications. What that means is that the fields we've been attempting to add addresses to are basically being ignored by the xi_notification_handler. My apologies for this, I just found this out myself.
I'll run a few tests and see if I can figure out a way around this for the multiple emails, for now, use what you can from the XI user management/notification preferences pages.
For the pager/SMS alerts, the new version of XI coming out within the next couple of days will allow you to define custom carriers for SMS alerts, so that should take care of the pager number.
Re: Issues with setting up alerting
Posted: Thu Jan 27, 2011 12:26 pm
by mguthrie
I did run a test where I added the "notifiy-host-by-email" command in addition to the "xi_host_notification_handler" command, and I was able to get the notification to send to multiple addresses, as well as an SMS alert.
To recreate what I did:
-Create your contact in XI, enabled their notifications and notify by email settings in XI
-Go to the Core Config Manager and add the
notifiy-host-by-email in addition to the
xi_host_notification_handler
-Do the same with the service event commands as well if desired.
-Add your additional addresses to the email fields.
-For the SMS address use an email address field and format your address to it sends the SMS to your mobile carriers SMS gateway. Example: <number>@tmomail.net for T-Mobile.
- As I mentioned before:
For the pager/SMS alerts, the new version of XI coming out within the next couple of days will allow you to define custom carriers for SMS alerts, so that should take care of the pager number.
Re: Issues with setting up alerting
Posted: Fri Jan 28, 2011 12:39 am
by dbsaust
This has still not worked for me, could you advise if your commands looked like this
xi_host_notification_handler
Code: Select all
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --contactpager="$CONTACTPAGER$" --contactaddress1="$CONTACTADDRESS1$" --contactaddress2="$CONTACTADDRESS2$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
notify-host-by-email
Code: Select all
/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$