首页 > nagios > nagios监控提示null

nagios监控提示null

2010年8月2日 eric 发表评论 阅读评论

今天在nagios插件网上下载了一个check_uptime.pl 插件,来监测nginx服务器的运行天数,服务器的运行时间·下载下来在服务器上执行能得到数据,但是在nagios服务器上,在commands.cfg 加了配置文件,然后在services.cfg 加了监测服务,在nagios 页面上显示 null. 在网上查找了好久原因都没找到问题的所在,想好了久,既然执行命令能输出内容,为什么在nagios上不能输出内容呢,发现是这个插件的输出内容格式与 nagios 的内容格式不符所导致的。

报警信息为:
***** Nagios *****

Notification Type: PROBLEM

Service: fms_uptime1
Host: fms-server
Address: 219.232.237.166
State: CRITICAL

Date/Time: Mon Aug 2 13:39:17 CST 2010

Additional Info:

(null)

下载的 check_uptime.pl 输出内容:

nagios $> ./check_uptime.pl -H -L
OK :UPTIME on fms - current uptime: 23 days

正确格式应该为:

OK - UPTIME on fms - current uptime: 23 days

状态 后面要跟 – 不能为冒号 :

修改 代码

nagios $> vim /usr/local/nagios/libexec/check_uptime.pl

# 按 shift +g 跳到最后一行

print "$result :UPTIME on $hostname -$message current uptime: $uptime $units\n";

把这行 改为

print "$result - UPTIME on $hostname ($message current uptime: $uptime $units )\n";

# wq 保存退出
然后在执行代码

nagios $> ./check_uptime.pl -H -L
OK - UPTIME on fms ( current uptime: 23 days )

过了nagios 的重新检测时间nagios 页面上 在也不是显示 null 了。显示出了 OK – UPTIME on fms ( current uptime: 23 days )

下面我顺便介绍一下这个插件的使用方法:

1.下载 check_uptime.pl 到 /usr/local/nagios/libexec/ 目录下 给予 可执行权限
2.修改 /usr/local/nagios/etc/objects/commands.cfg 加入代码:
define command{
command_name check_uptime
command_line $USER1$/check_uptime.pl -H -L -W $ARG1$ -C $ARG2$ -w $ARG3$ -c $ARG4$
}
3.修改 services.cfg 加入代码:

define service{
    use                     local-service,srv-pnp
    host_name               fms
    service_description     fms_uptime
    check_command           check_uptime!365!400!2!1
}

# 如果是 nrpe 客户端 则加入:

command[check_uptime]=/usr/local/nagios/libexec/check_uptime.pl -H -L -W 365 -C 400 -w 1 -c 0

4.重启服务

/etc/init.d/nagios restart

# nrpe 客户端

/etc/init.d/xinetd restart

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/206.html

分类: nagios 标签: ,
  1. 2010年8月3日21:32 | #1

    command[check_memory]=/usr/local/nagios/libexec/check_uptime.pl -H -L -W 365 -C 400 -w 1 -c 0
    改成
    command[check_uptime]=/usr/local/nagios/libexec/check_uptime.pl -H -L -W 365 -C 400 -w 1 -c 0

    吧,虽然都知道

  2. 2010年8月4日12:36 | #2

    谢谢虎总,大意了~

  1. 本文目前尚无任何 trackbacks 和 pingbacks.
订阅评论
2+6= (必填)