溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

關(guān)于nagios 郵件報(bào)警問題

發(fā)布時(shí)間:2020-10-08 18:49:20 來源:網(wǎng)絡(luò) 閱讀:332 作者:685436a 欄目:移動(dòng)開發(fā)

使用郵件報(bào)警

1、我安裝了sendemail,并測(cè)試發(fā)送郵件成功

2、修改command.cfg

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

define command{

command_name notify-host-by-email

command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -f zx@zx.com -t $CONTACTEMAIL$ -s 192.168.1.88 -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -xu zx@zx.com -xp 123456

}

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

define command{

command_name notify-service-by-email

command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/sendemail -f zx@zx.com -t $CONTACTEMAIL$ -s 192.168.1.88 -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu zx@zx.com -xp 123456

 

3、templates.cfg模版我使用的通用服務(wù)的設(shè)置

define service{

        name                            generic-service  ; The 'name' of this service template

        active_checks_enabled           1        ; Active service checks are enabled

        passive_checks_enabled          1         ; Passive service checks are enabled/accepted

        parallelize_check               1        ; Active service checks should be parallelized (disabling this can lead to major performance problems)

        obsess_over_service             1        ; We should obsess over this service (if necessary)

        check_freshness                 0        ; Default is to NOT check service 'freshness'

        notifications_enabled           1        ; Service notifications are enabled

        event_handler_enabled           1        ; Service event handler is enabled

        flap_detection_enabled          0        ; Flap detection is enabled

        failure_prediction_enabled      1        ; Failure prediction is enabled

        process_perf_data               1        ; Process performance data

        retain_status_information       1        ; Retain status information across program restarts

        retain_nonstatus_information    1        ; Retain non-status information across program restarts

        is_volatile                     0        ; The service is not volatile

        check_period                    24x7 ; The service can be checked at any time of the day

        max_check_attempts              1 ; Re-check the service up to 3 times in order to determine its final (hard) state

        normal_check_interval           2 ; Check the service every 10 minutes under normal conditions

        retry_check_interval            2 ; Re-check the service every two minutes until a hard state can be determined

        contact_groups                  admins ; Notifications get sent out to everyone in the 'admins' group

notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events

        notification_interval           10 ; Re-notify about service problems every hour

        notification_period             24x7 ; Notifications can be sent out at any time

         register                        0        ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!

        }

 

4、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                           zqy@zx.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

        }

###############################################################################

###############################################################################

#

# CONTACT GROUPS

#

###############################################################################

###############################################################################

# We only have one contact in this simple configuration file, so there is

# no need to create more than one contact group.

define contactgroup{

        contactgroup_name       admins

        alias                   Nagios Administrators

        members                 nagiosadmin

        }

 

5、nagios剛做好,把遠(yuǎn)程主機(jī)給關(guān)閉,發(fā)現(xiàn)服務(wù)全部都收到郵件報(bào)警,再開機(jī),發(fā)現(xiàn)報(bào)OK的郵件(所有service加上一個(gè)主機(jī)都正常)

但是我想再關(guān)機(jī)進(jìn)行測(cè)試的時(shí)候,就發(fā)現(xiàn)不報(bào)警了,只有一個(gè)service報(bào)警郵件。這到底是怎么回事呢,如果要是模版里面進(jìn)行設(shè)置的,那我要修改什么才能達(dá)到每次開關(guān)都報(bào)警,不管頻率有多頻繁。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI