http://nchc.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.2.3/nagios-3.2.3.tar.gz
http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
# useradd -s /sbin/nologin nagios
# apt-get install apache2
# apt-get install libapache2-mod-php5
# service sendmail start
一、安装nagios主程序
# tar -zxvf nagios-3.2.0.tar.gz
# cd nagios-3.2.0
#./configure --prefix=/usr/local/nagios
# make all
# make install
# make install-init
# make install-commandmode (配置目录权限)
# make install-config (安装nagios示例配置文件)
二、安装nagios插件 (插件版本与nagios版本无关)
# tar -zxvf nagios-plugins-1.4.14.tar.gz
# cd nagios-plugins-1.4.14
# ./configure --prefix=/usr/local/nagios
# make && make install
查看/usr/local/nagios/libexec,会看到新增很多的插件。
三、配置http
修改httpd的配置文件/etc/apache2/site-available/default (在中间添加)
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
:wq
# ln -s /usr/local/nagios/share /var/www/nagios
四、添加验证文件
# htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin
New password: (输入密码)
Re-type new password: (再输入一次密码)
在/usr/local/nagios/etc下就会新增一个htpasswd验证文件。
五、配置本机监控
1、修改contacts.cfg(联系人配置文件)(这个文件必须改,不改的话信息不显示)
# vi /usr/local/nagios/etc/objects/contacts.cfg
define contact {
contact_name ming ;
use generic-contact ;
email 1376467954@139.com ; (最好写139邮箱直接发到手机上)
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members ming ;添加上边定义的联系人名,以逗号分隔
}
:wq
2、检查配置是否有误
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
3、重启nagios:
# service nagios restart
此时登录到nagios的web界面,就能查看到监控界面左侧的主机和服务中有我们配置好的本地监控的信息啦。
开机自启动:
# chkconfig --add nagios
# chkconfig --level 35 nagios on
开启nagios的报错功能:
# vi /etc/init.d/nagios
$NagiosBin -v $NagiosCfgFile;(原为$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;)
:wq
开启http的报警功能:
# vi /usr/local/nagios/etc/objects/localhost.cfg
找到http 将 notifications_enabled 0
本文出自 “linux” 博客,谢绝转载!