去官方下載最新的版本nagios-4.0.8 http://www.nagios.org/download/core
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了合江免費(fèi)建站歡迎大家使用!
[root@nagios nagios]# tar zxvf nagios-4.0.8.tar.gz
[root@nagios nagios-4.0.8]# make all
[root@nagios nagios-4.0.8]# make install
[root@nagios nagios-4.0.8]# make install-init
[root@nagios nagios-4.0.8]# make install-commandmode
[root@nagios nagios-4.0.8]# make install-config
[root@nagios nagios-4.0.8]# make install-webconf
[root@nagios nagios-4.0.8]# make install-exfoliation
[root@nagios nagios-4.0.8]# make install-classicui
2:安裝插件 nagios-plugins-2.0.3.tar.gz http://www.nagios.org/download/plugins
./configure&&make&&make install
ln -s /usr/local/nagios /etc/nagios
個(gè)性化的插件都拷貝到/etc/nagios/libexec 下
3:安裝iostat_plugins 需要如下rpm包包
[root@nagios iostat_plugins]# ls -h
perl-Class-Accessor-0.31-1.el5.rf.noarch.rpm perl-Params-Validate-0.89-1.el5.rf.i386.rpm
perl-Config-Tiny-2.12-1.el5.rf.noarch.rpm perl-Regexp-Common-2.120-1.2.el5.rf.noarch.rpm
perl-Math-Calc-Units-1.06-1.el5.rf.noarch.rpm
如下插件都可以網(wǎng)上找 主要是check_traffic.sh
cp check_memory.pl check_iostat check_file_des check_inode check_netstat check_traffic.sh /usr/local/nagios/libexec
chmod 755 /usr/local/nagios/libexec/check_memory.pl
chmod 755 /usr/local/nagios/libexec/check_iostat
dos2unix /usr/local/nagios/libexec/check_memory.pl
dos2unix /usr/local/nagios/libexec/check_iostat
使用check_traffic.sh之前需要安裝snmp包snmpwalk
rpm -ivh net-snmp-utils-5.3.2.2-9.el5_5.1.i386.rpm
mkdir -p /var/tmp/nagios && chown -R nagios.nagios /var/tmp/nagios
例子:如何獲取交換機(jī)的端口信息
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C 3550b -H 172.16.40.9 -L
4:優(yōu)化部分
[root@nagios etc]# cd /etc/nagios/etc
[root@nagios etc]# htpasswd -c /usr/local/nagios/etc/htpasswd.users admin
New password:
Re-type new password:
Adding password for user admin
編輯cgi.cfg文件,替換nagiosadmin 為admin
/etc/init.d/nagios start
/etc/init.d/httpd start
5:繪圖PNP
http://docs.pnp4nagios.org/pnp-0.6/dwnld
下載:pnp4nagios-0.6.24.tar.gz 文檔部分 http://docs.pnp4nagios.org/pnp-0.6/start
PNP是一個(gè)Nagios插件 ***能數(shù)據(jù)進(jìn)行分析,并將它們存儲(chǔ)自動(dòng)RRD-databases
RRDtool是開(kāi)源行業(yè)標(biāo)準(zhǔn),可以提供高性能數(shù)據(jù)記錄時(shí)間序列數(shù)據(jù)和圖形繪制系統(tǒng)
下載鏈接:http://oss.oetiker.ch/rrdtool/pub/?M=D
此處使用rrdtool-1.2.12.tar.gz
[root@nagios rrdtool-1.2.12]# ./configure
[root@nagios rrdtool-1.2.12]# make all &&make install
[root@nagios pnp4nagios-0.6.24]# ls /usr/local/rrdtool-1.2.12/ 安裝好的目錄
[root@nagios ~]# cd pnp4nagios-0.6.24
[root@nagios pnp4nagios-0.6.24]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool-1.2.12/bin/rrdtool
[root@nagios pnp4nagios-0.6.24]# make all
[root@nagios pnp4nagios-0.6.24]# make install
[root@nagios pnp4nagios-0.6.24]# make install-webconf
[root@nagios pnp4nagios-0.6.24]# make install-config
*** PNP4Nagios sample config files installed ***
Please run 'make install-init' if you want to use
BULK Mode with NPCD
默認(rèn)是運(yùn)行Synchronous Mode 模式,比較浪費(fèi)資源它是每一個(gè)事件將觸發(fā)process-service-perfdata的執(zhí)行
所以此處使用Bulk mode 批量模式比同步模式更為復(fù)雜但能顯著降低nagios服務(wù)器上的負(fù)載,因?yàn)閿?shù)據(jù)收集器process_perfdata.pl不調(diào)用每個(gè)服務(wù)/主機(jī)檢查。
在批量模式Nagios將數(shù)據(jù)寫(xiě)入一個(gè)臨時(shí)文件中。這個(gè)文件是由process_perfdata進(jìn)行處理。在特定的間隔。Nagios將定期照顧啟動(dòng)和運(yùn)行它
首先在nagios.cfg中 啟用收據(jù)收集開(kāi)關(guān)
process_performance_data=1
#
# 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
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
}
6: 調(diào)試
http://192.168.10.100/pnp4nagios/ 提示404錯(cuò)誤
chown nagios.nagios /usr/local/nagios/etc/htpasswd.users
PNP4Nagios Version | pnp4nagios-0.6.24 |
---|---|
Prefix | /usr/local/pnp4nagios |
Configure Arguments | ./configure '--with-nagios-user=nagios' '--with-nagios-group=nagios' '--with-rrdtool=/usr/local/rrdtool-1.2.12/bin/rrdtool' |
RRD Storage | /usr/local/pnp4nagios/var/perfdata is readable. |
RRDtool Binary | /usr/local/rrdtool-1.2.12/bin/rrdtool is executable by PHP |
PHP GD extension | PHP GD extension not available |
PHP function proc_open() | Pass |
PHP zlib extension | Pass |
PHP session extension | Pass |
PHP JSON extension | Pass |
PHP magic_quotes_gpc | Off |
PHP socket extension | Pass |
Apache Rewrite Module | Pass |
在安裝光盤(pán)上查詢(xún)依次安裝即可,缺啥補(bǔ)啥
[root@nagios CentOS]# ls *php* | grep gd
php53-gd-5.3.3-1.el5.i386.rpm
php-gd-5.1.6-27.el5_5.3.i386.rpm
然后重啟WEB 刷新通過(guò)。
Your environment passed all requirements. Remove or rename the /usr/local/pnp4nagios/share/install.php
file now.
cd /usr/local/pnp4nagios/share/
[root@nagios share]# mv install.php install.php.bak
編輯模板新增vim templates.cfg
define host {
name host-pnp
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
在LINUX 被監(jiān)控端安裝nagios-plugins-2.0.3 nrpe-2.15.tar.gz
運(yùn)行方式:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d