Hello all,
I wonder how I could send an alert for a dead device, but to two different emails, depending on what time it is during the day. Example: If it is during the normal office hours the alert is sent to [email protected] and if it is during the night the email is sent to [email protected].
Is this possible, if not do you have any methods to suggest?
Best regards,
Host down - Different email notifications
Re: Host down - Different email notifications
Nagios supports something called a Time Period to control when alerts are sent. Think of it like a "quiet hours" setting.
1. Create two time periods using Core Config Manager (CCM) => Time Periods, one called office_hours and one called out_of_office_hours, inserting time ranges for each to define them. Make sure that together they cover the whole day.
2. Create two Contacts in your system, one for the day (I'll refer to this one as [email protected]), and one for the night ([email protected]).
3. On the Alert Settings tab for [email protected], set the Host/Service Notification Time Periods to office_hours.
4. On the Alert Settings tab for [email protected], set the Host/Service Notification Time Periods to out_of_office_hours.
5. Create a new Contact Group called office team. Add both [email protected] and [email protected] to the contact group.
Now you can assign the contact group wherever you were previously assigning contacts.
-OR-
For added flexibility, you could also assign one or the other to each host/service. For instance, if you didn't care that the office mail server was down at night, you could forego assigning the contact group, and just assign [email protected].
Note: The labels I used here are arbitrary. You could name them whatever you want as long as they're consistent.
1. Create two time periods using Core Config Manager (CCM) => Time Periods, one called office_hours and one called out_of_office_hours, inserting time ranges for each to define them. Make sure that together they cover the whole day.
2. Create two Contacts in your system, one for the day (I'll refer to this one as [email protected]), and one for the night ([email protected]).
3. On the Alert Settings tab for [email protected], set the Host/Service Notification Time Periods to office_hours.
4. On the Alert Settings tab for [email protected], set the Host/Service Notification Time Periods to out_of_office_hours.
5. Create a new Contact Group called office team. Add both [email protected] and [email protected] to the contact group.
Now you can assign the contact group wherever you were previously assigning contacts.
-OR-
For added flexibility, you could also assign one or the other to each host/service. For instance, if you didn't care that the office mail server was down at night, you could forego assigning the contact group, and just assign [email protected].
Note: The labels I used here are arbitrary. You could name them whatever you want as long as they're consistent.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Re: Host down - Different email notifications
Hello dchurch,
Thank you for your nice and clear reply. To let you know, I'm still unable to send email alert to my "contact" but I was able to send ones to a new "User" I've created with notification settings. I'll have to test more if my time schedule works and stuff.
Regards,
Thank you for your nice and clear reply. To let you know, I'm still unable to send email alert to my "contact" but I was able to send ones to a new "User" I've created with notification settings. I'll have to test more if my time schedule works and stuff.
Regards,
Re: Host down - Different email notifications
When you update the notification settings, you need to "deploy" them to the contacts using the Email Settings page, or it's not going to use them when sending notifications.
Also in CCM, under the Conact's edit page, under Alerts, check that the Host Notification command has xi_host_event_handler in the list and the Service Notification command is set to xi_service_event_handler.
Also in CCM, under the Conact's edit page, under Alerts, check that the Host Notification command has xi_host_event_handler in the list and the Service Notification command is set to xi_service_event_handler.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Re: Host down - Different email notifications
Hello dchurch,
What do you mean by: "you need to "deploy" them to the contacts using the Email Settings page"
I went on the page in Admin->Email Settings but there's no option to assign or deploy, only a Send a Test Email
Still no luck to send email notification/alertes with Contact, I'll try to compare all setting between Contact and local account to find where it's different.
Take care,
What do you mean by: "you need to "deploy" them to the contacts using the Email Settings page"
I went on the page in Admin->Email Settings but there's no option to assign or deploy, only a Send a Test Email
Still no luck to send email notification/alertes with Contact, I'll try to compare all setting between Contact and local account to find where it's different.
Take care,
Re: Host down - Different email notifications
Is there a file config I could show you?
Maybe I failed in one settings somewhere lol ?
Maybe I failed in one settings somewhere lol ?
Re: Host down - Different email notifications
Do you see the notification for both contacts listed in Home > Notifications? Is the Dispatcher column the same? What are they both set to?
Please follow these instructions:
Please go to Admin > Manage Email Settings:
- Make sure Logging is checked
- Click the Update Settings button
Then run this tail command (and leave it running):
Then force a notification to be sent then send me the full output of the tail command above and any errors you see on the screen (please test via the instructions at the bottom exactly, don't use the Send a Test Email button as it's different).
After you've done the steps above attach a FRESH copy of your profile, you can download it from Admin > System Profile > Download Profile.
PM me the name of the contact that's having issues as well.
How to submit passive results for testing:
For Hosts
------------
Go to Home > Host Status:
- Find the Host and click on it
- Click the + tab
- Click the "Submit passive check result" link
- Select the Check Result and type in some text for the Check Output
- Click the Submit button
NOTE: By default, passive_host_checks_are_soft=0 is set in your /usr/local/nagios/etc/nagios.cfg, this differs from services in that when you submit a passive host check result it immeditely goes into a HARD state (and should send a notification if configured to) instead of going into a SOFT state like services do. (notifications are only sent on HARD states).
For Services
----------------
Go to Home > Service Status:
- Find the Service and click on it
- Click the + tab
- Note these two rows:
State Type: Hard
Current Check: 1 of 4
Those columns tell the current State Type and the Current Check number. In order to generate a notification for a service you will need to submit MULTIPLE problem check results (the number that you need to submit is determined by the last number in the Current Check column, that is the max_check_attempts setting). For services, when you submit a passive check result, each result that you submit will be a SOFT state until you submit enough to hit the Max Check Attempts setting that you've defined on the service, only then will the service enter a HARD problem state which will generate the notification (just remember, notifications are only sent on HARD states).
- Click the "Submit passive check result" link
- Select the Check Result and type in some text for the Check Output
- Click the Submit button
- Submit as many as you need, right after another, until the service enters the HARD state so that a notification will be sent
NOTE: When coming from a HARD problem state (whether we are talking about hosts or services) if you submit an OK passive result it should fire off a recovery notification after a single passive result has been submitted.
Please follow these instructions:
Please go to Admin > Manage Email Settings:
- Make sure Logging is checked
- Click the Update Settings button
Then run this tail command (and leave it running):
Code: Select all
tail -Fn0 /var/log/maillog /usr/local/nagiosxi/tmp/phpmailer.log /usr/local/nagiosxi/var/eventman.logAfter you've done the steps above attach a FRESH copy of your profile, you can download it from Admin > System Profile > Download Profile.
PM me the name of the contact that's having issues as well.
How to submit passive results for testing:
For Hosts
------------
Go to Home > Host Status:
- Find the Host and click on it
- Click the + tab
- Click the "Submit passive check result" link
- Select the Check Result and type in some text for the Check Output
- Click the Submit button
NOTE: By default, passive_host_checks_are_soft=0 is set in your /usr/local/nagios/etc/nagios.cfg, this differs from services in that when you submit a passive host check result it immeditely goes into a HARD state (and should send a notification if configured to) instead of going into a SOFT state like services do. (notifications are only sent on HARD states).
For Services
----------------
Go to Home > Service Status:
- Find the Service and click on it
- Click the + tab
- Note these two rows:
State Type: Hard
Current Check: 1 of 4
Those columns tell the current State Type and the Current Check number. In order to generate a notification for a service you will need to submit MULTIPLE problem check results (the number that you need to submit is determined by the last number in the Current Check column, that is the max_check_attempts setting). For services, when you submit a passive check result, each result that you submit will be a SOFT state until you submit enough to hit the Max Check Attempts setting that you've defined on the service, only then will the service enter a HARD problem state which will generate the notification (just remember, notifications are only sent on HARD states).
- Click the "Submit passive check result" link
- Select the Check Result and type in some text for the Check Output
- Click the Submit button
- Submit as many as you need, right after another, until the service enters the HARD state so that a notification will be sent
NOTE: When coming from a HARD problem state (whether we are talking about hosts or services) if you submit an OK passive result it should fire off a recovery notification after a single passive result has been submitted.
Re: Host down - Different email notifications
Hey Ssax,
Just tried to send you the result in PM, but the message wont' go out of my Outbox lol. I'll wait a bit and maybe just paste teh result here instead.
Cheers!
Just tried to send you the result in PM, but the message wont' go out of my Outbox lol. I'll wait a bit and maybe just paste teh result here instead.
Cheers!
Re: Host down - Different email notifications
The PM that says the profile is attached doesn't have the profile attached, please attach it when you get a chance as I'll need it to understand your setup.
Re: Host down - Different email notifications
Hello Ssax,
Did I manage to send you the file? I don't see the message in my Outbox,
Just checking
Regards,
Did I manage to send you the file? I don't see the message in my Outbox,
Just checking
Regards,