五、配置Apache
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
#红色部分为修改添加部分
User nagios
Group nagios
DirectoryIndex index.html index.html.var index.php
AddType application/x-httpd-php .php
#在配置文件末尾添加如下信息:
#setting for nagios
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>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
#添加Apache认证用户:
[root@localhost ~]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd user
New password:
Re-type new password:
Adding password for user user
六、配置本机监控
1.新建monitor 文件,拷贝示例文件到该目录下
[root@localhost etc]# pwd
/usr/local/nagios/etc
[root@localhost etc]# mv objects/ monitor
2.修改联系人配置文件
[root@localhost monitor]# cat contacts.cfg |grep -v "#"|grep " "
define contact{
contact_name user ; Short name of user
use generic-contact ; 引用generic-contact属性信息
alias Nagios Admin ; Full name of user
email user@163.com ; 告警接收邮箱
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members user ;添加上面定义的联系人,逗号分隔
}
3.修改cgi.cfg
default_user_name=user ;将用户名修改为nagios界面登录的用户名
4.修改nagios.cfg将所有cfg_file=都注释掉添加如下一行
cfg_dir=/usr/local/nagios/etc/monitor
#这样配置非常方便以后维护
5.使用命令:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置是否有误
6.重启apache、nagios 并加到开启启动项
[root@localhost ~]# service httpd restart
停止 httpd:[确定]
正在启动 httpd:[确定]
[root@localhost ~]# service nagios restart
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig nagios on
7.下图为了看的更直观,没有删除其他的配置,目前还没有这个版本的汉化包,3.2版本有汉化包,汉化过的软件比较别扭,英文版的多使用几次就熟悉了。

