如何从命令行通过curl为任何特定的nagios主机设置一定时间的停机时间?
我需要通过curl 从命令行为特定nagios 主机设置计划停机时间..我该怎么做?
这是我已经用于从命令行启用/禁用服务/主机通知的东西。
curl -d "some input here" url "user:pass"
就像我需要为计划停机时间做的事情一样。现在的问题是停机时间选项需要更多选项,即开始时间、结束时间、评论等。
那么我如何从命令行通过curl来完成它呢?
curl -d " some key value pair(hostname,servicename" url "username:passowrd"
这将从命令行打开和关闭服务/主机通知。所以我想以这种方式使用curl 来为特定的nagios 服务器提供停机时间。
上面的脚本不起作用,因为 nagios 的停机选项需要更多参数,我尝试将这些参数注入脚本中..但它没有那样工作。我们还需要提供开始时间、结束时间和注释值。
另外,我已经尝试了curl的名为--form和--form-string的选项与该脚本..无法通过。
基本的想法是我们不想进入 Nagios Web 界面,而是从命令行完成这件事(我们已经成功实现了服务/主机服务和通知)。
希望我现在已经完全清楚了。
蒂亚·
巴斯卡
I need to set a schedule downtime for specific nagios host from the commandline by curl..how do I do that?
here is something I am already using for service/host notification enable/disable from commandline.
curl -d "some input here" url "user:pass"
Like way I need to do the thing for schedule downtime.Now the problem is that downtime option takes more options i.e starttime,endtime,comment etc.
So how do I get it done by curl from the commandline?
curl -d " some key value pair(hostname,servicename" url "username:passowrd"
which will do the service/host notification on and off from the commandline. So I want use curl in this fashion to provide downtime for specific nagios server.
Above script is not working for it because downtime option of nagios taked more parameter and I tried to infuse those in the script..but it didn't work out that way.We need provide starttime,endtime and comment value too.
Plus I have tried curl's option called --form and --form-string with that script..not able to get through.
The besic idea is instead of going to the Nagios web interface, we want to done this thing from the command line(we have succeded for service/host service and notification).
Hope I am absolutely clear now.
TIA
Bhaskar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我增强了 Anders 的答案,以提供完整的脚本,并且不需要使用支持 --data-urlencode 的较新的curl。这还会自动计算发送的结束时间并检查请求是否已成功提交给 Nagios。此外,这还会安排主机和主机上所有服务的停机时间。
I enhanced Anders answer to provide a complete script and to not require the use of a newer curl that supports --data-urlencode. This also automatically calculates the end time to send and checks that the request was successfully submitted to Nagios. Also, this schedules downtime for the host and all the services on the host.
您只需添加更多
--data(-d)
参数即可使用curl
发送多个表单字段值。这应该安排 Nagios 系统上的服务停机时间:You can send multiple form field values with
curl
simply by adding more--data(-d)
arguments. This should schedule service downtime on a Nagios system:我进一步增强了 Sarels 的回答。
HOST
和USER
设为命令行我的版本:
I further enhanced Sarels answer.
HOST
andUSER
a command line argMy version:
为了在我的 Nagios 上工作,我必须在“data host=$HOST”下添加一行额外的行
--data “com_author=Automatic+Downtime” \
如果没有它,我的 Nagios 将不会接受停机。
For this to work on my Nagios, I had to add an extra line under "data host=$HOST"
--data "com_author=Automatic+Downtime" \
Without that, my Nagios wouldn't accept the downtime.