寫給自己 :linux運(yùn)維路,自己動(dòng)手趟一遍
從策劃到設(shè)計(jì)制作,每一步都追求做到細(xì)膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供成都做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁(yè)設(shè)計(jì)、申請(qǐng)域名、虛擬主機(jī)、網(wǎng)絡(luò)營(yíng)銷、VI設(shè)計(jì)、 網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。
布暑之前,請(qǐng)看我之前的快速安裝布暑nagios文章。
都在監(jiān)控服務(wù)器端安裝配置:
圖形依賴庫(kù)
#yum install cairo pango zlib zlib-devel freetype freetype-devel gd gd-devel
rrdtools依賴 用來(lái)畫圖的
#yum install libart_lgpl rrdtool
pnp4nagios 主角,收集數(shù)據(jù),展示圖形
#yum install pnp4nagios
更改顯示時(shí)間,不然會(huì)有8小時(shí)時(shí)差
#vi /etc/php.ini date.timezone = "Asia/Shanghai"
#vi /etc/pnp4nagios/config.php $conf['date_fmt'] = "Y.m.d H:i"; 更符合中國(guó)時(shí)間習(xí)慣
配置出圖 由于pnp4nagios 0.6配置要用bulk+npcd模式,
官網(wǎng)說(shuō)明 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' command definition define command{ command_name process-host-perfdata-file command_line /usr/libexec/pnp4nagios/process_perfdata.pl --bulk=/var/lib/pnp4nagios/host-perfdata } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata-file command_line /usr/libexec/pnp4nagios/process_perfdata.pl --bulk=/var/lib/pnp4nagios/service-perfdata }
修改模板定義
#vi /etc/nagios/objects/templates.cfg define host{ name host-pnp action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_ register 0 } define service{ name service-pnp action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ register 0 }
修改主機(jī),服務(wù)檢測(cè)配置文件
#vi /etc/nagios/objects/hosts.cfg ... use linux-server,host-pnp //添加host-pnp模板 ... #vi /etc/nagios/objects/services.cfg ... use generic-service,service-pnp //添加service-pnp模板 ...
#nagios -v /etc/nagios/nagios.cfg 檢測(cè)配置是否正確
#systemctl restart npcd #systemctl restart httpd #systemctl restart nagios
點(diǎn)擊小圖標(biāo),就可以打開圖形監(jiān)控頁(yè)面了。