免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

搭建nagios監(jiān)控系統(tǒng)

1、軟件包準(zhǔn)備

成都創(chuàng)新互聯(lián)公司是一家以重慶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、品牌設(shè)計、軟件運維、seo優(yōu)化、小程序App開發(fā)等移動開發(fā)為一體互聯(lián)網(wǎng)公司。已累計為成都酒樓設(shè)計等眾行業(yè)中小客戶提供優(yōu)質(zhì)的互聯(lián)網(wǎng)建站和軟件開發(fā)服務(wù)。

nagios-4.0.8.tar.gz

nagios-plugins-2.0.3.tar.gz

nrpe-2.15.tar.gz

httpd-2.2.23.tar.gz

2、Nagios Server端安裝

1)、安裝相關(guān)依賴包

yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel

2)、安裝Nagios

# useradd -s /sbin/nologin nagios

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

# make all

# make install

# make install-init

# make install-commandmode

# make install-config

# chkconfig nagios on

# chkconfig --list | grep nagios 

3)、安裝Nagios插件

# tar zxvf nagios-plugins-2.0.3.tar.gz

# cd nagios-plugins-2.0.3

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

# make && make install

4)、安裝配置apache

# tar zxvf httpd-2.2.23.tar.gz

# cd httpd-2.2.23

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

# make && make install

# vim /usr/local/apache2/conf/http.conf

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

User daemon 

Group daemon

修改為

User nagios

Group nagios

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<IfModule dir_module> 

  DirectoryIndex index.html 

</IfModule> 

修改并增加為 

<IfModule dir_module> 

  DirectoryIndex index.html index.php 

</IfModule>

AddType application/x-httpd-php .php 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

增加驗證配置,即在httpd.conf 文件最后添加如下信息: 

#setting for nagios 

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

<Directory "/usr/local/nagios/sbin"> 

AuthType Basic 

Options ExecCGI 

AllowOverride None 

Order allow,deny 

Allow from all 

AuthName "Nagios Access" 

AuthUserFile /usr/local/nagios/etc/htpasswd 

Require valid-user 

</Directory> 

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

<Directory "/usr/local/nagios/share"> 

AuthType Basic 

Options None 

AllowOverride None 

Order allow,deny 

Allow from all 

AuthName "nagios Access" 

AuthUserFile /usr/local/nagios/etc/htpasswd 

Require valid-user 

</Directory> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

創(chuàng)建上面的目錄驗證文件htpasswd

# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios

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

修改配置文件中所有含有nagiosadmin的內(nèi)容

nagiosadmin => nagiosadmin,nagios

# scp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

# vim /etc/init.d/httpd

添加以下內(nèi)容

# chkconfig: 2345 85 15

# description: Apache is a World Wide Web Server

# chkconfig httpd on

# chkconfig --list | grep httpd

5)、安裝配置php

# tar zxvf php-5.4.10.tar.gz

# cd php-5.4.10

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

# make && make install

# service httpd start

# service nagios start

6)、安裝nrpe

# tar zxvf nrpe-2.15.tar.gz

# cd nrpe-2.15

# ./configure --enable-command-args

# make all

# make install-plugin

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

NRPE v2.15

7)、配置commands.cfg,添加check_nrpe定義

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

# 'check_nrpe' command definition

define command{

command_name    check_nrpe         

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

}

8、配置hosts.cfg

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

define host{

use                     linux-server

host_name               node.3

alias                   node.3

address                 10.0.2.203

}

9、配置node.3.cfg(也就是node.3的services.cfg文件,為了便于管理,每臺機器的services.cfg文件分開配置,并以主機名命名)

vim /usr/local/nagios/etc/objects/node.3.cfg

define service{

use                     local-service

host_name               node.3

service_description     Current Load

check_command           check_nrpe!check_load

contact_groups          admins

}

define service{

use                     local-service

host_name               node.3

service_description     Check Disk disk

check_command           check_nrpe!check_disk

contact_groups          admins

}

define service{

use                     local-service

host_name               node.3

service_description     Total Processes

check_command           check_nrpe!check_total_procs

contact_groups          admins

}

define service{

use                     local-service

host_name               node.3

service_description     Current Users

check_command           check_nrpe!check_users

contact_groups          admins

}

define service{

use                     local-service

host_name               node.3

service_description     Check Zombie Procs

check_command           check_nrpe!check_zombie_procs

contact_groups          admins

}

10)、配置nagios.cfg

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

添加以下內(nèi)容

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

cfg_file=/usr/local/nagios/etc/objects/node.3.cfg

11)、檢查nagios配置文件,并重啟nagios服務(wù)

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

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# service nagios restart

3、Nagios Client端的配置安裝

1)、安裝相關(guān)軟件包

yum install -y xinetd openssl*

2)、添加用戶

useradd nagios

passwd nagios

3)、安裝nagios插件

# tar zxvf nagios-plugins-2.0.3.tar.gz

# cd nagios-plugins-2.0.3

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

# make && make install

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

4)、安裝nrpe

# tar zxvf nrpe-2.15.tar.gz

# cd nrpe-2.15

# ./configure --enable-command-args

# make all

# make install-plugin

# make install-daemon

# make install-daemon-config

# make install-xinetd

# vim /etc/services

在文件最后追加以下內(nèi)容

nrpe            5666/tcp                # nrpe

# vim /etc/xinetd.d/nrpe

添加監(jiān)控主機IP

only_from       = 127.0.0.1 10.0.2.201

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

修改

dont_blame_nrpe=1

# service xinetd restart

# lsof -i:5666

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

NRPE v2.15

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

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

修改

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

4、添加MySQL和tomcat的監(jiān)控

1)、添加mysql監(jiān)控

Nagios Server:

# vim /usr/local/nagios/etc/objects/commands

添加以下內(nèi)容

# 'check_mysql' command definition

define command{

command_name    check_mysql

command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ $ARG3$

}

# vim /etc/ld.so.conf 

追加以下內(nèi)容

/usr/local/mysql/lib/#因為check_mysql會提示找不到libmysqlclient.so.18文件

# /sbin/ldconfig -v

# /usr/local/nagios/libexec/check_mysql -H 10.0.2.203 -u mysql -p 123456

# vim /usr/local/nagios/etc/objects/node.3.cfg

追加以下內(nèi)容

define service{

use                     local-service

host_name               node.3

service_description     Check MySQL

check_command           check_nrpe!check_mysql!mysql!123456

contact_groups          admins

}

Nagios Client:

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

添加以下內(nèi)容

command[check_mysql]=/usr/local/nagios/libexec/check_mysql -u $ARG1$ -p $ARG2$

# vim /etc/ld.so.conf 

追加以下內(nèi)容

/usr/local/mysql/lib/#因為check_mysql會提示找不到libmysqlclient.so.18文件

# /sbin/ldconfig -v

2)、添加自定義tomcat監(jiān)控

Nagios Server:

# vim /usr/local/nagios/etc/objects/commands

添加以下內(nèi)容

# 'check_tomcat' command definition

define command{

command_name    check_tomcat

command_line    $USER1$/check_tomcat -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ 

}

# vim /usr/local/nagios/etc/objects/node.3.cfg

追加以下內(nèi)容

define service{

use                     local-service

host_name               node.3

service_description     Check Tomcat

check_command           check_nrpe!check_tomcat!tomcat

contact_groups          admins

}

# service nagios restart

Nagios Client:

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

添加以下內(nèi)容

command[check_tomcat]=/usr/local/nagios/libexec/check_tomcat $ARG1$

# vim /usr/local/nagios/libexec/check_tomcat

#!/bin/sh

name=`basename $0`

process=`ps aux |grep -w "$1" | grep -vE "grep|$name"|wc -l |tr -d ' '`

if [ $process -ge 1 ]

then

   echo  "$1 proces running...."

   exit 0

else

   echo  "$1 proces no exist! "

   exit 2

fi

5、windows系統(tǒng)的監(jiān)控

解壓NSClient++-0.2.7.zip到C盤根目錄

命令行:cmd

>c:\NSClient++-0.2.7

>nsclient++ /install

>nsclient++ SysTray

命令行:services.msc 

找到NSClientpp服務(wù),雙擊打開,點擊”登錄“標(biāo)簽,在”允許服務(wù)與桌面交互“前打勾

編輯c:\NSClient++-0.2.7\NSC.ini

[modules]模塊

去掉除CheckWMI.dll和 RemoteConfiguration.dll 以外行的”;“

[Settings]

去掉password行的注釋,并設(shè)置密碼123456,同時需要在Nagios Server端command.cfg配置文件中check_nt命令定義處配置對應(yīng)的密碼

define command{

command_name    check_nt

command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s 123456 -v $ARG1$ $ARG2$

}

去掉allowed_hosts行的注釋,并將本行修改為allowed_hosts=127.0.0.1/32,10.0.2.201

[NSClient]

去掉port行前面的注釋,并設(shè)置port=12489

6、配置報警

1)、聲音報警

Nagios Server端

上傳音樂文件到/usr/local/nagios/share/media文件夾中

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

取消以下行前的”#“

host_unreachable_sound=hostdown.wav

host_down_sound=hostdown.wav

service_critical_sound=critical.wav

service_warning_sound=warning.wav

service_unknown_sound=warning.wav

normal_sound=noproblem.wav

2)、郵件報警

# yum install -y sendmail*

# service sendmail start

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

修改

emailnagios@local.com => email*******@qq.com

# service nagios restart

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

修改generic-service中

notification_interval60 => notification_interval5

修改local-service中

max_check_attempts 4 => max_check_attempts 1 

normal_check_interval5 => normal_check_interval5

retry_check_interval2 => retry_check_interval1

表示每五分鐘發(fā)送一次郵件報警,關(guān)于nagios報警時間的詳細配置,請參考”關(guān)于nagios報警時間間隔的配置“一文。

文章標(biāo)題:搭建nagios監(jiān)控系統(tǒng)
當(dāng)前網(wǎng)址:http://m.newbst.com/article48/jhechp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站網(wǎng)站排名外貿(mào)網(wǎng)站建設(shè)品牌網(wǎng)站建設(shè)定制開發(fā)域名注冊

廣告

聲明:本網(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)站托管運營