用于将nagios主机和服务通知推送到hip聊天室的命令行工具。
hipsaint的Python项目详细描述
===
hipsant
==
使用简单的命令行工具将Nagios通知推送到hipchat。
图片:https://travis-ci.org/hannseman/hipsant.png?branch=master
:目标:https://travis ci.org/hannseman/hipsant
…图片::https://img.shields.io/pypi/dm/hipsaint.svg
:目标:https://pypi.python.org/pypi/hipsaint
实现"hipchat消息api"。
_` hipchat消息api`:https://www.hipchat.com/docs/api/method/rooms/message
灵感来源于https://gist.github.com/2418848。
-
-
install
-
代码块::bash
pip安装hipsant
,或者克隆并简单运行:
…代码块::bash
python setup.py install
----
在nagios中的用法
----
假设使用nagios 3,则将以下部分添加到commands.cfg中,并使用"`<;token>;"和"`<;room&u id>;"指定"`",宏以"``分隔:
定义命令{
通过hipchat通知主机的命令名ommand_name通过hipchat通知服务se messages to hipchat将`--type``标志设置为``short host``或``short service``。
其他命令可通过:
。代码块::bash
通过hipchat命令通知服务吃两个脚本,一个用于主机,一个用于服务:
别忘了填写``<;token>;``和`<;room-id>;```。
主机/etc/icinga2/scripts/hipchat-host-notification.sh:
!/bin/bash
hipsant--user=icinga--token=<;token>;--room=<;room_id>;--type=host--inputs="$hostname$longdatetime$notificationtype$hostaddress$hoststate$hostoutput"-n
hipsant-v 2--token=<;token>;--room=<;room_id>;--type=host--inputs="$hostname$longdatetime$notificationtype$hostaddress$hoststate$hostoutput"-n
>服务/etc/icinga2/scripts/hipchat-service-notification.sh::
\/bin/bash
hipsant--user=icinga--token=<;token>;--room=<;room_id>;--type=service--inputs="$servicedsc$hostalias$longdatetime$notificationtype$hostaddress$servicestate$serviceoutput"-n
或
hipsant-v 2--token=<;token>;--room=<;room_id>;--type=service--inputs="$servicedesc$hostalias$longdatetime$notificationtype$hostaddress$servicestate$serviceoutput"-n
然后您需要告诉icinga使用这些脚本:
*ICinga2的hipchat/hipsant脚本
*
*仅当主机/服务对象的自定义属性"sla"设置为"24x7"时才应用。
*/
object notification command"notify host by hipchat"{
导入"plugin notificationcommand"
command=["/etc/icinga2/scripts/hipchat host notification.sh"]
host name="$host.name$"
long date time="$icinga.long廑date廑time$"
notification type="$notification.type$"
host address="$address$"
host state="$host.state$"
host output="$host.output$"
}
}
导入"插件通知命令"
env={
servicedesc="$service.name$"
hostalias="$host.display_name$"
long date time="$icinga.long_date_time$"
notification type="$notification.type$"
host address="$address$"
service state="$service.state$"
service output="$service.output$"
}
}
apply notification"hipchat-icingaadmin"到主机{
command="notify host by hipchat"
user-groups=["icingaadmins"]
}
将通知"hipchat icingaadmin"应用于服务{
command="notify service by hipchat"
assign where service.vars.sla=="24x7"
}
hipsant
==
使用简单的命令行工具将Nagios通知推送到hipchat。
图片:https://travis-ci.org/hannseman/hipsant.png?branch=master
:目标:https://travis ci.org/hannseman/hipsant
…图片::https://img.shields.io/pypi/dm/hipsaint.svg
:目标:https://pypi.python.org/pypi/hipsaint
实现"hipchat消息api"。
_` hipchat消息api`:https://www.hipchat.com/docs/api/method/rooms/message
灵感来源于https://gist.github.com/2418848。
-
-
install
-
代码块::bash
pip安装hipsant
,或者克隆并简单运行:
…代码块::bash
python setup.py install
----
在nagios中的用法
----
假设使用nagios 3,则将以下部分添加到commands.cfg中,并使用"`<;token>;"和"`<;room&u id>;"指定"`",宏以"``分隔:
定义命令{
通过hipchat通知主机的命令名ommand_name通过hipchat通知服务se messages to hipchat将`--type``标志设置为``short host``或``short service``。
其他命令可通过:
。代码块::bash
通过hipchat命令通知服务吃两个脚本,一个用于主机,一个用于服务:
别忘了填写``<;token>;``和`<;room-id>;```。
主机/etc/icinga2/scripts/hipchat-host-notification.sh:
!/bin/bash
hipsant--user=icinga--token=<;token>;--room=<;room_id>;--type=host--inputs="$hostname$longdatetime$notificationtype$hostaddress$hoststate$hostoutput"-n
hipsant-v 2--token=<;token>;--room=<;room_id>;--type=host--inputs="$hostname$longdatetime$notificationtype$hostaddress$hoststate$hostoutput"-n
>服务/etc/icinga2/scripts/hipchat-service-notification.sh::
\/bin/bash
hipsant--user=icinga--token=<;token>;--room=<;room_id>;--type=service--inputs="$servicedsc$hostalias$longdatetime$notificationtype$hostaddress$servicestate$serviceoutput"-n
或
hipsant-v 2--token=<;token>;--room=<;room_id>;--type=service--inputs="$servicedesc$hostalias$longdatetime$notificationtype$hostaddress$servicestate$serviceoutput"-n
然后您需要告诉icinga使用这些脚本:
*ICinga2的hipchat/hipsant脚本
*
*仅当主机/服务对象的自定义属性"sla"设置为"24x7"时才应用。
*/
object notification command"notify host by hipchat"{
导入"plugin notificationcommand"
command=["/etc/icinga2/scripts/hipchat host notification.sh"]
long date time="$icinga.long廑date廑time$"
notification type="$notification.type$"
host address="$address$"
host state="$host.state$"
host output="$host.output$"
}
}
导入"插件通知命令"
env={
servicedesc="$service.name$"
hostalias="$host.display_name$"
long date time="$icinga.long_date_time$"
notification type="$notification.type$"
host address="$address$"
service state="$service.state$"
service output="$service.output$"
}
}
apply notification"hipchat-icingaadmin"到主机{
command="notify host by hipchat"
user-groups=["icingaadmins"]
将通知"hipchat icingaadmin"应用于服务{
command="notify service by hipchat"
assign where service.vars.sla=="24x7"
}