十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
去官方下载最新的版本nagios-4.0.8 http://www.nagios.org/download/core
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了合江免费建站欢迎大家使用!
[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
个性化的插件都拷贝到/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
如下插件都可以网上找 主要是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
例子:如何获取交换机的端口信息
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C 3550b -H 172.16.40.9 -L
4:优化部分
[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是一个Nagios插件 ***能数据进行分析,并将它们存储自动RRD-databases
RRDtool是开源行业标准,可以提供高性能数据记录时间序列数据和图形绘制系统
下载链接: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
默认是运行Synchronous Mode 模式,比较浪费资源它是每一个事件将触发process-service-perfdata的执行
所以此处使用Bulk mode 批量模式比同步模式更为复杂但能显著降低nagios服务器上的负载,因为数据收集器process_perfdata.pl不调用每个服务/主机检查。
在批量模式Nagios将数据写入一个临时文件中。这个文件是由process_perfdata进行处理。在特定的间隔。Nagios将定期照顾启动和运行它
首先在nagios.cfg中 启用收据收集开关
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: 调试
http://192.168.10.100/pnp4nagios/ 提示404错误
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 |
在安装光盘上查询依次安装即可,缺啥补啥
[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 刷新通过。
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 被监控端安装nagios-plugins-2.0.3 nrpe-2.15.tar.gz
运行方式:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d