2013年12月28日 星期六

Nagios notify by gmail

# cd /usr/lib/nagios/plugins
# wget  http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3489&cf_id=24 -O  send_gmail.py
# vi send_gmail.py
# change to your username and password
# vi /etc/nagios3/conf.d/contacts_nagios2.cfg
define contact{
        contact_name                    root
        alias                           Root
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
       email                           YOUR_EMAIL_ADDRESS
# vi /etc/nagios3/commands.cfg
# comment old 'notify-host-by-email' and 'notify-service-by-email' command line and add follows
# *)notify-host-by-email

command_line /usr/bin/python /usr/lib/nagios/plugins/send_gmail.py -a $CONTACTEMAIL$ -b "***** Nagios *****\nnn\nnnNotification Type: $NOTIFICATIONTYPE$\nnnHost: $HOSTNAME$\nnnState: $HOSTSTATE$\nnnAddress: $HOSTADDRESS$\nnnInfo: $HOSTOUTPUT$\nnnDate/Time: $LONGDATETIME$" -s "** Nagios $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"

#notify-service-by-email

command_line /usr/bin/python /usr/lib/nagios/plugins/send_gmail.py -a $CONTACTEMAIL$ -b "***** Nagios *****\nnn\nnnNotification Type: $NOTIFICATIONTYPE$\nnnService: $SERVICEDESC$\nnnHost: $HOSTALIAS$\nnnAddress: $HOSTADDRESS$\nnnState: $SERVICESTATE$\nnnDate/Time: $LONGDATETIME$\nnnAdditional Info: $SERVICEOUTPUT$" -s "** Nagios $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" 



References :
Nagios Alerts via gmail and python - Nagios Exchange
4 Steps to Define Nagios Contacts With Email and Pager Notification

沒有留言:

張貼留言