nagios郵件報警設置

1、下載 sendEmail

   wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

2、配置 sendEmail

   tar zxvf sendEmail-v1.56.tar.gz

   cd sendEmail-v1.56

   cp sendEmail /usr/local/bin

   chmod 777 /usr/local/bin/sendEmail

   發送測試郵件

   /usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.126.com -xu [email protected] -xp password -u "nagios" -m "tets"
解釋:
-f表示發送者的郵箱
-t表示接收者的郵箱
-s表示SMTP服務器的域名或者ip
-u表示郵件的主題
-xu表示SMTP驗證的用戶名
-xp表示SMTP驗證的密碼
-m表示郵件的內容

3、配置contacts.cfg

vi /usr/local/nagios/etc/objects/contacts.cfg  輸入接收報警郵箱地址

  

define contact{

        contact_name                    nagiosadmin             ; Short name of user

        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)

        alias                           Nagios Admin            ; Full name of user

        email                           [email protected]   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

        }

4、配置commands.cfg

vi /usr/local/nagios/etc/objects/commands.cfg

註解# 'notify-host-by-email' command definition 與# 'notify-service-by-email' command definition下所有的設置

重新輸入以下內容

 

# 'notify-host-by-email' command definition

define command{

       command_name    notify-host-by-email

       command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu [email protected] -xp password -o message-charset=utf8

       }

# 'notify-service-by-email' command definition

define command{

       command_name    notify-service-by-email

  command_line    /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu [email protected] -xp password -o message-charset=utf8

       }

5、重啓服務

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章