画图软件安装
-
yum安装pnp软件需要的基础包
yum install cairo pango zlib zlib-devel freetype freetype-devel gd gd-devel -y
-
安装rrdtools的依赖
yum安装yum install libart_lgpl libart_lgpl-devel -y
编译安装
cd ~/tools/ wget http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.17.tar.gz tar zxvf libart_lgpl-2.3.17.tar.gz cd libart_lgpl-2.3.17 ./configure make make install /bin/cp -r /usr/local/include/libart-2.0/ /usr/include/
-
安装rrdtools轮询的数据库,专门画图
cd ~/tools/ wget https://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.14.tar.gz tar zxvf rrdtool-1.2.14.tar.gz cd rrdtool-1.2.14 ./configure --prefix=/usr/local/rrdtool --disable-python --disable-tcl make make install ls -l /usr/local/rrdtool/bin
-
安装PNP
pnp收集数据告诉rrdtools画图,PHP负责展示tar zxvf pnp-0.4.14.tar.gz cd pnp-0.4.14 ./configure --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/ make all make install make install-config make install-init ll /usr/local/nagios/libexec/ |grep process
–with-rrdtool=/usr/local/rrdtool/bin/rrdtool 出图的命令
–with-perfdata-dir=/usr/local/nagios/share/perfdata/ 出图所用的数据路径问题:configure报错
checking for linker flags for loadable modules… -shared
checking for Perl Module Time::HiRes… no
configure: error: Perl Module Time::HiRes not available
解决:
yum install perl-Time-HiRes -y
nagios出图相关基本配置
-
编辑nagios.cfg
cp /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg.ori vim /usr/local/nagios/etc/nagios.cfg +835
process_performance_data=1 host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata
-
编辑commands.cfg
cp /usr/local/nagios/etc/objects/commands.cfg /usr/local/nagios/etc/objects/commands.cfg.ori vim /usr/local/nagios/etc/objects/commands.cfg +227
删除原有的process-host-perfdata和process-service-perfdata命令定义
# ‘process-host-perfdata’ command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf “%b” “$LASTHOSTCHECKKaTeX parse error: Undefined control sequence: \t at position 1: \̲t̲HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n” >> /usr/local/nagios/var/host-perfdata.out
}
# ‘process-service-perfdata’ command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf “%b” “$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n” >> /usr/local/nagios/var/service-perfdata.out
}加入下面的命令定义
# 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line $USER1$/process_perfdata.pl } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line $USER1$/process_perfdata.pl }
-
检查语法与重启
/etc/init.d/nagios checkconfig /etc/init.d/nagios reload
-
查看是否配置完成
http://192.168.47.156/nagios/pnp/index.php