In addition to its rich monitoring capabilities, Nagios has a very powerful alarm function. For the alarm, commonly used is nothing more than mail and SMS alarm two ways, this article is mainly written in Nagios Mail alarm work.
Configuration of mail Alerts
We just need to edit the Contact.cfg file under/usr/local/nagios/etc/object and add the admin's mailbox after email. In general, if the Monitoring Project division is not too thin, the administrator can be responsible for all monitoring, and processing it, you can directly write one or more of the administrator's e-mail address, using a space or comma separated.
However, if the monitoring content of the server has a separate administrator, the network has a separate administrator, we can define multiple contacts (contact), and then use Contactgroup (Contact Group) to group the contacts.
For example, there are two people who manage the network, there are two people on the Management server, we can define two Contactgroup, then define the contact of four administrators, the following example is the contact.cfg that I am currently using, the server administrator has two, the network administrator has two
Configuration of the Contact.cfg
Define Contact{
Contact_Name zhang1
Use Generic-contact
Alias Zhang1
Service_notification_period 24x7
Host_notification_period 24x7
Service_notification_options W,u,c,r
Host_notification_options D,u,r
Service_notification_commands Notify-service-by-email
Host_notification_commands Notify-host-by-email
Email[email protected]
}
Define Contact{
Contact_Name zhang2
Use Generic-contact
Alias Zhang2
Service_notification_period 24x7
Host_notification_period 24x7
Service_notification_options W,u,c,r
Host_notification_options D,u,r
Service_notification_commands Notify-service-by-email
Host_notification_commands Notify-host-by-email
Email[email protected]
}
Define Contact{
Contact_Name Li1
Use Generic-contact
Alias Li1
Service_notification_period 24x7
Host_notification_period 24x7
Service_notification_options W,u,c,r
Host_notification_options D,u,r
Service_notification_commands Notify-service-by-email
Host_notification_commands Notify-host-by-email
Email[email protected]
}
Define Contact{
Contact_Name Li2
Use Generic-contact
Alias Li2
Service_notification_period 24x7
Host_notification_period 24x7
Service_notification_options W,u,c,r
Host_notification_options D,u,r
Service_notification_commands Notify-service-by-email
Host_notification_commands Notify-host-by-email
Email[email protected]
}
define contactgroup{
contactgroup_name network
alias network
members zhang1,zhang2
}
Define Contactgroup{
Contactgroup_name system
Alias system
Members Li1,li2
}
Note:
1, in the Commands.cfg file to define the command to send the message (the default is present)
2. Add contact information and intervals for notifications in hosts.cfg and services.cfg files.
3. Nagios uses a local mail server to send mail (SendMail or postfix), just make sure that sendmail or postfix is up.
Nagios sends alerts via email