真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

50.nagios監(jiān)控工具-創(chuàng)新互聯(lián)

nagios監(jiān)控工具

專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)穆棱免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了千余家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

Nagios是一款開(kāi)源的計(jì)算機(jī)系統(tǒng)和網(wǎng)絡(luò)監(jiān)視工具,能有效的監(jiān)控windows,linux和unix的主機(jī)狀態(tài),在系統(tǒng)和服務(wù)器狀態(tài)異常的時(shí)候發(fā)送電子郵件或短信報(bào)警,第一時(shí)間通知網(wǎng)站運(yùn)維成員,在狀態(tài)恢復(fù)后發(fā)出正常的電子郵件或短信通知。

Nagios四種監(jiān)控狀態(tài):

v 0(OK)表示狀態(tài)正常/綠色

v 1(WARNING)表示出現(xiàn)警告/×××

v 2(CRITICAL)表示出現(xiàn)非常嚴(yán)重的錯(cuò)誤/紅色

v 3(UNKNOWN)表示未知錯(cuò)誤/深×××

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

Nagios配置思想:

要監(jiān)控那臺(tái)主機(jī),監(jiān)控主機(jī)上那些服務(wù),我要在什么時(shí)間段內(nèi)做監(jiān)控,當(dāng)被監(jiān)控端出現(xiàn)故障時(shí)我要給那個(gè)聯(lián)系人發(fā)送郵件通知。

Nagios配置文件路徑:/usr/local/nagios/etc/

Nagios的配置文件解析:

v Nagios.cfg:主配置文件,定義其他配置文件存放位置

v Hostgroups.cfg:主機(jī)組配置文件,定義主機(jī)組

v Contacts.cfg:聯(lián)系人配置文件,定義聯(lián)系人和聯(lián)系人組

v Commands.cfg:命令配置文件,定義使用那些命令做監(jiān)控

v Timeperiods.cfg:時(shí)間段配置文件,定義在那個(gè)時(shí)間范圍做監(jiān)控

v Templates.cfg:模板文件,用于資源引用

v Localhost.cfg:本地主機(jī)配置文件,用于監(jiān)控本地

部署nagios監(jiān)控系統(tǒng):

關(guān)閉防火墻

#iptbles -F

#setenforce 0

創(chuàng)建nagios運(yùn)行用戶和組,創(chuàng)建安裝目錄,授權(quán)目錄

#useradd  -s /sbin/nologin  nagios

#mkdir /usr/local/nagios

#chown -R nagios.nagios   /usr/local/nagios

編譯安裝nagios軟件

#tar xzvf nagios-4.0.1.tar.gz

#cd agios-4.0.1

#./configure --prefix=/usr/local/nagios

#make all

#make install

#make install-init

#make install-commandmode

#make install-config

#chkconfig --add nagios

#chkconfig nagios on

安裝nagios-plugins插件

#tar xzvf nagios-plugins-1.5.tar.gz

#cd nagios-plugins-1.5

#./configure --prefix=/usr/local/nagios

#make && make install

安裝NRPE插件

#yum -y install openssl-devel

#tar xzvf nrpe-2.15.tar.gz

#cd nrpe-2.15

#./configure

#make all

#make install-plugin

安裝配置apche和PHP

#yum -y install httpd php

#vim /etc/httpd/conf/httpd.conf

添加相關(guān)內(nèi)容:Nagios的web頁(yè)面需要經(jīng)過(guò)授權(quán)才可以訪問(wèn)所以!

ScriptAlias  /nagios/cgi-bin "/usr/local/nagios/sbin"

    Options ExecCGI

    AllowOverride None

    Order allow,deny

    Allow from all

    Authname "Nagios Access"

    AuthType  Basic

    AuthUserFile /usr/local/nagios/etc/htpasswd.users    用于此目錄訪問(wèn)身份驗(yàn)證的文件

    Require  valid-user

Alias /nagios "/usr/local/nagios/share"

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

    Authname "Nagios Access"

    AuthType  Basic

    AuthUserFile /usr/local/nagios/etc/htpasswd.users

    Require  valid-user

#service httpd restart

創(chuàng)建web頁(yè)面的用戶為nagiosadm密碼為nagiosadm

# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadm

配置nagios系統(tǒng)

#vim /usr/local/nagios/etc/nagios.cfg

添加參數(shù):

cfg_dir=/usr/local/nagios/etc/conf         指定主機(jī)文件目錄

cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg     指定主機(jī)組文件位置

#mkdir /usr/local/nagios/etc/conf/         創(chuàng)建目錄

# cp localhost.cfg   /usr/local/nagios/etc/conf/192.168.254.129.cfg   拷貝主機(jī)文件

#vim  /usr/local/nagios/etc/conf/192.168.254.129.cfg        主機(jī)文件

修改內(nèi)容:

define host{                  被監(jiān)控主機(jī)

        use                     linux-server            調(diào)用模板參數(shù)

        host_name               web                  主機(jī)名

        alias                    web                  別名

        address                 192.168.254.129        被控主機(jī)地址

        }

define service{                被監(jiān)控主機(jī)服務(wù)

        use                    local-service             調(diào)用模板參數(shù)

        host_name              web                   主機(jī)名

        service_description       PING                   服務(wù)描述

        check_command         check_ping!100.0,20%!500.0,60% 使用的命令

        }

#vim /usr/local/nagios/etc/objects/hostgroups.cfg

define hostgroup{            被監(jiān)控主機(jī)組

        hostgroup_name   webs                       主機(jī)組名

        alias             webs                       主機(jī)組別名

        members         web                        成員主機(jī)(調(diào)用主機(jī))

}

#vim /usr/local/nagios/etc/objects/templates.cfg              模板文件

define host{

        name                   generic-host              模板名(主機(jī))

        notifications_enabled           1                 通告開(kāi)關(guān)

        event_handler_enabled         1                 事件處理開(kāi)關(guān)

        flap_detection_enabled         1                 移動(dòng)檢測(cè)開(kāi)關(guān)

        process_perf_data             1                 過(guò)程性能數(shù)據(jù)開(kāi)關(guān)

        retain_status_information       1                 保持狀態(tài)信息開(kāi)關(guān)

        retain_nonstatus_information    1                 保持無(wú)狀態(tài)信息開(kāi)關(guān)

        notification_period             24x7              通告周期(調(diào)用時(shí)間

        register                        0                不注冊(cè)

        }

define service{

        name                   generic-service          模板名(服務(wù))

        active_checks_enabled          1                存活檢查開(kāi)關(guān)

        passive_checks_enabled         1                被動(dòng)檢查開(kāi)關(guān)

        parallelize_check               1                并行化檢查開(kāi)關(guān)

        obsess_over_service            1                癡迷服務(wù)開(kāi)關(guān)

        check_freshness               0                檢查新的服務(wù)開(kāi)關(guān)

        notifications_enabled           1                通告開(kāi)關(guān)

        event_handler_enabled         1                 事件處理開(kāi)關(guān)

        flap_detection_enabled         1                 移動(dòng)監(jiān)測(cè)開(kāi)關(guān)

        process_perf_data             1                 過(guò)程性能數(shù)據(jù)開(kāi)關(guān)

        retain_status_information       1                 保持狀態(tài)信息開(kāi)關(guān)

        retain_nonstatus_information    1                 保持無(wú)狀態(tài)信息開(kāi)關(guān)

        is_volatile                    0                 服務(wù)是否不穩(wěn)定

        check_period                 24x7               檢查周期(調(diào)用時(shí)間

        max_check_attempts           3                  大檢查嘗試時(shí)間(分鐘)

        normal_check_interval          10                正常檢查間隔(分鐘)

        retry_check_interval            2                 重試檢查間隔(分鐘)

        contact_groups                admins            聯(lián)系人組(調(diào)用聯(lián)系人

        notification_options            w,u,c,r            通告告警級(jí)別

        notification_interval            60                通告間隔(分鐘)

        notification_period             24x7              通告周期(調(diào)用時(shí)間

         register                      0                 不注冊(cè)

        }

define contact{

        name                      generic-contact    模板名(聯(lián)系人)

        service_notification_period     24x7            服務(wù)通告周期(調(diào)用時(shí)間

        host_notification_period        24x7            主機(jī)通告周期(調(diào)用時(shí)間

        service_notification_options    w,u,c,r,f,s         服務(wù)告警級(jí)別

        host_notification_options       d,u,r,f,s          主機(jī)在什么狀態(tài)下發(fā)送通知

service_notification_commands notify-service-by-email 服務(wù)發(fā)送通知郵箱(調(diào)用命令)

  host_notification_commands     notify-host-by-email   主機(jī)發(fā)送通知郵箱(調(diào)用命令)

        register                        0                  不注冊(cè)

        }

define host{

        name                        linux-server        模板名(主機(jī))

        use                          generic-host       調(diào)用了模板中的參數(shù)

        check_period                  24x7             檢查周期(調(diào)用時(shí)間

        check_interval                 5                檢查間隔(分鐘)

        retry_interval                  1                重試間隔(分鐘)

        max_check_attempts           10               大嘗試時(shí)間(分鐘)

        check_command              check-host-alive     檢查命令(調(diào)用命令

        notification_period             workhours         通告周期(調(diào)用時(shí)間

        notification_interval            120               通告間隔(分鐘)

        notification_options            d,u,r             主機(jī)在什么狀態(tài)下發(fā)送通知

        contact_groups                admins           聯(lián)系人組(調(diào)用聯(lián)系人

        register                     0                 不注冊(cè)

}

define service{

        name                      local-service         模板名(服務(wù))

        use                        generic-service      調(diào)用模板中的參數(shù)

        max_check_attempts          4                 大檢查嘗試時(shí)間(分鐘)

        normal_check_interval         5                 正常檢查間隔(分鐘)

        retry_check_interval          1                  重試檢查間隔(分鐘)

        register                     0                 不注冊(cè)

        }

#vim /usr/local/nagios/etc/objects/timeperiods.cfg        時(shí)間文件

define timeperiod{

        timeperiod_name 24x7                        定義時(shí)間段名

        alias           24 Hours A Day, 7 Days A Week   定義時(shí)間別名

        sunday          00:00-24:00                 星期天

        monday          00:00-24:00                星期一

        tuesday         00:00-24:00                 星期二

        wednesday       00:00-24:00                星期三

        thursday        00:00-24:00                 星期四

        friday          00:00-24:00                 星期五

        saturday        00:00-24:00                 星期六

        }

define timeperiod{

        timeperiod_name workhours                  定義時(shí)間段名

        alias           Normal Work Hours           定義時(shí)間別名

        monday          09:00-17:00               星期一

        tuesday         09:00-17:00                星期二

        wednesday      09:00-17:00                星期三

        thursday        09:00-17:00                星期四

        friday           09:00-17:00                星期五

        }

#vim /usr/local/nagios/etc/objects/contacts.cfg                    聯(lián)系人文件

define contact{

        contact_name                    nagiosadmin           聯(lián)系人名

        use                             generic-contact        調(diào)用模板

        alias                            Nagios Admin           別名

        email                           867218859@qq.com      郵箱地址

        }

define contactgroup{

        contactgroup_name       admins                        聯(lián)系人組

        alias                   Nagios Administrators             聯(lián)系人組別名

        members                 nagiosadmin                   成員

        }

注釋:上面的是詳細(xì)的配置文件詳解

配置nagios文件經(jīng)驗(yàn):

對(duì)于全新的nagios只需要根據(jù)需求

定義主機(jī)文件:要監(jiān)控那臺(tái)主機(jī),該主機(jī)上用命令監(jiān)控那些服務(wù)

定義聯(lián)系人:要給那個(gè)聯(lián)系人發(fā)送通知,指定郵箱地址

定義時(shí)間段:在那個(gè)時(shí)間段發(fā)送通知

即可完成配置

check_ping!100.0,20%!500.0,60%意思是:使用check_ping命令檢測(cè)中,如果延遲延遲>=100或丟包率超過(guò)20%則觸發(fā)warning警告,如果延遲>=500,或丟包率超過(guò)60%,則觸發(fā)critical警告;否則不觸發(fā)警告。‘!’表示分割,‘,’表示或者

告警級(jí)別:w:warning警告  u:unknown未知錯(cuò)誤  c:critical嚴(yán)重錯(cuò)誤

主機(jī)狀態(tài):d:down關(guān)機(jī)  u:unreachable不可達(dá)  r:recovery恢復(fù)

關(guān)閉身份驗(yàn)證

#vim /usr/local/nagios/etc/cgi.cfg

修改內(nèi)容:

Use-authentication = 0

部署被控端

# yum -y install openssl openssl-devel

#useradd nagios -s /sbin/nologin

#mkdir /usr/local/nagios

#tar xzvf nagios-plugins-1.5.tar.gz

# cd nagios-plugins-1.5

#./configure --prefix=/usr/local/nagios

#make && make install

#tar xzvf nrpe-2.15.tar.gz

#cd nrpe-2.15

#./configure --prefix=/usr/local/nagios

#make  all && make install-plugin && make install-daemon && make install-daemon-config

#vim /usr/local/nagios/etc/nrpe.cfg

添加相關(guān)內(nèi)容:指定監(jiān)控服務(wù)器

allowed_hosts=127.0.0.1,192.168.254.128

commond[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

commond[check_load]=/usr/local/nagios/libexc/check_load -w 15,10,5 -c 30,25,20

# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d       啟動(dòng)nrpe服務(wù)

# netstat -lnupt | grep 5666                                     nrpe服務(wù)端口

監(jiān)控端測(cè)試nrpe是否正常

# /usr/local/nagios/libexec/check_nrpe  -H 192.168.254.129

重啟服務(wù)

# service nagios restart

Linux使用Sendmail發(fā)送郵件:
# yum -y install sendmail postfix mailx

# systemctl restart sendmail

發(fā)送郵件的方式:

# echo ‘內(nèi)容’ | mail -s ‘主題’ 郵箱地址

# mail -v 867218859@qq.com

>主題:

>內(nèi)容:

按快捷方式Ctrl+D。

Linux使用外部IMAP郵箱身份發(fā)送郵件方式:

郵箱協(xié)議:

SMTP:用于郵件的發(fā)送 端口號(hào):25

POP3:用于接收郵件 端口號(hào):110

IMAP:網(wǎng)絡(luò)郵箱協(xié)議,用于郵件在線傳輸。

# yum -y install mailx

# vim /etc/mail.rc

添加相關(guān)參數(shù):

set from=13590163240@163.com

set imap=imap.163.com

set imap-auth=login

set imap-auth-user=13590163240@163.com

set imap-auth-password=xyz110110

發(fā)送郵件的方式:

# echo ‘內(nèi)容’ | mail -s ‘主題’ 郵箱地址

# mail -v 867218859@qq.com

>主題:

>內(nèi)容:

按快捷方式Ctrl+D。

解決mail郵件不能發(fā)送問(wèn)題

報(bào)錯(cuò)信息

解決方法

#Cat /var/log/maillog

DSN: Service unavailable

更換hostname:

1.編輯/etc/sysconfig/network,更改hostname

2.把hostname寫(xiě)入/etc/hosts

3.執(zhí)行hostname www.a.com臨時(shí)修改

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+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)景需求。


名稱欄目:50.nagios監(jiān)控工具-創(chuàng)新互聯(lián)
文章分享:http://weahome.cn/article/shgch.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部