nagios+pnp4nagios出图
注释:
仁寿ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
首先下载
Apache 实现nagios监控通过web查看 Nagios
nagios监控程序
Nagios-plugins nagios监控插件
Pnp4nagios nagios监控插件
Nrpe nagios监控客户端
Rrdtool pnp4nagios生成图形工具
Nagios http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz
Nagios-plugins http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz Pnp4nagios http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.6.tar.gz/download
Nrpe http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
注释(以后可能会遇到一下相关包找不到等): 可能yum安装会有些问题找不到包,可添加yum源:如:rpmforge源和epel源
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm
php的一些扩展包找不到就需要添加这两个源:rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm和上面的epel-release-6-5.noarch.rpm
如:php扩展mcrypt就需要epel源;而php的扩展bitset就需要用哦感到rpmforge源。。。
一,安装pnp4nagios
!!!此时安装pnp4nagios就用到了需要的epel源,如果没有epel源
请参考:1、安装epel
# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
# rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm 这里应该对应你服务器的版本
[root@master ~]#yum install pnp4nagios rrdtool
或者源码:安装:
在这之前安装rrdtool和pnp4nagios需要如下包:
yum install -y perl-devel perl-CPAN perl-Time-HiRes
#tar -zxvf pnp4nagios-*.tar.gz
#cd php4nagios-*
#./configure --prefix=/usr/local/pnpnagios --with-nagios-user=nagios --with-nagios-group=nagios (如果单独编译安装的rrdtoool,则使用--with-rrdtool=/usr/local/rrdtool-1.2.xx/bin/rrdtool这样的形式)
#make all
#make install
#make install-webconf
#make install-config
#make install-init
#make fullinstall
(使用这条命令替换所有的make命令, make fullinstall)
还需要:复制所有的pnp4nagios 目录下etc下的*.cfg.simple 复制为*.cfg
cd /usr/local/pnpnagios-*/etc/
88. mv misccommands.cfg-sample misccommands.cfg
89. mv nagios.cfg-sample nagios.cfg
90. mv rra.cfg-sample rra.cfg
91. cd pages/
92. mv web_traffic.cfg-sample web_traffic.cfg
93. cd ../check_commands/
94. mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
95. mv check_nrpe.cfg-sample check_nrpe.cfg
96. mv check_nwstat.cfg-sample check_nwstat.cfg
本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2012-07/66071.htm
二,配置nagios
1、修改nagios.cfg
[root@master ~]# vim /etc/nagios/nagios.cfg //修改以下内容
process_performance_data=1 //由0改为1
host_perfdata_command=process-host-perfdata //前面的注释拿掉
service_perfdata_command=process-service-perfdata //注释拿掉
enable_environment_macros=1 //如果有注释拿掉
2、修改commands.cfg
注释掉原有对process-host-perfdata和process-service-perfdata,重新定义:
[root@master ~]# vim /etc/nagios/objects/commands.cfg
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA
}
3、修改配置文件templates.cfg
添加以下内容
[root@master ~]# vim /etc/nagios/objects/templates.cfg
define host {
name hosts-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
process_perf_data 1
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
4、修改服务器配置文件cisco_3650.cfg
[root@master ~]# vim /etc/nagios/objects/cisco_3650.cfg
###### define hosts ##########################
define host{
use generic-switch,hosts-pnp
host_name BJ3560G-48
address 172.16.1.1
contact_groups admins
}
##### define services ############
define service{
use generic-service,srv-pnp
host_name BJ3560G-48
service_description PING
check_command check_ping!200.0,20%!600.0,60%
contact_groups admins
}
三、配置apache
修改Apache的配置文件httpd.conf:
[root@master ~]# vim /usr/local/apache/conf/httpd.conf
在AddType application/x-gzip .gz .tgz下,添加下面的配置项:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
[root@master ~]# /etc/init.d/httpd restart 重启apache服务
可以直接拷贝下面到vim /etc/httpd/conf.d/pnp4nagios.conf
[root@lvs-save conf.d]# cat /etc/httpd/conf.d/pnp4nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
Alias /pnpnagios "/usr/local/pnpnagios/share"
AllowOverride None
Order allow,deny
Allow from all
#
# Use the same value as defined in nagios.conf
#
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
# Turn on URL rewriting
RewriteEngine On
Options FollowSymLinks
# Installation directory
RewriteBase /pnpnagios/
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
四、如果访问图不出提示:
The requested URL /pnp4nagios/index.php/graph was not found on this server.
那么可能是相关php包没安装:
方法:yum install php*
即可解解以上报错出图问题。
五、如果访问http://IP/pnpnagios需要提供认证而用nagios登录的也不行,那么就执行下一下在生成一个用户进行登录即可!
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 第一次使用htpasswd是用参数-c表示创建目录/usr/local/nagios/etc/htpasswd.users 用于存放用户nagiosadmin 信息!
htpasswd -m /usr/local/nagios/etc/htpasswd.users nagios 这个-m 参数表示在这个文件里面多加一个用户!
注意如果上面配置后在/usr/local/pnpnagios/var/perfdata/ 这么目录下有数据 但是点击游览器访问出图数据时候报错说什么找不到主机图,那么一般是http配置问题!看看pnp4nagios和pnpnagios区别的别名问题!
分享名称:nagios+pnp4nagios出图
URL网址:http://cdiso.cn/article/pdsssg.html