A command line tool for pushing Nagios host and service notifications to a HipChat room.
Project description
==========
HipSaint
==========
Push your nagios notifications to HipChat using a simple command line tool.
.. image:: https://travis-ci.org/hannseman/hipsaint.png?branch=master
:target: https://travis-ci.org/hannseman/hipsaint
.. image:: https://img.shields.io/pypi/dm/hipsaint.svg
:target: https://pypi.python.org/pypi/hipsaint
Implements `HipChat message API`_.
.. _`hipchat message API`: https://www.hipchat.com/docs/api/method/rooms/message
Inspired by https://gist.github.com/2418848.
---------
Install
---------
Through pip:
.. code-block:: bash
pip install hipsaint
Or clone and simply run:
.. code-block:: bash
python setup.py install
-------
Usage in Nagios
-------
Assuming you use Nagios 3 add the following sections to commands.cfg with ``<TOKEN>`` and ``<ROOM_ID>`` specified and macros delimited by ``|``::
define command {
command_name notify-host-by-hipchat
command_line hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$HOSTSTATE$|$HOSTOUTPUT$" -n
}
define command {
command_name notify-service-by-hipchat
command_line hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC$|$HOSTALIAS$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$SERVICESTATE$|$SERVICEOUTPUT$" -n
}
To send less verbose messages to hipchat set the ``--type`` flag to either ``short-host`` or ``short-service``.
Additional commands is available through:
.. code-block:: bash
hipsaint --help
Edit the Nagios contacts.cfg file by adding or editing an existing user and adding the notification commands created above::
define contact {
....
.....
service_notification_commands notify-service-by-hipchat
host_notification_commands notify-host-by-hipchat
email /dev/null
}
-------
Usage in Icinga 2
-------
To use Hipsaint in Icinga 2, you can create an additional config like this :
Create two scripts, one for hosts, one for services :
Don't forget to fill ``<TOKEN>`` and ``<ROOM_ID>``.
Hosts : /etc/icinga2/scripts/hipchat-host-notification.sh ::
#!/bin/bash
hipsaint --user=Icinga --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$HOSTSTATE|$HOSTOUTPUT" -n
or
hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$HOSTSTATE|$HOSTOUTPUT" -n
Services : /etc/icinga2/scripts/hipchat-service-notification.sh ::
#!/bin/bash
hipsaint --user=Icinga --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC|$HOSTALIAS|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$SERVICESTATE|$SERVICEOUTPUT" -n
or
hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC|$HOSTALIAS|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$SERVICESTATE|$SERVICEOUTPUT" -n
Then you need to tell Icinga to use those scripts :
Create a file called ``hipsaint.conf`` in your ``conf.d`` directory ::
/**
* Hipchat/Hipsaint script for Icinga2
*
* Only applied if host/service objects have
* the custom attribute `sla` set to `24x7`.
*/
object NotificationCommand "notify-host-by-hipchat" {
import "plugin-notification-command"
command = [ "/etc/icinga2/scripts/hipchat-host-notification.sh" ]
env = {
HOSTNAME = "$host.name$"
LONGDATETIME = "$icinga.long_date_time$"
NOTIFICATIONTYPE = "$notification.type$"
HOSTADDRESS = "$address$"
HOSTSTATE = "$host.state$"
HOSTOUTPUT = "$host.output$"
}
}
object NotificationCommand "notify-service-by-hipchat" {
import "plugin-notification-command"
command = [ "/etc/icinga2/scripts/hipchat-service-notification.sh" ]
env = {
SERVICEDESC = "$service.name$"
HOSTALIAS = "$host.display_name$"
LONGDATETIME = "$icinga.long_date_time$"
NOTIFICATIONTYPE = "$notification.type$"
HOSTADDRESS = "$address$"
SERVICESTATE = "$service.state$"
SERVICEOUTPUT = "$service.output$"
}
}
apply Notification "hipchat-icingaadmin" to Host {
command = "notify-host-by-hipchat"
user_groups = [ "icingaadmins" ]
assign where host.vars.sla == "24x7"
}
apply Notification "hipchat-icingaadmin" to Service {
command = "notify-service-by-hipchat"
user_groups = [ "icingaadmins" ]
assign where service.vars.sla == "24x7"
}
You want to customize this to your groups and users.
HipSaint
==========
Push your nagios notifications to HipChat using a simple command line tool.
.. image:: https://travis-ci.org/hannseman/hipsaint.png?branch=master
:target: https://travis-ci.org/hannseman/hipsaint
.. image:: https://img.shields.io/pypi/dm/hipsaint.svg
:target: https://pypi.python.org/pypi/hipsaint
Implements `HipChat message API`_.
.. _`hipchat message API`: https://www.hipchat.com/docs/api/method/rooms/message
Inspired by https://gist.github.com/2418848.
---------
Install
---------
Through pip:
.. code-block:: bash
pip install hipsaint
Or clone and simply run:
.. code-block:: bash
python setup.py install
-------
Usage in Nagios
-------
Assuming you use Nagios 3 add the following sections to commands.cfg with ``<TOKEN>`` and ``<ROOM_ID>`` specified and macros delimited by ``|``::
define command {
command_name notify-host-by-hipchat
command_line hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$HOSTSTATE$|$HOSTOUTPUT$" -n
}
define command {
command_name notify-service-by-hipchat
command_line hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC$|$HOSTALIAS$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$SERVICESTATE$|$SERVICEOUTPUT$" -n
}
To send less verbose messages to hipchat set the ``--type`` flag to either ``short-host`` or ``short-service``.
Additional commands is available through:
.. code-block:: bash
hipsaint --help
Edit the Nagios contacts.cfg file by adding or editing an existing user and adding the notification commands created above::
define contact {
....
.....
service_notification_commands notify-service-by-hipchat
host_notification_commands notify-host-by-hipchat
email /dev/null
}
-------
Usage in Icinga 2
-------
To use Hipsaint in Icinga 2, you can create an additional config like this :
Create two scripts, one for hosts, one for services :
Don't forget to fill ``<TOKEN>`` and ``<ROOM_ID>``.
Hosts : /etc/icinga2/scripts/hipchat-host-notification.sh ::
#!/bin/bash
hipsaint --user=Icinga --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$HOSTSTATE|$HOSTOUTPUT" -n
or
hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=host --inputs="$HOSTNAME|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$HOSTSTATE|$HOSTOUTPUT" -n
Services : /etc/icinga2/scripts/hipchat-service-notification.sh ::
#!/bin/bash
hipsaint --user=Icinga --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC|$HOSTALIAS|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$SERVICESTATE|$SERVICEOUTPUT" -n
or
hipsaint -V 2 --token=<TOKEN> --room=<ROOM_ID> --type=service --inputs="$SERVICEDESC|$HOSTALIAS|$LONGDATETIME|$NOTIFICATIONTYPE|$HOSTADDRESS|$SERVICESTATE|$SERVICEOUTPUT" -n
Then you need to tell Icinga to use those scripts :
Create a file called ``hipsaint.conf`` in your ``conf.d`` directory ::
/**
* Hipchat/Hipsaint script for Icinga2
*
* Only applied if host/service objects have
* the custom attribute `sla` set to `24x7`.
*/
object NotificationCommand "notify-host-by-hipchat" {
import "plugin-notification-command"
command = [ "/etc/icinga2/scripts/hipchat-host-notification.sh" ]
env = {
HOSTNAME = "$host.name$"
LONGDATETIME = "$icinga.long_date_time$"
NOTIFICATIONTYPE = "$notification.type$"
HOSTADDRESS = "$address$"
HOSTSTATE = "$host.state$"
HOSTOUTPUT = "$host.output$"
}
}
object NotificationCommand "notify-service-by-hipchat" {
import "plugin-notification-command"
command = [ "/etc/icinga2/scripts/hipchat-service-notification.sh" ]
env = {
SERVICEDESC = "$service.name$"
HOSTALIAS = "$host.display_name$"
LONGDATETIME = "$icinga.long_date_time$"
NOTIFICATIONTYPE = "$notification.type$"
HOSTADDRESS = "$address$"
SERVICESTATE = "$service.state$"
SERVICEOUTPUT = "$service.output$"
}
}
apply Notification "hipchat-icingaadmin" to Host {
command = "notify-host-by-hipchat"
user_groups = [ "icingaadmins" ]
assign where host.vars.sla == "24x7"
}
apply Notification "hipchat-icingaadmin" to Service {
command = "notify-service-by-hipchat"
user_groups = [ "icingaadmins" ]
assign where service.vars.sla == "24x7"
}
You want to customize this to your groups and users.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hipsaint-0.7.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file hipsaint-0.7.tar.gz
.
File metadata
- Download URL: hipsaint-0.7.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3f7a5f45bd432d032a5c9a8a13d8dfc1dde1719489bd30aaf4aa640cfa6862 |
|
MD5 | 3be342980aec618d1e446a5816220c02 |
|
BLAKE2b-256 | d13f7ccb8261c0cdda047cc54e19ce0351cf3d11fdd4971e79db0f4b95d519ac |
File details
Details for the file hipsaint-0.7-py2.py3-none-any.whl
.
File metadata
- Download URL: hipsaint-0.7-py2.py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fec5693ff5f7bbdf4d052e11ded1a357881e98b29e62cf681ccceeab927e4b4 |
|
MD5 | b7b6b3ff04c00e25d428aae219f8efb4 |
|
BLAKE2b-256 | 812d53f985b2cee7fcd5c098a16dd0906e224b2f554f81101df5fc951a593ace |