Currently Nagios can only view the state of each machine's services on a browser, and when a machine goes down or a service goes down, we don't know because we can't stare at the service at all times. At this point, you need to use the alarm system, let it automation, when the problem is found in time to notify us. The following configuration uses e-mail to implement the alarm.
operate on the service side!
The message recipient is defined first.
[[email protected] ~]# vim /etc/nagios/objects/contacts.cfgdefine contact{ contact_name test1 use generic-contact alias email1 email [ Email protected]}define contact{ contact_name test2 use generic-contact alias email2 email [email protected]}define contactgroup{ contactgroup_name common alias common members            TEST1,TEST2}
Description: Contact.cfg can define either user or group, define two user test1 and Test2, and then add the two user to the common group. e-mail will be sent to the common group, then [email protected] and [email protected] will receive mail.
Then add Contactgroup to the service that needs to be alerted.
[Email protected] ~]# vim/etc/nagios/conf.d/192.168.56.128.cfg
Increased alarm configuration for check_load services
define service{ use generic-service host_name 192.168.56.128 service_description check_load check_ Command check_nrpe!check_load max_check_attempts 5 normal_check_interval 1 contact_groups common notifications_enabled 1 notification_period  24X7   NOTIFICATION_OPTIONS  W,U,C,R}
Description: notifications_enabled 1 Indicates whether the alert function is turned on. 1 is on, 0 is disabled. In general, this option is defined in the main configuration file (Nagios.cfg), with the same effect. Notification_period 24x7 Indicates the time period when reminders are sent. If you are not within the defined time period, no reminders will be sent for any issues. Notification_options:w,u,c,r represents the status of the service. W is warning,u for unknown,c and critical,r for recovery. Similarly, there is a status of host: D,u,r,f,n. The D status indicates that the down,u for the Unreachable,r state reverts to ok,f for Flapping,n to not send reminders. Need to be added to the host's defined configuration to take effect.
After editing the configuration file, restart the Nagios service
[Email protected] ~]# service nagios restartrunning configuration Check...done. Stopping Nagios:done. Starting Nagios:done.
This article is from the "Learn Notes for students" blog, please make sure to keep this source http://sanyisheng.blog.51cto.com/11154168/1795726
2.3 Nagios Configuring message Alarms