一、簡介
Nagios是一款開源的電腦系統和網路監視工具,能有效監控Windows、Linux和Unix的主機狀態,交換器路由器等網路設定,印表機等。是營運利器,不會nagios怎麼好意思說你是營運呢?
二、安裝nagios
1、下載nagios:下載地址:http://sourceforge.net/projects/nagios-cn/?source=typ_redirect
2、安裝nagios
(前提安裝httpd和php)
建立使用者解壓編譯安裝
useradd nagios -G nagcmd
tar jxvf nagios-cn-3.2.3.tar.bz2
cd nagios-cn-3.2.3
./configure --prefix=/nagios --with-command-group=nagcmd
安裝nagios及其設定檔
make all
make install
make install-init
make install-commandmode
make install-config
cp sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
建立登入密碼:
htpasswd -c /nagios/etc/htpasswd.users nagios
啟動測試:
service nagios start
service httpd start
預設應該能啟動啦:
我的沒問題,如果有報錯的話多半是少了什麼包,網上查查吧。
到這裡的話,成功了一大半了。
下面安裝nagios-plugins和nrpe
下載nagios-plugins:http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
下載nrpe:http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download
安裝就很簡單啦,然後就是配置,下面就不贅述了。
然後說說pnp4nagios的安裝:
1、下載https://sourceforge.net/projects/pnp4nagios/files/latest
2、編譯安裝:
tar zxvf pnp4nagios-0.6.14.tar.gz
cd pnp4nagios-0.6.14
./configure && make all && make install
開啟nagios.cfg配置:
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdat
修改 commands.cfg配置:
define command{
command_name process-host-perfdata
command_line /pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /pnp4nagios/libexec/process_perfdata.pl
}
在templates.cfg添加相應的action_url:
主機模版
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
服務模版
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
好了,小太陽也出來了。