欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

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

# Nagios官網(wǎng)   http://www.nagios.org

本溪網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站開發(fā)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營(yíng)維護(hù)。成都創(chuàng)新互聯(lián)成立與2013年到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。

 nagios是php編寫的,需要提供支持php的環(huán)境

 支持插件

 安裝nrpe是為了檢測(cè)一些特殊的服務(wù),比如負(fù)載
 iptables和selinux關(guān)閉

★Nagios安裝

  • 服務(wù)端(192.168.182.100)

    編譯安裝很復(fù)雜,可以使用rpm包安裝(適用于CentOS)
    Centos6默認(rèn)的yum源里沒有nagios相關(guān)的rpm包,我們可以安裝一個(gè)epel的擴(kuò)展源
    yum install -y httpd               <== 配置文件默認(rèn)與httpd.conf對(duì)應(yīng),安裝httpd是為了

                                           web訪問,通過瀏覽器查看監(jiān)控內(nèi)容

                  nagios

                  nagios-plugins

                  nagios-plugins-all

                  nrpe

                  nagios-plugins-nrpe
    設(shè)置登錄nagios后臺(tái)的用戶和密碼:htpasswd -c /etc/nagios/passwd nagiosadmin
    編輯配置文件 vim /etc/nagios/nagios.cfg
    檢測(cè)配置文件 nagios -v /etc/nagios/nagios.cfg
    啟動(dòng)服務(wù):service httpd start; service nagios start
    瀏覽器訪問: http://192.168.182.100/nagios

  • 客戶端(192.168.182.105)

    我們同樣需要安裝epel擴(kuò)展源
    在客戶端機(jī)器上 rpm -ivh  http://www.aminglinux.com/bbs/da ... ease-6-7.noarch.rpm
    yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe
    編輯配置文件  vim /etc/nagios/nrpe.cfg

    allowed_hosts=127.0.0.1==>allowed_hosts=127.0.0.1,192.168.182.100 ip為服務(wù)端ip                                                <== 規(guī)定哪些主機(jī)可以使用nrpe服務(wù)

    dont_blame_nrpe=0 ==> dont_blame_nrpe=1
    啟動(dòng)客戶端 /etc/init.d/nrpe start

★監(jiān)控中心(192.168.182.100)添加被監(jiān)控主機(jī)(192.168.182.105)
   cd /etc/nagios/conf.d/
   vim yue.cfg(182.105上)      //定義一個(gè)主機(jī)三個(gè)服務(wù)
define host{                                      <== 定義主機(jī)
      use              linux-server    <== Name of host template to use
      host_name          yue              <== 被監(jiān)控主機(jī)名
      alias            hera
      address            192.168.182.105   <== 被監(jiān)控主機(jī)ip
      }

define service{
      use              generic-service
      host_name          yue
      service_description    check_ping        <== 可以在web頁(yè)面里看到
      check_command        check_ping!100.0,20%!200.0,50% <== 丟包20%警告,丟包50%
                                                                heck_ping后面是要跟參數(shù)

                                                                  ,在寫配置文件的時(shí)候參數(shù)

                                                                  要用!分隔開.

       max_check_attempts 5
      normal_check_interval 1
}

define service{
      use              generic-service
      host_name          192.168.182.105
      service_description    check_ssh
      check_command        check_ssh
      max_check_attempts    5                 <== 當(dāng)nagios檢測(cè)到問題時(shí),一共嘗試檢測(cè)5

                                                       次都有問題才會(huì)告警,如果該數(shù)值為1,

                                                       那么檢測(cè)到問題立即告警

       normal_check_interval 1                   <== 重新檢測(cè)的時(shí)間間隔,單位是分鐘,默
                                                     認(rèn)是3分鐘

       notification_interval        60         <== 在服務(wù)出現(xiàn)異常后,故障一直沒有解

                                                       決,nagios再次對(duì)使用者發(fā)出通知的時(shí)

                                                       間。單位是分鐘。如果你認(rèn)為,所有的

                                                       事件只需要一次通知就夠了,可以把這

                                                       里的選項(xiàng)設(shè)為0。
}

define service{
      use              generic-service
      host_name          192.168.0.12
      service_description    check_http
      check_command        check_http
      max_check_attempts    5
      normal_check_interval 1
}

 上面的服務(wù)不依賴于客戶端nrpe服務(wù),我們可以知道在自己電腦上可以使用ping或telnet探測(cè)遠(yuǎn)程任何一臺(tái)機(jī)器是否存活以及是否開啟某個(gè)端口或服務(wù)。

 但是當(dāng)我們想要檢測(cè)客戶端上的某個(gè)具體服務(wù)的情況時(shí),就需要借助于nrpe了,比如想知道客戶端機(jī)器的負(fù)載或磁盤使用情況。

★繼續(xù)添加服務(wù)
 在服務(wù)端編輯配置文件 vim /etc/nagios/objects/commands.cfg
 增加:define command{
      command_name  check_nrpe  實(shí)現(xiàn)和對(duì)方nrpe服務(wù)的通信
      command_line  $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
      }
 繼續(xù)編輯配置文件     vim /etc/nagios/conf.d/yue.cfg
 增加如下內(nèi)容:

define service{
      use    generic-service
      host_name    yue
      service_description    check_load
      check_command        check_nrpe!check_load
      max_check_attempts 5
      normal_check_interval 1
}

define service{
      use    generic-service
      host_name    yue
      service_description    check_disk_hda1
      check_command        check_nrpe!check_hda1
      max_check_attempts 5
      normal_check_interval 1
}

define service{
      use    generic-service
      host_name    yue
      service_description    check_disk_hda2
      check_command        check_nrpe!check_hda2
      max_check_attempts 5
      normal_check_interval 1
}

說明:  check_nrpe!check_load :這里的check_nrpe就是在commands.cfg剛剛定義的,check_load是遠(yuǎn)程主機(jī)上的一個(gè)檢測(cè)腳本
在遠(yuǎn)程主機(jī)上vim /etc/nagios/nrpe.cfg 搜索check_load,這行就是在服務(wù)端上要執(zhí)行的腳本了,我們可以手動(dòng)執(zhí)行這個(gè)腳本
把check_hda1更改一下:/dev/hda1 改為 /dev/sda1
再加一行command[check_hda2]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda2
客戶端上重啟一下nrpe服務(wù): service nrpe restart
服務(wù)端也重啟一下nagios服務(wù): service nagios restart

★配置告警
 vim /etc/nagios/objects/contacts.cfg //增加:

define contact{
      contact_name          123
      use                    generic-contact
      alias                  yue
      email         345394956@qq.com
      }

define contact{
      contact_name          456
      use                      generic-contact
      alias                  aaa
      email         345394956@qq.com
      }

define contactgroup{
      contactgroup_name            common
      alias                  common
      members                  123,456
      }

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

define service{
      use           generic-service
      host_name            192.168.182.105
      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禁用)一般,這個(gè)選項(xiàng)

                                           會(huì)在主配置文件(nagios.cfg)中定義,效果相同。       service_notification_period  24*7 <==發(fā)送提醒的時(shí)間段。

                                           非常重要的主機(jī)(服務(wù))我定義為7×24

                                           一般的主機(jī)(服務(wù))就定義為上班時(shí)間

 如果不在定義的時(shí)間段內(nèi),無論出現(xiàn)任何問題都不會(huì)發(fā)送提醒。還有一個(gè)host_notification_period, 相同的設(shè)置方法。但需要加到host的定義配置文件里。
      service_notification_options:w,u,c,r <==上面的是host的狀態(tài),這個(gè)是service的狀態(tài)。

                                               w(waning)  u(unknown)

                                               c(critical) r(recover)恢復(fù)了

     host_notification_options:d,u,r    <==發(fā)送提醒包括的情況

                                               d(狀態(tài)為DOWN) u(狀態(tài)為UNREACHABLE)

                                               r(狀態(tài)恢復(fù)為OK)

                                               也需要加入到host的定義配置里
}

★配置圖形顯示 pnp4nagios

  • 安裝
    yum install pnp4nagios rrdtool

  • 配置主配置文件
    vim /etc/nagios/nagios.cfg  //修改如下配置

   process_performance_data=1

   host_perfdata_command=process-host-perfdata

   service_perfdata_command=process-service-perfdata

   enable_environment_macros=1

  • 修改commands.cfg

   vim /etc/nagios/objects/commands.cfg

方便起見,我們可以注釋掉原有對(duì)process-host-perfdata和process-service-perfdata,重新定義

   加入以下內(nèi)容

define command {

    command_name  process-service-perfdata

    command_line  /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl

 }

define command {

    command_name  process-host-perfdata

    command_line  /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA

}

  • 修改配置文件 templates.cfg
    vim /etc/nagios/objects/templates.cfg

    define host {
          name    hosts-pnp
          register  0
          action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
          process_perf_data          1
    }
    define service {
          name    srv-pnp
          register  0
          action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
          process_perf_data          1
    }

  • 修改host和service配置
    vim /etc/nagios/conf.d/yue.cfg
    把 define host{
          use              linux-server
    改為:
    define host{
          use              linux-server,hosts-pnp

    修改對(duì)應(yīng)的service

    define service{
          use    generic-service
          host_name    192.168.182.100
          service_description    check_disk_hda1
          check_command        check_nrpe!check_hda1
          max_check_attempts 5
          normal_check_interval 1
    }
    改為:
    define service{
          use    generic-service,srv-pnp
          host_name    192.168.182.100
          service_description    check_disk_hda1
          check_command        check_nrpe!check_hda1
          max_check_attempts 5
          normal_check_interval 1
    }

  • 重啟和啟動(dòng)服務(wù):
    service nagios restart
    service httpd restart
    service npcd start

★訪問測(cè)試

  web下訪問
192.169.182.100/nagios/
192.168.182.100/pnp4nagios/

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

分享題目:linux下nagios的安裝及配置-創(chuàng)新互聯(lián)
鏈接URL:http://chinadenli.net/article34/deeope.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、Google、企業(yè)建站、品牌網(wǎng)站建設(shè)、定制網(wǎng)站、網(wǎng)站導(dǎo)航

廣告

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

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司