我花了一天在nagios上设置自定义的twitter通知。 一切似乎都已经到位,通知似乎被触发,但脚本不被调用。
我的通讯录configuration如下所示:
define contactgroup{ contactgroup_name twittergroup alias twittergroup members user1 } define contact { contact_name user1 alias user1 service_notification_period 24x7 host_notification_period 24x7 service_notification_options c,r host_notification_options d,r service_notification_commands streamnotify-service-twitter-dm host_notification_commands streamnotify-host-twitter-dm }
一个典型的服务看起来像这样:
define service{ use generic-service host_name ra-stream-monitoring-host servicegroups streaming_services service_description Stream / starrfm-redfm ingest stream check_command check_http_status!"http://somestream" contact_groups admins,twittergroup }
我的commands.cfg有这些条目:
define command { command_name streamnotify-host-twitter-dm command_line echo "todo notify host by twitter" } define command { command_name streamnotify-service-twitter-dm command_line /etc/nagios3/streamnotify_twitter.sh }
/etc/nagios3/streamnotify_twitter.sh中的脚本看起来像这样
!/bin/bash touch /etc/nagios3/CALLED
尽pipenagios的通知面板报告已经通知了user1,但是CALLED文件从未被创build
我们也有pipe理员组中的自定义松散通知,这些工作正常,如果我手动触发通知,但不是新的twitter通知。
我怎么去debugging呢? 我已经看了一下nagios的debugging日志,命令似乎被执行。 但据我可以告诉有什么问题,因为该文件是从来没有创build。 对于今天晚上关于纳吉奥斯的许多愤怒的咆哮,这一直是个提示,但是这也没有解决问题(无论如何这可能是我的错)。
提前致谢。
你的脚本在第一行的开头缺less一个合适的shebang。 它应该是#!/bin/bash 。
另外,nagios用户在/ etc / nagios3中没有写权限(我猜Ubuntu的包),这几乎是一个肯定的情况。 脚本实际上不属于那里,但那不是重点。
如果你想以这种方式进行testing,请将testing文件path更改为/tmp内容。