( 2) 安装和编译nagios
搭建nagios所需要的软件已经放在/nagios
[iyunv@localhost nagios]# tar zxf nagios-3.2.0.tar.gz
[iyunv@localhost nagios]# cd nagios-3.2.0
[iyunv@localhost nagios-3.2.0]# ./configure --prefix=/usr/local/nagios/
[iyunv@localhost nagios-3.2.0]# make all ; make install ; make install-init ; make install-commandmode ; make install-config
[iyunv@localhost nagios-3.2.0]# chkconfig --add nagios
[iyunv@localhost nagios-3.2.0]# chkconfig nagios on
(3)安装nagios插件
[iyunv@localhost nagios]# tar zxf nagios-plugins-1.4.14.tar.gz
[iyunv@localhost nagios]# cd nagios-plugins-1.4.14
[iyunv@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ ; make ; make insta
(4)安装Nagios的汉化包
[iyunv@localhost nagios]# tar jxf nagios-cn-3.2.0.tar.bz2
[iyunv@localhost nagios]# cd nagios-cn-3.2.0
[iyunv@localhost nagios-cn-3.2.0]# ./configure ; make all ; make install
1) 验证nagios主配置文件的语法正确性
[iyunv@localhost etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
2) 启动与停止nagios
[iyunv@localhost etc]# service nagios start
Starting nagios:This account is currently not available.
done.
[iyunv@localhost etc]# service nagios status
nagios (pid 5106) is running...
[iyunv@localhost etc]# service nagios stop
Stopping nagios: .done.
[iyunv@localhost etc]# service nagios restart
Running configuration check...done.
Stopping nagios: No lock file found in /usr/local/nagios//var/nagios.lock
Starting nagios:This account is currently not available.
done.
一、 Nagios性能分析图表的实现
1) 安装PNP支持包rrdtool工具
[iyunv@localhost nagios]# tar zxf rrdtool-1.4.5.tar.gz
[iyunv@localhost nagios]# cd rrdtool-1.4.5
[iyunv@localhost rrdtool-1.4.5]# ./configure --prefix=/usr/local/rrdtool ; make ; make install
2)安装PNP
[iyunv@localhost rrdtool-1.4.5]# cd /aaa/
[iyunv@localhost nagios]# tar zxf pnp-0.4.13.tar.gz
[iyunv@localhost nagios]# cd pnp-0.4.13
[iyunv@localhost pnp-0.4.13]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-di
r=/usr/local/nagios/share/perfdata ; make all ; make install ; make install-config ; make install-init
3) 配置PNP
A,创建默认配置文件
[iyunv@localhost pnp-0.4.13]# cd /usr/local/nagios/etc/pnp/
[iyunv@localhost pnp]# cp process_perfdata.cfg-sample process_perfdata.cfg
[iyunv@localhost pnp]# cp npcd.cfg-sample npcd.cfg
[iyunv@localhost pnp]# cp rra.cfg-sample rra.cfg
[iyunv@localhost pnp]# chown -R nagios:nagios /usr/local/nagios/etc/pnp/
B,修改process_perfdata.cfg
[iyunv@localhost pnp]# vi /usr/local/nagios/etc/pnp/process_perfdata.cfg
44 LOG_LEVEL = 2
4) 修改Nagios主配置文件
A,增加小太阳图标
[iyunv@localhost pnp]# cd /usr/local/nagios/etc/
[iyunv@localhost etc]# vi templates.cfg
define host{
name hosts-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
process_perf_data 1
}
define service{
name services-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
B、修改nagios.cfg
找到如下几行去掉注释
[iyunv@localhost etc]# vi nagios.cfg
833 process_performance_data=1
845 host_perfdata_command=process-host-perfdata
846 service_perfdata_command=process-service-perfdata
C、修改commands.cfg
227 # 'process-host-perfdata' command definition
228 define command{
229 command_name process-host-perfdata
230 command_line /usr/local/nagios/libexec/process_perfdata.pl
231 }
232
233
234 # 'process-service-perfdata' command definition
235 define command{
236 command_name process-service-perfdata
237 command_line /usr/local/nagios/libexec/process_perfdata.pl
238 }
D、修改hosts.cfg文件和services.cfg文件
[iyunv@localhost ~]# vi /usr/local/nagios/etc/hosts.cfg
define host{
use linux-server,hosts-pnp
host_name web
alias benet-web
address 192.168.1.100
}
define host{
use linux-server,hosts-pnp
host_name mysql
alias benet-mysql
address 192.168.1.200
}
define hostgroup{
hostgroup_name sa-servers
alias sa servers
members web,mysql
}
[iyunv@localhost ~]# vi /usr/local/nagios/etc/services.cfg
################- benet web -##########################
define service{
use local-service,services-pnp
host_name web
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service,services-pnp
host_name web
service_description SSH
check_command check_ssh
}
注意项:别心急看小太阳数据,等会儿就有了。