3 nagios core安装
tar zxvf nagios-3.4.1.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
6 安装nrpe
yum install openssl-devel
yum install xinetd
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz/download
tar zxf nrpe-2.14.tar.gz
cd nrpe-2.14
./configure
make && make install
配置文件引用在/usr/local/nagios/etc/objects/nagios.cfg文件里设置
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/service.cfg
如上我将localhost.cfg文件注释了,用hosts.cfg和service.cfg替换,host.cfg文件主要定义要监控的主机和主机组,service.cfg主要定义监控的服务等
Hosts.cfg文件配置如下:
# Define a host for the local machine
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name client
alias client
address 192.168.100.31
}
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name localhost
alias localhost
address 127.0.0.1
}
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members localhost,client ; Comma separated list of hosts that belong to this group
}
上述配置文件中的linux-server是在templates.cfg里配置,可以添加多个主机组
配置了客户端后可登陆web http://<your.nagios.server.ip>/nagios
界面看到添加的监控服务器下图中的clients
点击服务可以监控具体的服务,下图是监控cpu负载的情况
安装nagiosgrah
wget http://sourceforge.net/projects/nagiosgraph/files/nagiosgraph/1.4.4/nagiosgraph-1.4.4.tar.gz/download
yum install perl-rrdtool perl-GD
yum install perl-Time-HiRes
tar zxf nagiosgraph-1.4.4.tar.gz
cd nagiosgraph-1.4.4
perl ./install.pl --check-prereq
perl ./install.pl --layout overlay --prefix /usr/local/nagios
2个选项需要输入y其他默认即可
Modify the Nagios configuration? [n] y
Modify the Apache configuration? [n] y
安装完成后访问测试
http://192.168.100.30/nagios/cgi-bin/show.cgi
http://192.168.100.30/nagios/cgi-bin/showconfig.cgi
配置复制安装包里的文件
cp nagiosgraph-1.4.4/share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi
修改文件common-header.ssi
[iyunv@server01 opt]# vi /usr/local/nagios/share/ssi/common-header.ssi
<script type="text/javascript" src="/nagios/nagiosgraph.js"></script>
mv /usr/local/nagios/share/images/action.gif /usr/local/nagios/share/images/action.gif-orig
拷贝安装包文件文件graph.gif
cp nagiosgraph-1.4.4/share/graph.gif /usr/local/nagios/share/images/action.gif
vi /usr/local/nagios/share/side.php 搜索Trends后添加
<li><a href="<?php echo $cfg["cgi_base_url"];?>/trends.cgi" target="<?php echo $link_target;?>">Trends</a></li>
cd /opt/nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
安装nrpe
yum install xinetd
[iyunv@server02 opt]# tar xzf nrpe-2.14.tar.gz
[iyunv@server02 opt]# cd nrpe-2.14
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
编辑vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.100.30 没有空格
编辑/etc/xinetd.d/nrpe 文件添加监控主机的地址192.168.100.30
only_from = 127.0.0.1 <nagios_ip_address>
编辑/etc/servers文件添加
nrpe 5666/tcp # NRPE
重启服务
service xinetd restart