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

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

Nagios監(jiān)控實例部署

Nagios是一款企業(yè)級開源軟件,專注于監(jiān)控服務器上服務是否正常,不生成圖形,提供報警機制,郵件或者短信發(fā)送監(jiān)控狀態(tài),它通過各種插件實現(xiàn)不同的功能。

成都創(chuàng)新互聯(lián)從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都網(wǎng)站建設、成都做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元京山做網(wǎng)站,已為上家服務,為京山各地企業(yè)和個人服務,聯(lián)系電話:13518219792

Nagios        監(jiān)控平臺主程序

Nagios-plugins     必選插件

NRPE         監(jiān)控遠程服務器的主機資源

NSClient++      用于監(jiān)控Windows主機

NDOUtils       將數(shù)據(jù)寫入數(shù)據(jù)庫

實例應用:

1 監(jiān)控快速部署

監(jiān)控需要安裝http php nagios nagios-plugins NRPE軟件包

yum install -y gd gd-devel openssl openssl-devel httpd php gcc glibc glib-common make wget

net-snmp

setenforce 0

iptables -F

安裝nagios 源碼包下載安裝

wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz/download

groupadd nagios

useradd -g nagios nagios

tar -zxf nagios-3.5.0.tar.gz -C /usr/src/

cd /usr/src/nagios

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make all

make install

make install-init             #安裝啟動腳本

make install-commandmode          #安裝與配置目錄權限

make install-config            #安裝配置文件模板

make install-webconf            #web監(jiān)控界面配置

安裝nagios-plugins和nrpe

wget   http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz

tar -zxf nagios-plugins-1.4.16.tar.gz -C /usr/src/

cd /usr/src/nagios-plugins-1.4.16

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

make && make install

wget wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

tar -zxf nrpe-2.14.tar.gz -C /usr/src/

cd /usr/src/nrpe-2.14

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

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

創(chuàng)建賬戶信息

htpasswd -c /usr/local/nagions/etc/htpasswd.users tomcat

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

service iptables save

啟動服務

service httpd start

/etc/init.d/nagios start

chkconfig httpd on

chkconfig --add nagios

chkconfig nagios on


2 修改配置文件

nagios的配置文件較多,主要位于/usr/local/nagios/etc 下

nagios.conf             主配置文件

nrpe.cfg                    遠程監(jiān)控配置文件

cgi.conf                    CGI配置文件

commands.cfg            命令定義文件

contacts.cfg                定義聯(lián)系人文件

timepreriods.cfg              時間周期定義文件

tempaltes.cfg                    對象定義參考模板

localhost.cfg                    監(jiān)控本機配置模板

printer.cfg                        監(jiān)控打印機模板

switch.cfg                            監(jiān)控交換模板

windows.cfg                        監(jiān)控Windows配置模板


很多配置文件無需修改可以直接使用

修改主配置文件nagios.cfg,主要是用cfg_file配置加載其他配置文件。

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

cfg_file=/usr/local/nagios/etc/objects/commands.cfg

cfg_file=/usr/local/nagios/etc/objects/contacts.cfg

cfg_file=/usr/local/nagios/etc/objects/templates.cfg

cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg

cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

cfg_file=/usr/local/nagios/etc/web1.cfg

cfg_file=/usr/local/nagios/etc/web2.cfg


修改CGI配置文件cgi.cfg,添加tomcat賬戶進來

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

default_user_name=tomcat

authorized_for_system_information=nagiosadmin,tomcat

authorized_for_configuration_information=nagiosadmin,tomcat

authorized_for_system_commands=nagiosadmin,tomcat

authorized_for_all_services=nagiosadmin,tomcat

authorized_for_all_hosts=nagiosadmin,tomcat

authorized_for_all_service_commands=nagiosadmin,tomcat

authorized_for_all_host_commands=nagiosadmin,tomcat


修改命令配置文件command.cfg,定義命令實現(xiàn)的方式,如郵件報警,使用工具,內(nèi)容格式等。

vim /usr/local/nagios/etc/objects/commands.cfg

define command{

       command_name    check_nrpe

       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$

       }

define command{

       command_name    check_nrpe_args

       command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a $ARG2$

       }

修改聯(lián)系人配置文件contacts.cfg 報警的聯(lián)系人及聯(lián)系方式

define contact{

       contact_name                    nagiosadmin             

       use                             generic-contact         

       alias                           Nagios Admin            

       email                           yourname@domain.com 

       }


修改報警時間周期timeperiods.cfg

vim /usr/local/nagios/etc/objects/timeperiods.cfg

define timeperiods{

       timeperiod_name 24x7   #監(jiān)控所有時間段(7*24小時)

       alias           24 Hours A Day, 7 Days A Week
       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
       }

修改本機的配置localhost.cfg

define host{

       use                          linux-server

       host_name                    duangr-1

       alias                        duangr-1

       address                      192.168.56.10

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Host Alive

       check_command                   check-host-alive

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Users

       check_command                   check_local_users!20!50

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             CPU

       check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Disk Root

       check_command                   check_local_disk!20%!10%!/

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Disk Home

       check_command                   check_local_disk!20%!10%!/export/home

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Zombie Procs

       check_command                   check_local_procs!5!10!Z

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Total Procs

       check_command                   check_local_procs!250!400!RSZDT

       }

define service{

       use                             local-service

       host_name                       duangr-1

       service_description             Swap Usage

       check_command                   check_local_swap!20!10

       }

修改模板文件templates.cfg

vi /usr/local/nagios/etc/objects/templates.cfg

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

define contact{

        name                            generic-contact        

        service_notification_period     24x7                    

        host_notification_period        24x7                    

        service_notification_options    w,u,c,r,f,s            

        host_notification_options       d,u,r,f,s               

        service_notification_commands   notify-service-by-email 

        host_notification_commands      notify-host-by-email    

        register                        0                       

        }

#定義generic-host主機模板

define host{

        name                            generic-host    

        notifications_enabled           1               

        event_handler_enabled           1               

        flap_detection_enabled          1              

        failure_prediction_enabled      1              

        process_perf_data               1              

        retain_status_information       1              

        retain_nonstatus_information    1              

        notification_period             24x7           

        register                        0              

        }

#定義Linux主機模板

define host{

        name                            linux-server    

        use                             generic-host    

        check_period                    24x7            

        check_interval                  5               

        retry_interval                  1              

        max_check_attempts              10              

        check_command                   check-host-alive 

        notification_period             workhours       

                                                        

                                                        

        notification_interval           120             

        notification_options            d,u,r           

        contact_groups                  admins          

        register                        0               

        }


創(chuàng)建遠程監(jiān)控web1.cfg

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

define host{
       use                     linux-server
       host_name               duangr-2
       alias                   duangr-2
       address                 192.168.56.11
       }

define service{
       use                             local-service
       host_name                       duangr-2
       service_description             Host Alive
       check_command                   check-host-alive
       }
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             Users
       check_command                   check_nrpe_args!check_users!5 10
       }
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             CPU
       check_command                   check_nrpe_args!check_load!15,10,5 30,25,20
       }
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             Disk Root
       check_command                   check_nrpe_args!check_disk!20% 10% /
       }
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             Disk /export/home
       check_command                   check_nrpe_args!check_disk!20% 10% /export/home
       }
define service{
      use                             local-service
      host_name                       duangr-2
      service_description             Procs Zombie
      check_command                   check_nrpe_args!check_procs!5 10 Z
      }
define service{
      use                             local-service
      host_name                       duangr-2
      service_description             Procs Total
      check_command                   check_nrpe_args!check_procs_args!"-w400 -c600"      }
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             Swap Usage
       check_command                   check_nrpe_args!check_swap!20% 10%
       }

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  下面是一些常用進程的監(jiān)控,主要是云平臺相關進程
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 監(jiān)控crond進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: crond
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Ccrond"       }
;; 監(jiān)控zookeeper進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: QuorumPeerMain
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.quorum.QuorumPeerMain"       }
;;監(jiān)控storm的從節(jié)點進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: supervisor
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -adaemon.supervisor"       }
;; 監(jiān)控storm的主節(jié)點進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: nimbus
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -adaemon.nimbus"       }
;; 監(jiān)控MetaQ進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: MetaQ
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -ametamorphosis-server-w"       }
;; 監(jiān)控redis進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: redis-server
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Credis-server"       }
;; 監(jiān)控hadoop主節(jié)點NameNode進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: NameNode 
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.namenode.NameNode"       }
;; 監(jiān)控hadoop主節(jié)點SecondaryNameNode進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: SecondaryNameNode
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.namenode.SecondaryNameNode"       }
;; 監(jiān)控hadoop主節(jié)點ResourceManager進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: ResourceManager
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.resourcemanager.ResourceManager"       }
;; 監(jiān)控hadoop從節(jié)點DataNode進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: DataNode
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.datanode.DataNode"       }
;;監(jiān)控hadoop從節(jié)點NodeManager進程
define service{
       use                             local-service
       host_name                       duangr-2
       service_description             PS: NodeManager
       check_command                   check_nrpe_args!check_procs_args!"-c1:1 -Cjava -aserver.nodemanager.NodeManager"       }

由于duangr-2是遠程主機,因此使用check_nrpe_args命令來監(jiān)控.

/etc/init.d/nagios restart

快速定位配置文件問題所在命令

/usr/local/nagios/bin/nagios -V /usr/local/nagios/etc/nagios.cfg


3 被監(jiān)控機安裝軟件  nagios-plugin  nrpe

yum install -y openssl openssl-devel

groupadd nagios

useradd -g nagios -s /sbin/nologin nagios

tar -zxf nagios-plugins-2.1.6.tar.gz -C /usr/src/

cd /usr/src/nagios-plugins-2.1.6

./configure  --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios

make && make install

tar -zxf nrpe-2.14.tar.gz -C /usr/src/

cd /usr/src/nrpe-2.14

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config


修改客戶端的NRPE配置文件

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

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

command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2

command[check_swap]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/shm

command[check_home]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/VolGroup00-LogVol00

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 200 -c 300

command[check_ping81]=/usr/local/nagios/libexec/check_ping -H 10.155.0.1 -w 100.0,20% -c 500.0,60%#

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1


/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local

netstat -lnupt |grep 5666

iptables -I INPUT -p tcp --dport 5666 -j ACCEPT

service iptables save


檢查監(jiān)控命令配置是否ok

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users  -a 5 10

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load   -a 15,10,5 30,25,20

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_disk   -a 20% 10% /

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_procs  -a 200 400 RSZDT

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_swap   -a 20% 10%

沒有問題就可以用瀏覽器訪問nagios了


網(wǎng)頁名稱:Nagios監(jiān)控實例部署
文章鏈接:http://weahome.cn/article/jcjecs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部