三、检测定义快捷命令
问题1:新建立文件夹及节点无法生效
解决:修改nagios目录文件,使其目录被检测
vi /usr/local/nagios/etc/nagios.cfg
添加 要检测的目录。
cfg_dir=/usr/local/nagios/etc/cfgs
问题2:《《apache 启动失败 》》 默认安装在/usr/sbin/下,执行apachectl start时候,提示如下错误:
httpd: apr_sockaddr_info_get() failed for shiwei
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
于是上网查了一下,根据前人的经验,问题终于解决了。总结一下,方便以后使用。
原因:这个问题应该是没有在 /etc/httpd/conf/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。
解决办法:
(1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80
(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)
问题3 NRPE: Unable to read output
我的解决办法是:修改nagios目录的权限
#chown -R nagios:nagios nagios/
#chmod -R 775 nagios/
问题解决。linux
四、添加command
command[check_cpu]=/usr/local/nagios/libexec/check_cpu_pct -w $ARG1$ -c $ARG2$
command[check_memory]=/usr/local/nagios/libexec/check_mem -w $ARG1$ -c $ARG2$
将配置文件拷贝到指定目录后,修改所属及访问权限。
command[check_load]=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$
command[check_swap]=/usr/local/nagios/libexec/check_swap -w $ARG1$ -c $ARG2$228
command[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$
command[check_io]=/usr/local/nagios/libexec/check_iostat -d $ARG3$ -w $ARG1$ -c $ARG2$
五、安装sendmail
首先要确保sendmail相关组件的完整安装,我们可以使用如下的命令来完成sendmail的安装:
# yum install -y sendmail*
然后重新启动sendmail服务:
# service sendmail restart
然后发送测试邮件,验证sendmail的可用性:
# echo "Hello World" | mail abc@abc.com
Root@Nagios objects]# service sendmail restart
Shutting down sendmail: [FAILED]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
chkconfig sendmail off
chkconfig sendmail off 加速开机时间
重启服务器注意1,开机nrpe 二启动sendmail 三 iptables 设置
Nagios 多用户的一些配置
刚开始我想到在搭nagios的时候,用户验证是用apache来做的,接到这个需求后的第一反应是这个东西可能做不了。但接着一想,不应该啊,nagios本身至少会有一些用户配置的吧,于是乎开始寻找相关资料,基本配置如下:
(1)新增一个apache用户,如qiuyuetao
[root@service3F-38 ~]# htpasswd /usr/local/nagios/etc/htpasswd.users qiuyuetao
(2)更改cgi.cfg配置
[root@service3F-38 ~]# vi /usr/local/nagios/etc/cgi.cfg
use_authentication=1
如果只允许查看,不允许管理,加上下面配置
authorized_for_read_only=qiuyuetao
authorized_for_all_services=qiuyuetao
authorized_for_all_hosts=qiuyuetao
(3)将userA设为联系人
[root@service3F-38 ~]# vi /usr/local/nagios/etc/objects/contacts.cfg #添加如下配置
define contact{
contact_name qiuyuetao
use generic-contact
alias qyt
}
(4)在属于userA的主机、服务配置文件的联系人中加入qiuyuetao
[root@service3F-38 ~]# vi /usr/local/nagios/etc/objects/hosts.cfg
define host {
host_name web02-1.22@sh
alias web02-1.22@sh
address 10.1.1.22
contacs qyt
contact_groups sys_admins
check_command check-host-alive
max_check_attempts 5
notification_interval 3
notification_period 24x7
notification_options d,u,r
}
(5)重启nagios后生效
[root@service3F-38 ~]# /etc/init.d/nagios restart
Nagios 的详细介绍:请点这里
Nagios 的下载地址:请点这里
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-11/109653.htm
