写给自己 :linux运维路,自己动手趟一遍
都在监控服务器端安装配置:
图形依赖库
#yuminstallcairopangozlibzlib-develfreetypefreetype-develgdgd-devel
rrdtools依赖 用来画图的
#yuminstalllibart_lgplrrdtool
pnp4nagios 主角,收集数据,展示图形
#yuminstallpnp4nagios
更改显示时间,不然会有8小时时差
#vi/etc/PHP.ini date.timezone="Asia/Shanghai"
#vi/etc/pnp4nagios/config.PHP $conf['date_fmt']="Y.m.dH:i";更符合中国时间习惯
配置出图 由于pnp4nagios 0.6配置要用bulk+npcd模式,
官网说明 https://docs.pnp4nagios.org/pnp-0.6/config#bulk_mode
#vi/etc/nagios/nagios.cfg process_performance_data=1 host_perfdata_file=/var/spool/pnp4nagios/host-perfdata service_perfdata_file=/var/spool/pnp4nagios/service-perfdata host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHE CKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$ service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSER VICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATET YPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$ host_perfdata_file_mode=a service_perfdata_file_mode=a host_perfdata_file_processing_interval=15 service_perfdata_file_processing_interval=15 host_perfdata_file_processing_command=process-host-perfdata-file service_perfdata_file_processing_command=process-service-perfdata-file
修改command.cfg定义
#vi/etc/nagios/objects/command.cfg #'process-host-perfdata'commanddefinition definecommand{ command_nameprocess-host-perfdata-file command_line/usr/libexec/pnp4nagios/process_perfdata.pl--bulk=/var/lib/pnp4nagios/host-perfdata } #'process-service-perfdata'commanddefinition definecommand{ command_nameprocess-service-perfdata-file command_line/usr/libexec/pnp4nagios/process_perfdata.pl--bulk=/var/lib/pnp4nagios/service-perfdata }
修改模板定义
#vi/etc/nagios/objects/templates.cfg definehost{ namehost-pnp action_url/pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_ register0 } defineservice{ nameservice-pnp action_url/pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ register0 }
#vi/etc/nagios/objects/hosts.cfg ... uselinux-server,host-pnp//添加host-pnp模板 ... #vi/etc/nagios/objects/services.cfg ... usegeneric-service,service-pnp//添加service-pnp模板 ...
#nagios-v/etc/nagios/nagios.cfg检测配置是否正确
#systemctlrestartnpcd #systemctlrestarthttpd #systemctlrestartnagios
点击小图标,就可以打开图形监控页面了。