添加用户:
useradd -m nagios
passwd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd daemon
编译安装nagios
tar -xvzf nagios-cn-3.2.3.tar.bz2
cd nagios-3.0.3
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
设置apache服务器访问密码:
cd /usr/local/nagios/etc/
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd /usr/local/apache/conf/
vi httpd-vhosts.conf
配置apache的cgi ,具体配置如下:
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios /usr/local/nagios/share
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
重启apache
/usr/local/apache/bin/apachectl configtest
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start
安装nagios插件
tar -xvzf nagios-plugins-2.0.1.tar.gz
cd nagios-plugins-1.4.12
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
chkconfig –add nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
现在你可以通过浏览器访问监控的界面了,http://www.example.com/nagios
现在你仅仅能看到对于本机的监控,接下来我们添加一个http服务的监控
cd /usr/local/nagios/
vi nagios.cfg
添加一行:
cfg_file=/usr/local/nagios/etc/objects/wwws.cfg
编写配置wwws.cfg
touch objects/hosts.cfg objects/wwws.cfg
vi objects/wwws.cfg
具体内容如下:
define host{
use generic-host
host_name maycode
alias www.maycode.com
address 10.11.24.42
hostgroups webhosts
max_check_attempts 10
}
define hostgroup{
hostgroup_name webhosts
alias web service hosts
members maycode
}