關于nagios郵件報警問題-創(chuàng)新互聯(lián)

使用郵件報警

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比昭平網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式昭平網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋昭平地區(qū)。費用合理售后完善,10多年實體公司更值得信賴。

1、我安裝了sendemail,并測試發(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模版我使用的通用服務的設置

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剛做好,把遠程主機給關閉,發(fā)現(xiàn)服務全部都收到郵件報警,再開機,發(fā)現(xiàn)報OK的郵件(所有service加上一個主機都正常)

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

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章題目:關于nagios郵件報警問題-創(chuàng)新互聯(lián)
轉載注明:http://muchs.cn/article28/cosojp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供虛擬主機、營銷型網(wǎng)站建設、域名注冊服務器托管、網(wǎng)站維護、自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設