内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

nagios的安裝及配置方法-創(chuàng)新互聯(lián)

這篇文章主要介紹“nagios的安裝及配置方法”,在日常操作中,相信很多人在nagios的安裝及配置方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”nagios的安裝及配置方法”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習吧!

成都創(chuàng)新互聯(lián)是一家專業(yè)提供遂溪企業(yè)網(wǎng)站建設(shè),專注與成都做網(wǎng)站、網(wǎng)站制作、H5響應(yīng)式網(wǎng)站、小程序制作等業(yè)務(wù)。10年已為遂溪眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進行中。

一、服務(wù)端安裝(主要監(jiān)控磁盤或系統(tǒng)負載,可以自定義腳本,不能查看歷史數(shù)據(jù))

1、配置好擴展源并安裝

yum install -y httpd nagios nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

2、設(shè)置登錄nagios后臺的用戶和密碼:

htpasswd -c /etc/nagios/passwd nagiosadmin

3、編輯配置文件


vim /etc/nagios/nagios.cfg

nagios -v /etc/nagios/nagios.cfg #檢測配置文件

4、啟動服務(wù)

啟動服務(wù):service httpd start; service nagios start

5、瀏覽器訪問: http://10.10.13.239/nagios

nagios管理員賬號:nagiosadmin密碼:abc.123


二、客戶端安裝

1、配置好擴展源后安裝

yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe

2、編輯配置文件

vim /etc/nagios/nrpe.cfg  找到“allowed_hosts=127.0.0.1” 改為 “allowed_hosts=127.0.0.1,10.10.13.239” 后面的ip為服務(wù)端ip; 找到” dont_blame_nrpe=0” 改為  “dont_blame_nrpe=1” 
啟動客戶端 /etc/init.d/nrpe start

3、服務(wù)端添加配置文件

cd /etc/nagios/conf.d/

vim 10.10.13.247.cfg


define host{


    use           linux-server

    host_name         10.10.13.247

    alias            13.247

    address          10.10.13.247

    }

define service{

    use           generic-service

    host_name         10.10.13.247

    service_description      check_ping

    check_command        check_ping!100.0,20%!200.0,50%

    max_check_attempts 5

    normal_check_interval 1

}

define service{

    use           generic-service

    host_name         10.10.13.247

    service_description      check_ssh

    check_command        check_ssh

    max_check_attempts      5   #當nagios檢測到問題時,一共嘗試檢測5次都有問題才會告警,如果該數(shù)值為1,那么檢測到問題立即告警

    normal_check_interval     1   #重新檢測的時間間隔,單位是分鐘,默認是3分鐘

    notification_interval     60   #在服務(wù)出現(xiàn)異常后,故障一直沒有解決,nagios再次對使用者發(fā)出通知的時間。單位是分鐘。如果你認為,>所有的事件只需要一次通知就夠了,可以把這里的選項設(shè)為0。

}

define service{

    use           generic-service

    host_name         10.10.13.247

    service_description      check_http

    check_command        check_http

    max_check_attempts      5

    normal_check_interval     1

}

#配置完檢測是否有錯

nagios -v /etc/nagios/nagios.cfg

4、客戶端上重啟一下nrpe服務(wù): service nrpe restart
服務(wù)端也重啟一下nagios服務(wù): service nagios restart

5、 刷新地址http://10.10.13.239/nagios看host和services已經(jīng)添加了相關(guān)項目

三、監(jiān)控客戶端的本地資源(需要借助于nrpe服務(wù))

1、服務(wù)端vim /etc/nagios/objects/commands.cfg
增加:define command{
      command_name  check_nrpe
      command_line  $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
      }
2、繼續(xù)編輯 vim /etc/nagios/conf.d/10.10.13.247.cfg 
增加如下內(nèi)容:define service{
      use    generic-service
      host_name    10.10.13.247
      service_description    check_load
      check_command        check_nrpe!check_load #可以在客戶端/etc/nagios/nrpe.cfg里面找到check_load腳本路徑
      max_check_attempts 5
      normal_check_interval 1
}


define service{
      use    generic-service
      host_name    10.10.13.247
      service_description    check_disk_sda1
      check_command        check_nrpe!check_hda1#可以在客戶端/etc/nagios/nrpe.cfg里面找到check_hda1腳本路徑
      max_check_attempts 5
      normal_check_interval 1
}

3、修改客戶端的nrpe配置文件

vim /etc/nagios/nrpe.cfg

修改command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1

改為command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1

4、重啟服務(wù)端的nagios和nrpe服務(wù)重啟客戶端的nrpe服務(wù)

[root@server ~]# /etc/init.d/nagios restart

[root@server ~]# /etc/init.d/nrpe restart

[root@client ~]# /etc/init.d/nrpe restart

5、刷新地址http://10.10.13.239/nagios看services已經(jīng)添加了一負載和硬盤使用量的監(jiān)控

四、添加郵件告警功能

1、編輯配置文件

vim /etc/nagios/objects/contacts.cfg

添加

define contact{                      #定義成員123
      contact_name        123
      use                    generic-contact
      alias                  river
      email       313841662@qq.com
      }


define contact{
      contact_name          456         #定義成員456
      use                    generic-contact
      alias                  aaa
      email       313841662@qq.com
      }


define contactgroup{                 #定義組,組成員為123,456
      contactgroup_name        common
      alias                      common
      members                  123,456
      }

2、然后在要需要告警的服務(wù)里面加上contactgroup

vim /etc/nagios/conf.d/10.10.13.247.cfg

define service{
      use    generic-service
      host_name    10.10.13.247
      service_description    check_load
      check_command        check_nrpe!check_load
      max_check_attempts 5
      normal_check_interval 1
      contact_groups      common
      notifications_enabled  1         ;是否開啟提醒功能。1為開啟,0為禁用。一般,這個選項會在主配置文件(nagios.cfg)中定義,效果相同。
      notification_period  24x7        ;發(fā)送提醒的時間段。非常重要的主機(服務(wù))我定義為7×24,一般的主機(服務(wù))就定義為上班時間。如果不在定義的時間段內(nèi),無論什么問題發(fā)生,都不會發(fā)送提醒。(時間格式為24x7不是24*7,如果寫成后者就會報錯)      
      notification_options w,u,c,r       ;這個是service的狀態(tài)。w為waning, u為unknown, c為critical, r為recover(恢復(fù)了),f為flapping,n為不發(fā)送提醒。類似的還有一個  host對應(yīng)的狀態(tài):d,u,r  d = 狀態(tài)為DOWN, u = 狀態(tài)為UNREACHABLE , r = 狀態(tài)恢復(fù)為OK,需要加入到host的定義配置里。(這一選項后面不能跟冒號跟冒號就會報錯,必須為空格)
}

#具體告警格式可以百度nagios 郵件告警

五、利用sendmail發(fā)送告警郵件

1.軟件檢測及安裝

#rpm -q sendmail

若不存在則安裝

#yum -y install sendmail

2.停止sendmail服務(wù)

這里不需要sendmail作為郵件服務(wù)端來運行,所以關(guān)閉sendmail服務(wù)。

#service sendmail stop

3.配置sendmail服務(wù)

配置發(fā)送郵件的郵箱認證信息

vi /etc/mail.rc

添加如下內(nèi)容:

set from=chenconghe@benco.com.cn

set smtp=mail.benco.com.cn

set smtp-auth-user=chenconghe

set smtp-auth-password=20160427150456

set smtp-auth=login

4.測試發(fā)送郵件功能

格式:echo "郵件內(nèi)容" | mail -s "郵件標題" 目標郵件地址

echo "hello word" | mail -s "mail title" 313841662@qq.com

5.配置nagios郵件發(fā)送命令

修改nagios命令配置文件

#vim /etc/nagios/objects/commands.cfg

#notify-host-by-email命令的定義

define command{

     #命令名稱,即定義了一個主機異常時發(fā)送郵件的命令。

    command_name   notify-host-by-email

     #命令具體的執(zhí)行方式。

    command_line   /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

    }

#notify-service-by-email命令的定義

define command{

     #命令名稱,即定義了一個服務(wù)異常時發(fā)送郵件的命令

    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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

    }

6、接著修改nagios中定義的主機和服務(wù)的報警機制,實現(xiàn)nagios利用郵件自動報警。

vim /etc/nagios/conf.d/10.10.13.238.cfg

define service{

    use   generic-service

    host_name    10.10.13.247

    service_description   notify-service-by-email

    check_command      notify-service-by-email

    max_check_attempts 5

    normal_check_interval 1

    notification_period 24x7

    contact_groups common

    notifications_enabled  1

    notification_options w,u,c,r

}

define service{

    use   generic-service

    host_name    10.10.13.247

    service_description   notify-host-by-email

    check_command      notify-host-by-email

    max_check_attempts 5

    normal_check_interval 1

    contact_groups common

    notifications_enabled  1

    notification_period 24x7

    notification_options w,u,c,r

}

#當重啟服務(wù)時出現(xiàn)以下錯誤:

Warning: Duplicate definition found for command 'notify-host-by-email' (config file '/etc/nagios/objects/commands.cfg', starting on line 244)

Error: Could not add object property in file '/etc/nagios/objects/commands.cfg' on line 245.

有可能是因為復(fù)制粘貼的時候復(fù)制了兩次,注意檢查配置文件

7、測試

將10.10.13.247關(guān)掉,QQ郵箱收到一封報警信,測試成功。



#當重啟客戶端的時候有可能在Nagios的監(jiān)控頁面上有關(guān)需要nrpe輔助的項目會顯示出錯,需要重新檢查客戶端nrpe配置文件allowed_hosts和dont_blame_nrpe是否需要修改。突然斷電等可能導(dǎo)致配置信息丟失需要重新檢查


測試自動發(fā)送郵件參考此文章:http://4709096.blog.51cto.com/4699096/1703980


參考: 
調(diào)用短信接口  http://www.aminglinux.com/bbs/thread-7380-1-1.html
整合微信  http://www.aminglinux.com/bbs/thread-7917-1-1.html

到此,關(guān)于“nagios的安裝及配置方法”的學(xué)習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習,快去試試吧!若想繼續(xù)學(xué)習更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

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

分享文章:nagios的安裝及配置方法-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.rwnh.cn/article4/ccidie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、網(wǎng)站排名、移動網(wǎng)站建設(shè)、網(wǎng)站維護、微信公眾號、虛擬主機

廣告

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

成都網(wǎng)站建設(shè)
志丹县| 云林县| 兴国县| 榆中县| 乌鲁木齐县| 稷山县| 松原市| 弥勒县| 松滋市| 宁波市| 潼关县| 澄城县| 高州市| 开江县| 沙洋县| 石首市| 精河县| 息烽县| 宁陕县| 都江堰市| 那曲县| 天柱县| 五莲县| 金塔县| 丁青县| 中卫市| 沁源县| 张家川| 威海市| 灌云县| 东兰县| 云龙县| 吉木萨尔县| 安国市| 盐池县| 宿松县| 扎赉特旗| 崇阳县| 德江县| 淮阳县| 安远县|