nagios的一些配置解释
nagios的配置
参考以下地址
http://zhumeng8337797.blog.163.com/blog/static/100768914201110155233669/?suggestedreading&wumii
http://nagios-cn.sourceforge.net/nagios-cn/index.html
1:
无权查看任何主机的信息。 请检查HTTP服务器关于该CGI的访问权限设置。
2:The requested URL /nagios/cgi-bin/status.cgi was not found on this server.
yum安装以下包
yum install gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel
并且重新编译nagios
./configure 添加以下选项
./configure --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
搜索了一下方法
确保 htpasswd.user的所有组为nagios
解决办法:
vi /usr/local/nagios/etc/cgi.cfg
将use_authentication的值改为0.
use_authentication=0
然后重启nagios服务
service nagios restart
还有另外一种可能:
配置文件中的hostname称service_description使用了中文导致的。
记住:hostname和service_description 都最好不要使用中文哦
注:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
use_authentication=0
按照上面修改将默认的1 改为0,但是改这个之后在服务操作的界面,在想调整服务检测的时候就会出现这样的一个提示:
Sorry Dave, I can't let you do that...
其实并不需要降低cgi 的安全性,你只需要把你的nagios 管理员账户添加到cgi.cfg 文件就可
以了,比如我的nagios 管理用户是linux(这个命令生成的账户 htpasswd -c /usr/local/nagios/etc/htpasswd.users linux
只有添加第一个账户要用-c 参数)
就需要在cgi.cfg 文件中修改如下几项:
将每项的nagiosadmin 更改为linux 即可,多用户用”,”分割。
authorized_for_system_information=linux
authorized_for_configuration_information=linux
authorized_for_system_commands=linux
authorized_for_all_services=linux
authorized_for_all_hosts=linux
authorized_for_all_service_commands=linux
authorized_for_all_host_commands=linux
templates.cfg 文件
nagios主要用于监控主机资源以及服务(在nagios中被称为对象,)为了不重复定义一些监控对象,nagios引入了一个模板配置文件,将一些共性的属性定义成模板,以便多次引用,
以下列出部分解释
define contact{
name generic-contact ; 联系人名称
service_notification_period 24x7 ; 当服务出现异常,发送通知时间段
host_notification_period 24x7 ; 当主机出现异常,发送通知时间段
service_notification_options w,u,c,r,f,s ; 定义通知被发现的情况,w=warning,u=unkown,c=criticle,r=recover
host_notification_options d,u,r,f,s ; 定义主机在什么状态下需要发送通知给使用者
service_notification_commands notify-service-by-email ; 服务故障时,发送通知的方式,可以邮件或者短信其中notify-service-by-email在commands.cfg中定义
host_notification_commands notify-host-by-email ; 主机故障时,发送通知的方式,可以邮件或者短信其中notify-service-by-email在commands.cfg中定义
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
define host{
name generic-host ; 不是真正的主机名,是对应主机配置文件中设定的名字
notifications_enabled 1 ;
event_handler_enabled 1 ;
flap_detection_enabled 1 ;
failure_prediction_enabled 1 ;
process_perf_data 1 ; 以上值可以设置为0或者1,作用是否启用nagios的数据输出功能,赋值为1,nagios会将数据写入某个文件
retain_status_information 1 ;
retain_nonstatus_information 1 ;
notification_period 24x7 ; 指定发送通知的时间段
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
# Linux host definition template - This is NOT a real host, just a template!
define host{
name linux-server ; 主机名称
use generic-host ; use表示引用,将主机generic-host所有属性引用到linux-server中
check_period 24x7 ; 告诉nagios检查主机的时间段
check_interval 5 ; 检查时间的间隔(min)
retry_interval 1 ; 重试检查时间间隔(min)
max_check_attempts 10 ; 对主机最大检查数,检测主机异常时,不会马上判断,儿是多试几次,10为至少10次
check_command check-host-alive ; 指定检查主机的命令,在commands.cfg中定义
notification_period workhours ; 主机故障时候发送通知的时间范围 zai timeperiods.cfg中定义
;
;
notification_interval 120 ; 主机异常后,故障一直没解决再次对使用者发出通知时间(min)如果设为0则一次够了
notification_options d,u,r ; 定义主机在什么状态下发送给使用者,d=down,u=unreachable,r=recovery
contact_groups admins ;指定联系人组,这个admins在contact.cfg中定义
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
define service{
name generic-service ; 定义一个服务名称
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness'
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; 以上检查服务的时间段
max_check_attempts 3 ; 最大检查次数
normal_check_interval 10 ; 距离上一次的检查时间
retry_check_interval 2 ; 重试检查时间间隔
contact_groups admins ; 指定联系人组
notification_options w,u,c,r ; 通知可以被发出的情况
notification_interval 60 ; 出现异常后,故障没有解决发出的通知时间
notification_period 24x7 ; 指定发出通知的时间段
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
notes_url /nagios/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
}
resource.cfg
$USER1$=/usr/local/nagios//libexec $USER1指定了安装nagios插件的路径,
由于使用arch所有笔记都记录在KWrite上具体配置已经成功,改日图文并茂updata上来!
页:
[1]