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

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

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)-創(chuàng)新互聯(lián)

Nagios的功能以及它所使用的場(chǎng)景在此不必多說(shuō).網(wǎng)上很多這方面資料.本文主要介紹Nagios-SNMP-Plugins 來(lái)實(shí)現(xiàn)對(duì)企業(yè)中的服務(wù)器的硬件的監(jiān)控,如:磁盤(pán),CPU ,內(nèi)存,網(wǎng)卡等在出現(xiàn)異?;蚧謴?fù)時(shí)通知管理員并使用PNP插件結(jié)合rrdtool實(shí)現(xiàn)繪圖

創(chuàng)新互聯(lián)主要從事成都做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)高密,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專(zhuān)業(yè),歡迎來(lái)電咨詢(xún)建站服務(wù):18980820575

一.實(shí)驗(yàn)環(huán)境

1.監(jiān)控機(jī):CentOS5.4_x32(192.168.1.253)

2.兩臺(tái)被監(jiān)控機(jī)器:Windows (192.168.1.206),Linux(192.168.1.124)

3.所需軟件:

    Nagios3.3.1

    Nagios-plugins-1.4.16

    Nagios-snmp-plugins.1.1.1

    Rrdtool

    Pnp4nagios-0.6.18

    sendEmail

二.部署過(guò)程

1.確保系統(tǒng)開(kāi)發(fā)組件已安裝

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

2.使用yum安裝LAMP環(huán)境

  yum -y install php php-cli php-common php-pdo php-gd php-mysql php-devel php-mbstrin

  yum -y install httpd httpd-devel system-config-httpd

  yum -y install mysql-devel mysql-server mysql

  yum -y install gd gd-devel

注:以上組件件中有PHP擴(kuò)展,關(guān)于gd gd-devel必需安裝不然map會(huì)出現(xiàn)異常.ndo2db會(huì)將的nagios信息轉(zhuǎn)入MySQL數(shù)據(jù)庫(kù)

3.啟動(dòng)Apache和MySQL

  chkconfig --add httpd || chkconfig httpd on//添加apache服務(wù)開(kāi)機(jī)啟動(dòng)

  chkconfig --add mysqld || chkconfig mysqld on  //添加MySQL服務(wù) 開(kāi)機(jī)啟動(dòng)

  service httpd restart  啟動(dòng)Apache

  service mysqld restart 啟動(dòng)MySQL

4.建立php測(cè)試文件,并驗(yàn)證

  vim /var/www/index.php

  

    phpinfo();

  ?>

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

三.依次安裝所需軟件

1.安裝Nagios

  groupadd nagcmd

  useradd -G nagcmd nagios

  passwd nagios //手動(dòng)設(shè)置密碼

  usermod -a -G nagcmd apache

  cd nagios-3.3.1

  ./configure --with-command-group=nagcmd --enable-event-broker //--enable-enevnt-broker參數(shù)用于實(shí)現(xiàn)NDO的功能

  make all

  make install

  make install-init

  make install-commandmode

  make install-config

  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin //指定Nagios的web接口登錄密碼

  make install-webconf

2.安裝Nagios-plugins

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

  make

  make install

  chkconfig --add nagios || chkconfig nagios on //配置Nagios開(kāi)機(jī)啟動(dòng)

  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg //檢測(cè)無(wú)異常即可以啟動(dòng)服務(wù)

  service nagios restart //重啟apache服務(wù)

  service httpd restart //啟動(dòng)nagios服務(wù)

3.安裝Nagios-snmp-plugins

  Crypt-DES-2.07.tar.gz

  Digest-HMAC-1.03.tar.gz

  Digest-MD5-2.53.tar.gz

  Digest-SHA1-2.13.tar.gz

  Net-SNMP-v6.0.1.tar.gz

  分別解壓進(jìn)入各目錄執(zhí)行以下操作

  perl Makefile

  make test

  make install

  tar -zxvf nagios-snmp-plugins.tar.gz

  cd nagios_plugins

  ./install //依次回車(chē)即可,完成后會(huì)在/usr/local/nagios/libexec目錄中生成相應(yīng)的健康腳本

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

重啟apache 和nagios

瀏覽器中輸入:http://192.168.1.253/nagios

用戶(hù)名:nagiosadmin

密碼:上面設(shè)置的密碼

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

三.配置監(jiān)控

1,配置/usr/local/.nagios/etc/object/command.cfg文件,在文件結(jié)尾處添加以下內(nèi)容.

###############################SNMP

define command {

command_name      check_tcpport

command_line      $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ -w $ARG2$ -c $ARG3$

}

define command {

command_name      check_snmp_disk

command_line      $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ $USER7$ -p $ARG1$ -m $ARG2$ -w $ARG3$ -c $ARG4$

}

define command {

command_name      check_snmp_mem

command_line      $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ $USER7$ -p $ARG1$ -m $ARG2$ -w $ARG3$ -c $ARG4$ -f

}

define command {

command_name      check_snmp_cpuload

command_line      $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ $USER7$ -p $ARG1$ -w $ARG2$ -c $ARG3$ -f

}

(-f 不可缺少否則無(wú)法出圖)

配置監(jiān)控之前先檢測(cè)被檢控主機(jī)狀態(tài),被控機(jī)上開(kāi)啟SNMP服務(wù)并配置好團(tuán)體名及所接收來(lái)自哪些區(qū)域的請(qǐng)求.

windows

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

linux

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

測(cè)試成功就可以進(jìn)行配置了.

2.定義監(jiān)控主機(jī)

 在nagios.cfg中開(kāi)啟被監(jiān)控主機(jī)的目錄

  開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

添加windows主機(jī)監(jiān)控文件開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

以下為192.168.1.206這臺(tái)機(jī)器的監(jiān)控配置

define host{

    use       windows-server

    host_name    web-192.168.1.206

    alias      My Windows Server

    address     192.168.1.206

    hostgroups    windows-server

    }

##################################### //這里是分組,注,分組中需要指定一次

define hostgroup{

    hostgroup_name  windows-server

    alias      windows-server

}

define hostgroup{

    hostgroup_name  linux-server

    alias      linux-server

}

#####################################

define service{

    use           generic-service

    host_name        web-192.168.1.206

    service_description   PING

    check_command      check_ping!100.0,20%!500.0,60%!5

    }

###########Memory

define service{

    use           generic-service

    host_name        web-192.168.1.206

    service_description   Memor

    check_command      check_snmp_mem!161!"Physical Memory"!10!20

檢測(cè)語(yǔ)法是否有錯(cuò)

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

無(wú)報(bào)錯(cuò)即可重啟nagios 服務(wù)

service nagios restart

刷新監(jiān)控頁(yè)面

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

三.配置監(jiān)控對(duì)像使用量繪圖功能

1.安裝cgilib

tar -zxvf cgilib-0.6.tar.gz

cd cgilib-0.6

make

cp aux.h /usr/include/

cp cgi.h /usr/include/

cp libcgi.a /usr/lib/

2.安裝rrdtool

yum -y install ruby

yum -y install pango pango-devel

rpm -ivh rrdtool *

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

3.安裝PNP

cd pnp4nagios-0.6.18

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata

make all

make install

make install-config

4.配置apache

vi /etc/httpd/conf/httpd.conf

末尾添加如下信息

Alias /pnp4nagios "/usr/local/pnp4nagios/share"

    AllowOverride None

    Order allow,deny

    Allow from all

    AuthName "Nagios Access"

    AuthType Basic

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

    Require valid-user

    

        RewriteEngine On

        Options FollowSymLinks

        RewriteBase /pnp4nagios/

        RewriteRule ^(application|modules|system) - [F,L]

        RewriteCond %{REQUEST_FILENAME} !-f

        RewriteCond %{REQUEST_FILENAME} !-d

        RewriteRule .* index.php/$0 [PT,L]

    

5.配置template.cfg

define host {

 name    host-pnp

 action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_

 register  0

}

define service {

 name    srv-pnp

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$

 register  0

}

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

6.配置commands.cfg

先注釋原有的再添加

define command {

   command_name  process-service-perfdata

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

}

define command {

   command_name  process-host-perfdata

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

}

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

7.配置nagios.cfg

process_performance_data=1

enable_environment_macros=1

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

8.更新PHP至 5.2(CentOS 6.2可yum安裝)

yum install php-gd

rpm --import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy

wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo

yum --enablerepo=webtatic --exclude=php*5.3* list php

yum --enablerepo=webtatic --exclude=php*5.3* update -y php

驗(yàn)證:

rpm -qa |grep php

service httpd restart

測(cè)試PNP .刪除或移動(dòng)/usr/local/pnp4nagios/share/install.php配

9.為主機(jī)或服務(wù)配置繪圖

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

重新啟動(dòng)服務(wù).并查看監(jiān)控頁(yè)面.需要等一會(huì)才能出圖

service httpd restart

service nagios restart

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

三.配置監(jiān)控LINUX主機(jī)也一樣,調(diào)用的模版文件改成linux-server.分組使用linux-server,前面定義過(guò)分組這里不用定義

cd /usr/local/nagios/etc/object/linux

vim 192.168.1.124.cfg

define host{

    use       linux-server,host-pnp

    host_name    web-192.168.1.124

    alias      My Linux Server

    address     192.168.1.124

    hostgroups    linux-server

    }

#####################################

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   PING

    check_command      check_ping!100.0,20%!500.0,60%!5

    }

###########Memory

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   Mem

    check_command      check_snmp_mem!161!"Real Memory"!90!99

    }

###########disk/

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   disk-/

    check_command      check_snmp_stro!161!/!80!90

    }

#####CPU

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   cpuload

    check_command      check_snmp_cpuload!161!80!90

    }

###########Traffic

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   eth0

    check_command      check_snmp_traffic!2!200,100!300,200

    }

#####Process

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   httpd

    check_command      check_snmp_proc!httpd!3!20!100,200

    }

define service{

    use           generic-service,srv-pnp

    host_name        web-192.168.1.124

    service_description   port80

    check_command      check_tcpport!80!0.0023!0.0067

    }

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

五:配置告警功能

1.定義宏變量

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

2.sendEmail的用法

下載 wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

tar -zxvf sendEmail

cd sendEmail

cp -p sendEmail  /usr/local/bin

檢測(cè)發(fā)信

/usr/local/bin/sendEmail –f nagios@test.com –t yahoon@test.com –s mail.test.com –u “from nagios” –xu nagios –xp p#3isoda –m happy

解釋:-f 表示發(fā)送者的郵箱

-t 表示接收者的郵箱

-s 表示SMTP服務(wù)器的域名或者ip

-u 表示郵件的主題-xu

表示SMTP驗(yàn)證的用戶(hù)名-xp

表示SMTP驗(yàn)證的密碼(注意,這個(gè)密碼貌似有限制,例如我用d!5neyland就不能被正確識(shí)別)

-m 表示郵件的內(nèi)容

注:以上內(nèi)容來(lái)源于網(wǎng)絡(luò)

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

添加告警配置

# 'notify-service-by-email' command definition

define command{

   command_name notify-host-by-email

   command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTA

TE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n" | /usr/local/bin/sendEmail -s $USER8$ -xu $USER9$ -xp $US

ER10$ -t $CONTACTEMAIL$ -f $USER9$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***

** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$

nnDate/Time: $LONGDATETIME$n"

}

# 'notify-service-by-email' command definition

define command{

   command_name notify-service-by-email

   command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $H

OSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$" | /usr/local/b

in/sendEmail -s $USER8$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER9$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Servic

e Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SE

RVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTP

UT$"

}

定義聯(lián)系人,可以定義多個(gè)用逗號(hào)隔開(kāi)

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

關(guān)掉系統(tǒng)自帶的sendmai

service sendmail stop

chkconfig sendmail off

重啟服務(wù).觀測(cè)頁(yè)面上的notification選項(xiàng)和上面定義的收信郵箱

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)

本次實(shí)驗(yàn)先做到這里,稍后附上ndo2db+nagvis的配置..

另外有需要云服務(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ù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。


文章標(biāo)題:開(kāi)源監(jiān)控軟件Nagios之SNMP實(shí)戰(zhàn)-創(chuàng)新互聯(lián)
文章來(lái)源:http://weahome.cn/article/codojs.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部