nagios监控主机
基础环境准备
1、通过yum 安装httpd,mod_perl,php
2、账户准备
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
下载地址:
nagios核心下载
http://www.nagios.org/download/core/
make all
make install
make install-init
make install-config
make install-commandmode
增加apache下的nagios功能,
cp /usr/local/tmp/nagios/sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
nagios plugin
http://www.nagios.org/download/plugins
添加并启动nagios服务
/sbin/chkconfig --add nagios
/sbin/chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/sbin/service nagios start
增加主机绘图功能
yum install rrdtool
安装pnp4nagios
提前安装
yum -y install perl-Time-HiRes
下载安装pnp4nagios
make all
make install
make install-config
make install-init
先修改主配置文件
vi /usr/local/nagios/etc/nagios.cfg
将原来的改成下面的
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
然后修改
vi /usr/local/nagios/etc/objects/templates.cfg 的最后添加host-pnp与srv-pnp这两个pnp绘图模板:
define host {
name host-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$
}
define service {
name srv-pnp
register 0
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
再修改
vi /usr/local/nagios/etc/objects/commands.cfg
这里要注意把原先的配置注释掉,改为下面的配置
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
以上配置文件修改完毕后,我们需要在主机的配置文件中引用上述修改,例如,在shop1.cfg的配置文件中引用模板文件templates.cfg里的srv-pnp:
被监控机器
nrpe机器准备
/usr/sbin/useradd nagios
增加ssl依赖
yum -y install openssl-devel
安装NRPE
http://sourceforge.net/projects/nagios/files/nrpe-2.x/
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download
make all
make install-plugin
make install-daemon
make install-daemon-config
安装nagios plugin
http://www.nagios.org/download/plugins
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
使用check_linux_stat来监控硬件性能,需要增加安装Sys-Statistics-Linux模块
模块安装需要安装Perl的cpan模块,需要安装perl。
yum -y install perl-CPAN
下载地址 http://search.cpan.org/dist/Sys-Statistics-Linux/
wget http://search.cpan.org/CPAN/authors/id/B/BL/BLOONIX/Sys-Statistics-Linux-0.66.tar.gz
tar zxvf Sys-Statistics-Linux-0.66.tar.gz
cd Sys-Statistics-Linux-0.66
perl Makefile.PL
make && make test && make install
安装完成后
check_linux_stat下载地址
http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2516&cf_id=24
如果不能使用,增加这个
yum -y install perl-Time-HiRes
nagios通过SendEmail发送邮件
http://caspian.dotconf.net/menu/Software/SendEmail/