pythonnagioshipchat

Nagios - Hipchat integration through Hipsaint


We are trying to integrate nagios (4.1.1) notifications with Hipchat using Hipsaint. We followed the instructions posted here (keep in mind that the instructions mention nagios 3). We filled in the Token and Room_ID. We get the following output:

:~# hipsaint --token=XXXXXXXXXX --room=XXXXXXX --type=host --inputs="$HOSTNAME$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$HOSTSTATE$|$HOSTOUTPUT$" -n

Traceback (most recent call last):
  File "/usr/local/bin/hipsaint", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/hipsaint/bin/commands.py", line 78, in main
    msg.deliver_payload()
  File "/usr/local/lib/python2.7/dist-packages/hipsaint/messages.py", line 68, in deliver_payload_v1
    raw_response = urlopen(self.urlv1, message_params)
  File "/usr/lib/python2.7/urllib2.py", line 133, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 416, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 529, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 454, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 388, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 537, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized

We also tried the following:

Using a new Token

Updating Python from ver 2.7 to 3

Opening the ports for hipchat on the nagios Security Group

Any idea how we can proceed?


Solution

  • Test the validity of your auth token and make sure the test is not responding with "401 Unauthorized" status. If you're using your own private HipChat Server, replace api.hipchat.com with your HipChat Server hostname. Replace YOUR_TOKEN with the auth token you generated. Execute the following from your Nagios server:

    curl https://api.hipchat.com/v1/rooms/list?auth_token=YOUR_TOKEN&auth_test=true
    

    Source: https://www.hipchat.com/docs/api/auth