陈俊勇:教你搭建Nagios性能图,直观监控神器

陈俊勇:教你搭建Nagios性能图,直观监控神器

文章精选heiyunw2024-04-30 18:47:2015A+A-

安装图表工具


安装PNP4Nagios

解决依赖

[root@juny-10 Nagios]# yum install rrdtool php-gd perl-rrdtool perl-Time-HiRes -y

解压pnp文件

[root@juny-10 Nagios]# tar xzf pnp4nagios-0.6.26.tar.gz -C /usr/local/src/

到解压目录下面去

[root@juny-10 Nagios]# cd /usr/local/src/pnp4nagios-0.6.26/

配置文件

[root@juny-10 pnp4nagios-0.6.26]# ./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagcmd

编译

[root@juny-10 pnp4nagios-0.6.26]# make all

编译安装

[root@juny-10 pnp4nagios-0.6.26]# make install

[root@juny-10 pnp4nagios-0.6.26]# make fullinstall

修改nagios主配置文件

#修改以下几个内容

[root@juny-10 pnp4nagios]# vim /usr/local/nagios/etc/nagios.cfg

...

process_performance_data=0

#修改为1

process_performance_data=1

...

host_perfdata_command=process-host-perfdata #取消注释

service_perfdata_command=process-service-perfdata #取消注释

...

修改nagios配置commands命令

[root@juny-10 pnp4nagios]# vim /usr/local/nagios/etc/objects/commands.cfg

修改为

修改nagios的模板文件

在最后添加

[root@juny-10 pnp4nagios]# vim /usr/local/nagios/etc/objects/templates.cfg

define host {

name host-pnp

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

class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAMEamp;srv=_HOST_

register 0

#process_perf_data 1

}

define service {

name srv-pnp

action_url /pnp4nagios/index.php/graph?host=$HOSTNAMEamp;srv=$SERVICEDESC

class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAMEamp;srv=$SERVICEDESC$

register 0

#process_perf_data 1

}

拷贝头文件到nagios的网站根目录下

[root@juny-10 pnp4nagios]# cd /usr/local/src/pnp4nagios-0.6.26/

[root@juny-10 pnp4nagios-0.6.26]# cp contrib/ssi/status-header.ssi /usr/local/nagios/share/ssi/

编辑nagios的localhost的配置文件

在需要显示性能图的服务后面添加,srv-pnp

[root@juny-10 pnp4nagios-0.6.26]# vim /usr/local/nagios/etc/objects/localhost.cfg

重命名文件

[root@juny-10 pnp4nagios-0.6.26]# mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.bak

重新授权给nagios

[root@juny-10 pnp4nagios-0.6.26]# chown -R nagios.nagios /var/www/html/ /usr/local/nagios/ /usr/local/pnp4nagios/

重启服务

重启nagios

[root@juny-10 pnp4nagios-0.6.26]# /etc/init.d/nagios restart

Restarting nagios (via systemctl): [ 确定 ]

重启httpd

[root@juny-10 pnp4nagios-0.6.26]# systemctl restart httpd

重启npcd

[root@juny-10 pnp4nagios-0.6.26]# /etc/init.d/npcd restart

Reloading systemd: [ 确定 ]

Restarting npcd (via systemctl): [ 确定 ]

网页测试

重命名文件

[root@juny-10 pnp4nagios-0.6.26]# cd /usr/local/pnp4nagios/etc/

[root@juny-10 etc]# ls

background.pdf config_local.php misccommands.cfg-sample pages rra.cfg-sample

check_commands config.php nagios.cfg-sample pnp4nagios_release

config.d config.php.0.6.26 npcd.cfg process_perfdata.cfg

[root@juny-10 etc]# mv misccommands.cfg-sample misccommands.cfg

[root@juny-10 etc]# mv nagios.cfg-sample nagios.cfg

[root@juny-10 etc]# mv rra.cfg-sample rra.cfg

[root@juny-10 etc]#

[root@juny-10 etc]# cd pages/

[root@juny-10 pages]# ls

web_traffic.cfg-sample

[root@juny-10 pages]# mv web_traffic.cfg-sample web_traffic.cfg

[root@juny-10 pages]# cd ..

[root@juny-10 etc]# cd check_commands/

[root@juny-10 check_commands]# ls

check_all_local_disks.cfg-sample check_nrpe.cfg-sample check_nwstat.cfg-sample

[root@juny-10 check_commands]# mv check_all_local_disks.cfg-sample check_all_local_disks.cfg

[root@juny-10 check_commands]# mv check_nrpe.cfg-sample check_nrpe.cfg

[root@juny-10 check_commands]# mv check_nwstat.cfg-sample check_nwstat.cfg

[root@juny-10 check_commands]#

重启服务

[root@juny-10 check_commands]# /etc/init.d/nagios restart

Restarting nagios (via systemctl): [ 确定 ]

[root@juny-10 check_commands]# /etc/init.d/npcd restart

Restarting npcd (via systemctl): [ 确定 ]

[root@juny-10 check_commands]#

查看网页

到此整个nagios安装完成

因nagios监控Windows的内容不能发布,,需要的私我

点击这里复制本文地址 以上内容由黑云学习网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

支持Ctrl+Enter提交
qrcode

黑云学习网 © All Rights Reserved.  Copyright Your WebSite.Some Rights Reserved.