naigos实现监控短信报警Linux认证考试
文章作者 100test 发表时间 2009:10:27 11:56:10
来源 100Test.Com百考试题网
一、nagios在服务端的安装
# vim nagios-install
#!/bin/bash
#### nagios客户端安装请注释了install nagios这段###
##install nagios
tar zxvf nagios-3.0.6.tar.gz cd nagios-3.0.6 ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cd ..
##install nagios-plugins
tar zxvf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure --prefix=/usr/local/nagios
make
make install
cd ..
##install nrpe
tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure --enable-ssl --enable-command-args
make all
mkdir -p /usr/local/nagios/etc
mkdir -p /usr/local/nagios/bin
cp sample-config/nrpe.cfg /usr/local/nagios/etc/
cp src/nrpe /usr/local/nagios/bin/
sed -i s/127.0.0.1/127.0.0.1,192.168.1.253/ /usr/local/nagios/etc/nrpe.cfg sed -i s/usr\/local/nagios/g /usr/local/nagios/etc/nrpe.cfg
二、启动nrpe
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d如需重启nrpe,先killall -9 nrpe再执行启动
三、配置nagios
Nagios安装成功后,在/usr/local/nagios下有几个目录,分别是:
bin etc libexec sbin share var
1、在/usr/local/nagios/etc 下建立一个linux的目录,并建立一个hosts.cfg文件。
这个文件里面的内容,是分三大块:(1)、定义主机,即host (2)、定义监控组,即 hostgroup (3)、定义监控主机的服务,即server
例:
# Define webgroup host for the testers machine ##定义主机
define host{
host_name web01
alias web01.com address 192.168.1.10
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 20
notification_period 24x7
notification_options d,r
contact_groups admins
name web01
}
define host{
host_name web02
alias web02.com address 192.168.1.20
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 20
notification_period 24x7
notification_options d,r
contact_groups admins
name web02
}
define host{
host_name web03
alias web03.com address 192.168.1.20
check_command check-host-alive
max_check_attempts 10
check_period 24x7
notification_interval 20
notification_period 24x7
notification_options d,r
contact_groups admins
name web02
}