1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問(wèn)題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      CentOS7.2部署Nagios4.4.3

      系統(tǒng)運(yùn)維

      Nagios是一款開(kāi)源電腦系統(tǒng)和網(wǎng)絡(luò)監(jiān)視工具,能夠有效監(jiān)控windows,linux,Uninx的主機(jī)狀態(tài),交換機(jī)路由器等網(wǎng)絡(luò)設(shè)置,打印機(jī)等.在系統(tǒng)或服務(wù)狀態(tài)異常時(shí)發(fā)出郵件或短信報(bào)警第一時(shí)間通知運(yùn)維人員,在狀態(tài)恢復(fù)后發(fā)出正常的郵件或短信報(bào)警通知。

      金川網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(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),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司

      Nagios Core 是一個(gè)開(kāi)源的系統(tǒng),Nagios XI是收費(fèi)的。我們這里安裝前者。

      一、Nagios 結(jié)構(gòu)說(shuō)明

      Nagios 結(jié)構(gòu)上來(lái)說(shuō), 可分為核心和插件兩個(gè)部分。Nagios 的核心部分只提供了很少的監(jiān)控功能,因此要搭建一個(gè)完善的 IT 監(jiān)控管理系統(tǒng),用戶還需要在 Nagios 服務(wù)器安裝相應(yīng)的插件,插件可以從 Nagios 官方網(wǎng)站下載 http://www.nagios.org/,也可以根據(jù)實(shí)際要求自己編寫(xiě)所需的插件。

      Nagios 可實(shí)現(xiàn)的功能特性:

      監(jiān)控網(wǎng)絡(luò)服務(wù)(SMTP、POP3、HTTP、FTP、PING 等);

      監(jiān)控本機(jī)及遠(yuǎn)程主機(jī)資源(CPU 負(fù)荷、磁盤利用率、進(jìn)程 等);

      允許用戶編寫(xiě)自己的插件來(lái)監(jiān)控特定的服務(wù),方便地?cái)U(kuò)展自己服務(wù)的檢測(cè)方法,支持多種開(kāi)發(fā)語(yǔ)言(Shell、Perl、Python、PHP 等)

      具備定義網(wǎng)絡(luò)分層結(jié)構(gòu)的能力,用parent主機(jī)定義來(lái)表達(dá)網(wǎng)絡(luò)主機(jī)間的關(guān)系,這種關(guān)系可被用來(lái)發(fā)現(xiàn)和明晰主機(jī)宕機(jī)或不可達(dá)狀態(tài);

      當(dāng)服務(wù)或主機(jī)問(wèn)題產(chǎn)生與解決時(shí)將告警發(fā)送給聯(lián)系人(通過(guò) EMail、短信、用戶定義方式);

      可以支持并實(shí)現(xiàn)對(duì)主機(jī)的冗余監(jiān)控;

      可用 WEB 界面用于查看當(dāng)前的網(wǎng)絡(luò)狀態(tài)、通知和故障歷史、日志文件等;

      二.Nagios工作原理

      Nagiosq的功能是監(jiān)控服務(wù)和主機(jī),但也是 他 自身并不包括這部分功能,所有的監(jiān)控,檢測(cè)功能都是通過(guò)各種插件來(lái)完成的。

      啟動(dòng)Nagios后他會(huì)周期性的自動(dòng)調(diào)用插件去檢查服務(wù)器狀態(tài) ,同時(shí)Nagios會(huì)維持一個(gè)列隊(duì),所有插件返回來(lái)的狀態(tài)信息都進(jìn)入列隊(duì) ,Nagios每次都從隊(duì)首開(kāi)始讀取信息,并進(jìn)行處理,把狀態(tài)結(jié)果通過(guò)web結(jié)果通過(guò)顯示出來(lái)

      Nagios提供了許多插件,利用這些插件可以方便的監(jiān)控很多服務(wù)狀態(tài),安裝完成 后,在Nagios主目錄下的/libexec里放有nagios自的可以使用的所有插件,如,check_disk是檢查磁盤空間的插件,check_load是檢查CPU負(fù)載的,等等。每一個(gè)插件可以通過(guò)運(yùn)行 ./check_xxx –h 來(lái)查看使用方法和功能;

      Nagios可以識(shí)別4種狀態(tài)返回信息,即0(OK)表示狀態(tài)正常/綠色,1(WARNING)表示出現(xiàn)警告/X色,2(CRITTCAL)表示出現(xiàn) 非常嚴(yán)重 的錯(cuò)誤/紅色,3(UNKNOWN)表示未知錯(cuò)誤 、深X色。Nagios根據(jù)插件返回來(lái)的值,來(lái)判斷 監(jiān)控對(duì)象的狀態(tài),并通過(guò)web顯示出來(lái),以提供管理員及時(shí)發(fā)現(xiàn)故障

      再說(shuō)報(bào)警功能,如果 監(jiān)控系統(tǒng)發(fā)現(xiàn)問(wèn)題不能報(bào)警那就沒(méi)有意義了,所以報(bào)警也是nagios很重要的功能之一,但是,同樣的,Nagios自身業(yè)沒(méi)有報(bào)警部分的代碼,甚至沒(méi)有插件,而是交給用戶或者其他 相關(guān)開(kāi)源項(xiàng)目組去完成

      Nagios安裝,是指基本平臺(tái),也就是Nagios軟件包的安裝,它是監(jiān)控體系的框架,也是所有監(jiān)控基礎(chǔ)。

      Nagios通過(guò)NRPE來(lái)遠(yuǎn)端管理服務(wù)

      Nagios執(zhí)行安裝在它里面的check_nrpe插件,并告訴check_nrpe去檢測(cè)哪些服務(wù)。

      通過(guò)SSL,check_nrpe連接遠(yuǎn)端 機(jī)子上的NRPE daemon

      NRPE運(yùn)行本地的各種插件去檢測(cè)本地的服務(wù)和狀態(tài)

      最后,NRPE把檢測(cè)的結(jié)果傳給主機(jī)端check_nrpe,check_nrpe在把結(jié)果 送到Nagios狀態(tài)隊(duì)列中,

      Nagios依次讀取隊(duì)列中信息,再把結(jié)果顯示出來(lái)

      二.Nagios部署

      備注:默認(rèn)情況下Nagios沒(méi)有數(shù)據(jù)庫(kù),可以安裝NDOUtils保存Nagios數(shù)據(jù)到mysql數(shù)據(jù)庫(kù)中。

      1、環(huán)境準(zhǔn)備

      設(shè)置或停止防火墻:

      [root@localhost?~]#?systemctl?stop?firewalld.service
      [root@localhost?~]#?systemctl?disable?firewalld.service

      關(guān)閉selinux:

      臨時(shí)關(guān)閉:
      [root@localhost?~]#?setenforce?0
      
      永久關(guān)閉(修改配置文件):
      [root@localhost?~]#?vi?/etc/selinux/config
      改成SELINUX=disabled
      [root@localhost?~]#?rpm?-qa?httpd*
      [root@localhost?~]#?rpm?-e?--nodeps?包名
      有多個(gè)httpd*,用腳本刪除for?name?in?`rpm?-qa?httpd*`;do?rpm?-e?--nodeps?$name;done

      [root@localhost?~]#?rpm?-Uvh?https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
      [root@localhost?~]#?yum?install?wget?lrzsz?vim?lynx?lsof?netstat-tools?unzip?-y

      時(shí)區(qū)設(shè)置:

      [root@localhost?~]timedatectl
      [root@localhost?~]timedatectl?list-timezones??#該命令列出了所有的時(shí)區(qū)
      [root@localhost?~]timedatectl?set-timezone?Asia/Shanghai?#該命令把時(shí)區(qū)設(shè)置為上海

      時(shí)間同步:

      [root@localhost?~]#?ntpdate?time.nist.gov?#如果沒(méi)有yum安裝此命令
      [root@localhost?~]#?/usr/sbin/ntpdate?time.nist.gov
      [root@localhost?~]#?crontab?-e
      */10****?/usr/sbin/ntpdate?time.nist.gov?>/dev/null?2>&1

      2、源碼安裝nagios core(主程序)

      參考:https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html#_ga=2.130440076.2034626946.1559144380-1378811618.1556870555
      [root@localhost?~]#?yum?install?-y?gcc?glibc?glibc-common?wget?unzip?httpd?php?gd?php-gd?gd-devel?perl?postfix
      [root@localhost?~]#?cd?/tmp
      [root@localhost?tmp]#?wget?-O?nagioscore.tar.gz?https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz
      [root@localhost?tmp]#?tar?zxvf?nagioscore.tar.gz
      [root@localhost?tmp]#?cd?/tmp/nagioscore-nagios-4.4.3/
      [root@localhost?nagioscore-nagios-4.4.3]#?./configure
      [root@localhost?nagioscore-nagios-4.4.3]#?make?all
      [root@localhost?nagioscore-nagios-4.4.3]#?make?install-groups-users
      [root@localhost?nagioscore-nagios-4.4.3]#?usermod?-a?-G?nagios?apache

      #安裝主程序

      [root@localhost?nagioscore-nagios-4.4.3]#?make?install
      [root@localhost?nagioscore-nagios-4.4.3]#?make?install-daemoninit
      [root@localhost?nagioscore-nagios-4.4.3]#?systemctl?enable?httpd.service

      #配置目錄權(quán)限

      [root@localhost?nagioscore-nagios-4.4.3]#?make?install-commandmode

      #安裝示例配置文件

      [root@localhost?nagioscore-nagios-4.4.3]#?make?install-config

      #安裝nagios的web接口,會(huì)在/etc/httpd/conf.d目錄中創(chuàng)建nagios.conf文件

      [root@localhost?nagioscore-nagios-4.4.3]#?make?install-webconf

      執(zhí)行上述操作后,會(huì)在/usr/local/nagios目錄下產(chǎn)生如下目錄:

      bin:nagios執(zhí)行程序所在的目錄,nagios文件即為主程序。

      etc:nagios配置文件目錄,當(dāng)make install-config完以后etc下面就會(huì)出現(xiàn)默認(rèn)的配置文件。

      sbin:nagios CGI文件所在目錄,這里存放的是一些外部命令執(zhí)行程序。

      share:nagios網(wǎng)頁(yè)文件目錄,存放一些html文件。

      var:nagios日志文件、pid等文件目錄。

      Libexec:系統(tǒng)默認(rèn)插件的存儲(chǔ)位置

      修改nagios警告信息的郵件地址

      [root@localhost?~]#?vi?/usr/local/nagios/etc/objects/contacts.cfg
      ????email???????????????????442102293@qq.com?;?<<*****?CHANGE?THIS?TO?YOUR?EMAIL?ADDRESS?******

      nagiosadmin設(shè)置密碼

      root@localhost?~]#?htpasswd?-c?/usr/local/nagios/etc/htpasswd.users?nagiosadmin
      [root@localhost?~]#?systemctl?start?httpd.service
      [root@localhost?~]#?systemctl?start?nagios.service
      http://192.168.146.128/nagios 

      不使用默認(rèn)nagiosadmin賬號(hào),新增gxm賬號(hào)并配置權(quán)限,如果不配置點(diǎn)擊Hosts會(huì)報(bào)紅色錯(cuò)誤。

      [root@localhost?~]#?htpasswd?-bc?/usr/local/nagios/etc/htpasswd.users?gxm?123456

      [root@localhost?~]#?cd?/usr/local/nagios/etc/
      [root@localhost?etc]#?sed?-i?\'s#nagiosadmin#gxm#g\'?cgi.cfg
      [root@localhost?etc]#?grep?gxm?cgi.cfg
      authorized_for_system_information=gxm
      authorized_for_configuration_information=gxm
      authorized_for_system_commands=gxm
      authorized_for_all_services=gxm
      authorized_for_all_hosts=gxm
      authorized_for_all_service_commands=gxm
      authorized_for_all_host_commands=gxm
      [root@localhost?etc]#?systemctl?restart??httpd.service

      #檢查語(yǔ)法錯(cuò)誤

      [root@localhost?etc]#?/usr/local/nagios/bin/nagios?-v?/usr/local/nagios/etc/nagios.cfg
      Nagios?Core?4.4.3
      Copyright?(c)?2009-present?Nagios?Core?Development?Team?and?Community?Contributors
      Copyright?(c)?1999-2009?Ethan?Galstad
      Last?Modified:?2019-01-15
      License:?GPL
      Website:?https://www.nagios.org
      Reading?configuration?data...
      ???Read?main?config?file?okay...
      ???Read?object?config?files?okay...
      Running?pre-flight?check?on?configuration?data...
      Checking?objects...
      ????Checked?8?services.
      ????Checked?1?hosts.
      ????Checked?1?host?groups.
      ????Checked?0?service?groups.
      ????Checked?1?contacts.
      ????Checked?1?contact?groups.
      ????Checked?24?commands.
      ????Checked?5?time?periods.
      ????Checked?0?host?escalations.
      ????Checked?0?service?escalations.
      Checking?for?circular?paths...
      ????Checked?1?hosts
      ????Checked?0?service?dependencies
      ????Checked?0?host?dependencies
      ????Checked?5?timeperiods
      Checking?global?event?handlers...
      Checking?obsessive?compulsive?processor?commands...
      Checking?misc?settings...
      Total?Warnings:?0
      Total?Errors:???0
      Things?look?okay?-?No?serious?problems?were?detected?during?the?pre-flight?check

      3、安裝nagios插件(監(jiān)控功能通過(guò)插件完成)

      上述安裝的Nagios主程序只是一個(gè)控制中心,而能夠起到服務(wù)監(jiān)測(cè)和系統(tǒng)監(jiān)測(cè)等功能的是眾多Nagios的插件,沒(méi)有插件的Nagios系統(tǒng)其實(shí)只是一個(gè)空殼。因此在安裝了Nagios平臺(tái)之后我們還需要安裝插件。

      [root@localhost?~]#?yum?install?-y?gcc?glibc?glibc-common?make?gettext?automake?autoconf?wget?openssl-devel?net-snmp?net-snmp-utils?epel-release
      [root@localhost?~]#?yum?install?-y?perl-Net-SNMP
      或者
      [root@localhost?~]#?cd?/tmp
      [root@localhost?~]#?wget?https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
      [root@localhost?~]#?rpm?-ihv?epel-release-latest-7.noarch.rpm
      [root@localhost?~]#?subscription-manager?repos?--enable=rhel-7-server-optional-rpms
      [root@localhost?~]#?yum?install?-y?gcc?glibc?glibc-common?make?gettext?automake?autoconf?wget?openssl-devel?net-snmp?net-snmp-utils
      [root@localhost?~]#?yum?install?-y?perl-Net-SNMP
      [root@localhost?~]#?cd?/tmp
      [root@localhost?~]#?wget?--no-check-certificate?-O?nagios-plugins.tar.gz?https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
      [root@localhost?~]#?tar?zxvf?nagios-plugins.tar.gz
      [root@localhost?~]#?cd?/tmp/nagios-plugins-release-2.2.1/
      [root@localhost?nagios-plugins-release-2.2.1]#?./tools/setup
      [root@localhost?nagios-plugins-release-2.2.1]#?./configure
      [root@localhost?nagios-plugins-release-2.2.1]#?make
      [root@localhost?nagios-plugins-release-2.2.1]#?make?install
      [root@localhost?nagios-plugins-release-2.2.1]#?systemctl?start?nagios.service
      [root@localhost?nagios-plugins-release-2.2.1]#?systemctl?stop?nagios.service
      [root@localhost?nagios-plugins-release-2.2.1]#?systemctl?restart?nagios.service
      [root@localhost?nagios-plugins-release-2.2.1]#?systemctl?status?nagios.service
      
      [root@localhost?libexec]#?ll?/usr/local/nagios/libexec
      -rwxr-xr-x?1?root?root?210656?5月??31?11:54?check_apt
      -rwxr-xr-x?1?root?root???2354?5月??31?11:54?check_breeze
      -rwxr-xr-x?1?root?root?214653?5月??31?11:54?check_by_ssh
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_clamd?->?check_tcp
      -rwxr-xr-x?1?root?root?163022?5月??31?11:54?check_cluster
      -r-sr-xr-x?1?root?root?211527?5月??31?11:54?check_dhcp
      -rwxr-xr-x?1?root?root?227293?5月??31?11:54?check_disk
      -rwxr-xr-x?1?root?root???9477?5月??31?11:54?check_disk_smb
      -rwxr-xr-x?1?root?root?127110?5月??31?11:54?check_dummy
      -rwxr-xr-x?1?root?root???3868?5月??31?11:54?check_file_age
      -rwxr-xr-x?1?root?root???6512?5月??31?11:54?check_flexlm
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_ftp?->?check_tcp
      -rwxr-xr-x?1?root?root?209501?5月??31?11:54?check_hpjd
      -rwxr-xr-x?1?root?root?375004?5月??31?11:54?check_http
      -r-sr-xr-x?1?root?root?227225?5月??31?11:54?check_icmp
      -rwxr-xr-x?1?root?root?169900?5月??31?11:54?check_ide_smart
      -rwxr-xr-x?1?root?root??15283?5月??31?11:54?check_ifoperstatus
      -rwxr-xr-x?1?root?root??13435?5月??31?11:54?check_ifstatus
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_imap?->?check_tcp
      -rwxr-xr-x?1?root?root???6992?5月??31?11:54?check_ircd
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_jabber?->?check_tcp
      -rwxr-xr-x?1?root?root?187685?5月??31?11:54?check_load
      -rwxr-xr-x?1?root?root???6673?5月??31?11:54?check_log
      -rwxr-xr-x?1?root?root??22741?5月??31?11:54?check_mailq
      -rwxr-xr-x?1?root?root?173210?5月??31?11:54?check_mrtg
      -rwxr-xr-x?1?root?root?170431?5月??31?11:54?check_mrtgtraf
      -rwxr-xr-x?1?root?root?186817?5月??31?11:54?check_nagios
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_nntp?->?check_tcp
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_nntps?->?check_tcp
      -rwxr-xr-x?1?root?root?219815?5月??31?11:54?check_nt
      -rwxr-xr-x?1?root?root?218463?5月??31?11:54?check_ntp
      -rwxr-xr-x?1?root?root?208212?5月??31?11:54?check_ntp_peer
      -rwxr-xr-x?1?root?root?207193?5月??31?11:54?check_ntp_time
      -rwxr-xr-x?1?root?root?250160?5月??31?11:54?check_nwstat
      -rwxr-xr-x?1?root?root???9461?5月??31?11:54?check_oracle
      -rwxr-xr-x?1?root?root?193042?5月??31?11:54?check_overcr
      -rwxr-xr-x?1?root?root?223263?5月??31?11:54?check_ping
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_pop?->?check_tcp
      -rwxr-xr-x?1?root?root?224192?5月??31?11:54?check_procs
      -rwxr-xr-x?1?root?root?185576?5月??31?11:54?check_real
      -rwxr-xr-x?1?root?root???9687?5月??31?11:54?check_rpc
      -rwxr-xr-x?1?root?root???1537?5月??31?11:54?check_sensors
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_simap?->?check_tcp
      -rwxr-xr-x?1?root?root?268781?5月??31?11:54?check_smtp
      -rwxr-xr-x?1?root?root?269786?5月??31?11:54?check_snmp
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_spop?->?check_tcp
      -rwxr-xr-x?1?root?root?185227?5月??31?11:54?check_ssh
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_ssmtp?->?check_tcp
      -rwxr-xr-x?1?root?root?166806?5月??31?11:54?check_swap
      -rwxr-xr-x?1?root?root?252843?5月??31?11:54?check_tcp
      -rwxr-xr-x?1?root?root?186950?5月??31?11:54?check_time
      lrwxrwxrwx?1?root?root??????9?5月??31?11:54?check_udp?->?check_tcp
      -rwxr-xr-x?1?root?root?199442?5月??31?11:54?check_ups
      -rwxr-xr-x?1?root?root?163288?5月??31?11:54?check_uptime
      -rwxr-xr-x?1?root?root?157647?5月??31?11:54?check_users
      -rwxr-xr-x?1?root?root???3040?5月??31?11:54?check_wave
      -rwxr-xr-x?1?root?root?157770?5月??31?11:54?negate
      -rwxr-xr-x?1?root?root?151307?5月??31?11:54?urlize
      -rwxr-xr-x?1?root?root???1914?5月??31?11:54?utils.pm
      -rwxr-xr-x?1?root?root???2791?5月??31?11:54?utils.sh

      4、安裝nrpe(在需要監(jiān)控的服務(wù)器上部署)

      NRPE依賴于nagios-plugins,所以要一起安裝。

      可參考:https://support.nagios.com/kb/article.php?id=515

      [root@localhost?~]#?yum?install?-y?gcc?glibc?glibc-common?openssl?openssl-devel?perl?wget
      [root@localhost?~]#?cd?/tmp
      [root@localhost?~]#?wget?--no-check-certificate?-O?nrpe.tar.gz?https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.1.tar.gz
      [root@localhost?~]#?tar?zxvf?nrpe.tar.gz
      [root@localhost?~]#?cd?/tmp/nrpe-nrpe-3.2.1/
      [root@localhost?nrpe-nrpe-3.2.1]#?./configure?--enable-command-args
      [root@localhost?nrpe-nrpe-3.2.1]#?make?all
      [root@localhost?nrpe-nrpe-3.2.1]#?make?install-groups-users
      [root@localhost?nrpe-nrpe-3.2.1]#?make?install
      [root@localhost?nrpe-nrpe-3.2.1]#?make?install-config
      
      [root@localhost?nrpe-nrpe-3.2.1]#?echo?>>?/etc/services
      [root@localhost?nrpe-nrpe-3.2.1]#?echo?\'#?Nagios?services\'?>>?/etc/services
      [root@localhost?nrpe-nrpe-3.2.1]#?echo?\'nrpe?5666/tcp\'?>>?/etc/services
      [root@localhost?nrpe-nrpe-3.2.1]#?make?install-init
      [root@localhost?nrpe-nrpe-3.2.1]#?systemctl?enable?nrpe.service

      #添加nagios服務(wù)器IP,運(yùn)行服務(wù)器連接nrpe

      [root@localhost?nrpe-nrpe-3.2.1]#?vi?/usr/local/nagios/etc/nrpe.cfg
      allowed_hosts=127.0.0.1,192.168.146.128
      dont_blame_nrpe=1
      [root@localhost?nrpe-nrpe-3.2.1]#?systemctl?start?nrpe.service
      [root@localhost?~]#?cat?/usr/lib/systemd/system/nrpe.service
      [root@localhost?nrpe-nrpe-3.2.1]#?/usr/local/nagios/libexec/check_nrpe?-H?127.0.0.1
      NRPE?v3.2.1
      [root@localhost?nrpe-nrpe-3.2.1]#?/usr/local/nagios/libexec/check_nrpe?-H?192.168.146.128
      NRPE?v3.2.1

      測(cè)試插件和NRPE

      [root@localhost?nrpe-nrpe-3.2.1]#?vi?/usr/local/nagios/etc/nrpe.cfg
      command[check_load]=/usr/local/nagios/libexec/check_load?-w?15,10,5?-c?30,25,20
      [root@localhost?nrpe-nrpe-3.2.1]#?/usr/local/nagios/libexec/check_nrpe?-H?127.0.0.1?-c?check_load
      WARNING?-?load?average:?0.06,?0.06,?0.09|load1=0.060;0.150;0.300;0;?load5=0.060;0.100;0.250;0;?load15=0.090;0.050;0.200;0;
      
      [root@localhost?~]#?netstat?-tnlp
      Active?Internet?connections?(only?servers)
      Proto?Recv-Q?Send-Q?Local?Address???????????Foreign?Address?????????State???????PID/Program?name????
      tcp????????0??????0?0.0.0.0:22??????????????0.0.0.0:*???????????????LISTEN??????1062/sshd???????????
      tcp????????0??????0?127.0.0.1:25????????????0.0.0.0:*???????????????LISTEN??????1372/master?????????
      tcp????????0??????0?0.0.0.0:5666????????????0.0.0.0:*???????????????LISTEN??????60275/nrpe??????????
      tcp6???????0??????0?:::80???????????????????:::*????????????????????LISTEN??????57918/httpd?????????
      tcp6???????0??????0?:::22???????????????????:::*????????????????????LISTEN??????1062/sshd???????????
      tcp6???????0??????0?::1:25??????????????????:::*????????????????????LISTEN??????1372/master?????????
      tcp6???????0??????0?:::5666?????????????????:::*????????????????????LISTEN??????60275/nrpe

      5、安裝PNP插件(監(jiān)控功能通過(guò)插件完成)

      可參考:https://www.cnblogs.com/caoguo/p/5022230.html

      [root@localhost?~]#?yum?-y?install?rrdtool?librrds-perl?perl-rrdtool?-y
      [root@localhost?~]#?tar?zxvf?pnp4nagios-0.6.26.tar.gz
      [root@localhost?~]#?cd?pnp4nagios-0.6.26
      [root@localhost?pnp4nagios-0.6.26]#?./configure?--with-nagios-user=nagios?--with-nagios-group=nagios
      [root@localhost?pnp4nagios-0.6.26]#?make?all
      [root@localhost?pnp4nagios-0.6.26]#?make?install
      [root@localhost?pnp4nagios-0.6.26]#?make?install-webconf
      [root@localhost?pnp4nagios-0.6.26]#?make?install-config
      [root@localhost?pnp4nagios-0.6.26]#?make?install-init
      [root@localhost?pnp4nagios-0.6.26]#?cd?./sample-config
      [root@localhost?pnp4nagios-0.6.26]#?make?install-webconf

      配置pnp4nagios

      [root@localhost?pnp4nagios-0.6.26]#?cd?/usr/local/pnp4nagios/etc/
      [root@localhost?etc]#?mv?misccommands.cfg-sample?misccommands.cfg
      [root@localhost?etc]#?mv?rra.cfg-sample?rra.cfg
      [root@localhost?etc]#?mv?nagios.cfg-sample?nagios.cfg
      [root@localhost?etc]#?cd?pages/
      [root@localhost?pages]#?mv?web_traffic.cfg-sample?web_traffic.cfg
      [root@localhost?pages]#?cd?../check_commands/
      [root@localhost?check_commands]#?mv?check_all_local_disks.cfg-sample?check_all_local_disks.cfg
      [root@localhost?check_commands]#?mv?check_nrpe.cfg-sample?check_nrpe.cfg
      [root@localhost?check_commands]#?mv?check_nwstat.cfg-sample?check_nwstat.cfg
      [root@localhost?check_commands]#?/etc/init.d/npcd?start
      [root@localhost?check_commands]#?chkconfig?npcd?on
      配置Nagios數(shù)據(jù)輸出接口(以BULK模式運(yùn)行)詳情參考官網(wǎng)https://docs.pnp4nagios.org/pnp-0.6/config#bulk_mode:
      [root@localhost?~]#?vi?/usr/local/nagios/etc/nagios.cfg
      process_performance_data=1?#默認(rèn)為0,修改為1
      并在該文件中添加下面的內(nèi)容
      #
      #?service?performance?data
      #
      service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
      service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tSERVICEDESC::$SERVICEDESC$\\tSERVICEPERFDATA::$SERVICEPERFDATA$\\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$\\tSERVICESTATE::$SERVICESTATE$\\tSERVICESTATETYPE::$SERVICESTATETYPE$
      service_perfdata_file_mode=a
      service_perfdata_file_processing_interval=15
      service_perfdata_file_processing_command=process-service-perfdata-file
      #
      #?host?performance?data?starting?with?Nagios?3.0
      #
      host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
      host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::$TIMET$\\tHOSTNAME::$HOSTNAME$\\tHOSTPERFDATA::$HOSTPERFDATA$\\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\\tHOSTSTATE::$HOSTSTATE$\\tHOSTSTATETYPE::$HOSTSTATETYPE$
      host_perfdata_file_mode=a
      host_perfdata_file_processing_interval=15
      host_perfdata_file_processing_command=process-host-perfdata-file

      配置command.cfg:

      [root@localhost?~]#?vi?/usr/local/nagios/etc/objects/commands.cfg
      在該文件中添加下面的內(nèi)容
      define?command{
      ???????command_name????process-service-perfdata-file
      ???????command_line????/usr/local/pnp4nagios/libexec/process_perfdata.pl?--bulk=/usr/local/pnp4nagios/var/service-perfdata
      }
      define?command{
      ???????command_name????process-host-perfdata-file
      ???????command_line????/usr/local/pnp4nagios/libexec/process_perfdata.pl?--bulk=/usr/local/pnp4nagios/var/host-perfdata
      }

      在模板配置文件中添加圖表圖標(biāo)模板:

      [root@localhost?~]#?vi?/usr/local/nagios/etc/objects/templates.cfg
      在該文件中添加下面的內(nèi)容
      define?host?{
      ???name???????host-pnp
      ???action_url?/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
      ???register???0
      }
      define?service?{
      ??name???????service-pnp
      ??action_url?/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
      ???register???0
      }

      在監(jiān)控主機(jī)和服務(wù)中調(diào)用圖表模板(在主機(jī)和服務(wù)后面添加新的模板):

      [root@localhost ~]# vi /usr/local/nagios/etc/objects/localhost.cfg

      按下面的內(nèi)容修改(不是添加)該文件

      define?host{
      ????????use?????????????????????linux-server,host-pnp??????????????????????????
      ????????host_name???????????????localhost
      ????????alias???????????????????localhost
      ????????address?????????????????127.0.0.1
      ????????}
      define?service{
      ????????use????????????????????????????local-service,service-pnp
      ????????host_name???????????????????????localhost
      ????????service_description?????????????PING
      ????????check_command???????????check_ping!100.0,20%!500.0,60%
      ????????}
      define?service{
      ????????use????????????????????????????local-service,service-pnp
      ????????host_name???????????????????????localhost
      ????????service_description?????????????Root?Partition
      ????????check_command???????????check_local_disk!20%!10%!/
      ????????}

      重啟nagios和apache:

      [root@localhost?~]#?systemctl?restart?nagios.service
      [root@localhost?~]#?systemctl?restart?httpd.service

      訪問(wèn)nagios界面即可看到圖表小圖標(biāo):

      要全綠色,不綠色就按照提示解決。

      [root@localhost?check_commands]#?mv?/usr/local/pnp4nagios/share/install.php?/tmp/

      全綠色后刷新,正常如下:

      監(jiān)控本機(jī)

      ==============================================================================

      [root@localhost?~]#?cd?/usr/local/nagios/etc/objects
      [root@localhost?~]#?vim?localhost.cfg
      define?host{
      ???????use?????????????????????linux-server??????????????????????????????????????
      ???????host_name???????????????localhost
      ???????alias???????????????????localhost
      ???????address?????????????????127.0.0.1
      ???????}
      #?Define?an?optional?hostgroup?for?Linux?machines
      define?hostgroup{
      ???????hostgroup_name??linux-servers?;?The?name?of?the?hostgroup
      ???????alias???????????Linux?Servers?;?Long?name?of?the?group
      ???????members?????????localhost?????;?Comma?separated?list?of?hosts?that?belong?to?this?group
      ???????}
      #?Define?a?service?to?ftp?the?local?machine
      define?service{
      ???????use?????????????????????????????local-service?????????;?Name?of?service?template?to?use
      ???????host_name???????????????????????localhost
      ???????service_description?????????????FTP
      ???????check_command???????????????????check_ftp
      ???????}
      #?Define?a?service?to?nfs?the?local?machine
      define?service{
      ???????use?????????????????????????????local-service?????????;?Name?of?service?template?to?use
      ???????host_name???????????????????????localhost
      ???????service_description?????????????NFS
      ???????check_command???????????????????check_tcp!2049
      ???????}

      監(jiān)控遠(yuǎn)程主機(jī)

      ==============================================================================

      [root@localhost?~]#?cd?/usr/local/nagios/etc/objects
      [root@localhost?~]#?cp?localhost.cfg?192.168.0.164.cfg
      [root@localhost?~]#?vim?192.168.0.164.cfg
      define?host{
      ???????use?????????????????????linux-server????
      ???????host_name???????????????testserver
      ???????alias???????????????????host196
      ???????address?????????????????192.168.0.164
      ???????}
      #define?hostgroup{
      #????????hostgroup_name??testserver?;?The?name?of?the?hostgroup
      #????????alias???????????host;?Long?name?of?the?group
      #????????members?????????localhost???;?Comma?separated?list?of?hosts?that?belong?to?this?group
      #}
      define?service{
      ???????use?????????????????????????????local-service
      ???????host_name???????????????????????testserver
      ???????service_description?????????????PING
      ???????check_command???????????????????check_ping!100.0,20%!500.0,60%
      ???????}
      define?service{
      ???????use?????????????????????????????local-service??
      host_name???????????????????????testserver
      ???????service_description?????????????HTTP
      ???????check_command???????????????????check_http
      #???????notifications_enabled???????????0
      ???????}
      define?service{
      ???????use?????????????????????????????local-service
      ???????host_name???????????????????????testserver
      ???????service_description?????????????NFS
      ???????check_command???????????????????check_tcp!2049
      #???????notifications_enabled???????????0
      ???????}

      =============================================================================

      更改主配置文件

      [root@localhost?~]#?vim?/usr/local/nagios/etc/nagios.cfg
      添加一行
      cfg_file=/usr/local/nagios/etc/objects/192.168.122.100.cfg
      檢測(cè)新的配置文件是否正確
      [root@localhost?~]#?/usr/local/nagios/bin/nagios?-v?/usr/local/nagios/etc/nagios.cfg
      Total?Warnings:?0
      Total?Errors:???0
      Things?look?okay?-?No?serious?problems?were?detected?during?the?pre-flight?check

      重啟nagios,web登錄確認(rèn)是否新增了主機(jī)。

      監(jiān)控本機(jī)和遠(yuǎn)程主機(jī)參考:

      https://blog.51cto.com/1585654/1386857

      nagios默認(rèn)不用Mysql存儲(chǔ),可以使用NDOUtils插件實(shí)現(xiàn)MYSQL存儲(chǔ):

      https://support.nagios.com/kb/article/ndoutils-installing-ndoutils-406.html


      當(dāng)前名稱:CentOS7.2部署Nagios4.4.3
      路徑分享:http://ef60e0e.cn/article/chogpe.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        伊宁县| 平潭县| 拜泉县| 通河县| 昌黎县| 河池市| 水城县| 肇源县| 五家渠市| 綦江县| 宁都县| 广宗县| 安义县| 库尔勒市| 宁明县| 井陉县| 盐边县| 内乡县| 宜兴市| 乐亭县| 永登县| 米林县| 思茅市| 富锦市| 凤山县| 文山县| 卓资县| 松江区| 菏泽市| 南部县| 江门市| 昌吉市| 无极县| 襄城县| 高州市| 北京市| 涞源县| 民勤县| 陆河县| 辽阳市| 香格里拉县|