I have Nagios running on a webserver. For this one Nagios service check in particular, if it fails, it will run a script. This script is triggered via Nagios event handlers.
Nagios event handler command:
define command{
command_name testDisableServer
command_line /usr/local/nagios/etc/objects/event_handlers/testDisableServer.sh
}
I am executing a script called testDisableServer.sh from Nagios event handlers that looks like this:
#!/bin/bash
wall "Script execution started";/usr/bin/sudo /root/scripts/disableServer.sh force
This script 'testDisableServer.sh' has the following permissions:
-rwxr-xr-x 1 nagios nagios 2.0KOct1214:57 testDisableServer.sh
When the service goes down, I will get a wall post in my SSH connection saying "Script execution started", but it will not trigger my disableServer.sh script. I tried to place another wall post inside of disableServer.sh and it did not trigger it.
This script is being run by the user 'nagios'. 'nagios' was added in visudo, as such:
nagios ALL=(ALL)NOPASSWD:/root/scripts/disableServer.sh
Running this script as the user 'nagios' from a command line works perfectly fine. However, when the event handler triggers it, there is no output. I tried to catch the output into a log file, and I came up with nothing. These are the permissions on /root/scripts/disableServer.sh:
-rwxr-xr-x 1 root root 2.0KOct1215:01 disableServer.sh
Why would the event handler hit 'testDisableServer.sh', but not execute 'disableServer.sh' from a Nagios event handler, but work just fine in an SSH connection as the user nagios? BTW, 'testDisableServer.sh' is just an extra layer added to see if the event handlers were working, which they seem to be. This will be removed after this script execution is all sorted out.
Answer:
Possibly it's an environment issue (the script is relying on something in its environment that is not available when run by nagios).
I would change your script (temporarily for debugging only) to:
#!/bin/bash
exec 2>/tmp/log."$$"set-x
wall "Script execution started";/usr/bin/sudo /root/scripts/disableServer.sh force
And add another set -x
at the top of disableServer.sh
To see what's going on (in the /tmp/log.*
files).
Executing a script from Nagios event handler fails to run的更多相关文章
-
[翻译]Event Handler Description 事件处理描述
Event Handler Description 事件处理描述 (自定义控件) How should a new event handler be defined if it does not ...
-
Event Handler
在Event Handler中,有一种特殊的Event Handler,称之为Synchronizer或者Denormalizer,其作用就是为了同步“Query Database”.Query Da ...
-
SharePoint中Event Handler的触发
一直以来对于Event Handler的感觉就是:添加.编辑和删除动作之前和动作之后,我们在SharePoint系统中可以做的一些事情 不过在最近处理的一个问题中,发现它在触发时机上出了一点问题 ...
-
SSIS ->;>; Event Handler
Event Handler支持在某个事件触发的时候定义好处理该事件的逻辑,比如错误事件触发是该怎么处理.它跟Control Flow界面相似,就好像执行了另外一个包一样.Event Handler不仅 ...
-
JPA project Change Event Handler问题解决[转]
转至:http://my.oschina.net/cimu/blog/278724 这是Eclipse中的一个GUG: Bug 386171 - JPA Java Change Event Handl ...
-
jquery , find the event handler,找到jquery中的event handler
找到 dispatch: function (e) { e = b.event.fix(e); var n, r, i, s, o, u = [], a = d.call(arguments), f ...
-
为什么Form.Timer的event handler在Form被Dispose之后还是被调到了?
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:为什么Form.Timer的event handler在Form被Dispose之后还是被调到了?.
-
Qt的事件模型(5种使用办法,通常重新实现event handler即可。只有定义控件才需要管理信号的发射)
Qt的事件模型 1.事件的概念 应用程序对象将系统消息接收为 Qt 事件.应用程序可以按照不同的粒度对事件加以监控.过滤并做出响应. 在 Qt 中,事件是指从 QEvent继承 的对象.Qt将事件发送 ...
-
linux input如何固定设备event handler
于qt开发时间.遇到的问题,usb输入设备(鼠标器,usb 电容屏)在动力分配后自己主动input节点,实例usb鼠标停留电后,分配给自己的主动性/dev/input/event0 mouse0.第一 ...
随机推荐
-
1 《JavaScript高级程序设计》学习笔记(1)
欢迎关注本人的微信公众号"前端小填填",专注前端技术的基础和项目开发的学习. 首先,我将从<JavaScript高级程序设计>这本JavaScript学习者必看的经典教 ...
-
c++中头文件include规则浅析[译]
英文原文地址 在开发大型的软件项目时,头文件需要得到恰当的管理,甚至在c中也会面临这种问题,当我们用c++开发时,头文件的管理会变得更复杂,更加耗费我们的时间去管理,下面我将讲一些包含规则来简化这个苦 ...
-
安装oracle 12c遇到问题
安装前步骤:更改用户账户控制设置:从不通知 出现 "SEVERE: [FATAL] [INS-30014] 无法检查指定的位置是否位于 CFS 上" 解决办法:重新设置hosts ...
-
甘果移动老甘:移动互联网变迁中的App和小程序
2018 年 10 月13 日,由又拍云和知晓云联合主办的 Open Talk 丨2018 小程序开发者沙龙系列活动广州站拉开帷幕,甘果移动的 CEO 路文杰(老甘)在沙龙上做了<移动互联网变迁 ...
-
Mac下使用国内镜像安装Homebrew
First MBP上的brew很老了,就想把brew更新一下,顺便安装一下NodeJs.无奈更新的过程一直卡在网络下载,毫不动弹.想想,应该是Repo访问不到的原因,于是重装brew. 根据官网上的方 ...
-
封装手风琴!使用jQuery!
//封装手风琴 /** * * * */ $.fn.accordion = function (colors, width) { var width=width||0; var colors= col ...
-
jupyter notebook安装纪要
本次教程使用python工具pip安装.更多安装方式请参考官网. 1.升级pip工具到最新 2.运行安装执行 pip install jupyter 3.安装中 4.更改工作目录 4.1获取配置文件路 ...
-
ssh: connect to host github.com port 22: Connection timed out
问题描述 $ git clone git@github.com:MaugerWu/MaugerWu.github.io.git Cloning into 'MaugerWu.github.io'... ...
-
LoadRunner脚本参数化之自动关联和手动关联
一.关联的意义 1.关联的含义 关联(correlation):在脚本回放过程中,客户端发出请求,通过关联函数所定义的左右边界值(也就是关联规则),在服务器所响应的内容中查找,得到相应的值,以变量的 ...
-
Python *Mix_w5
1. 字典dict dict 用{}来表示 ,键值对数据{key:value} key具有唯一性 键:都必须是可哈希的,除了列表,不可变的数据类型都可以当做字典中的键 值 没有任何限制 2. 字 ...