Home

Awesome

hipchat-cli

Some command line scripts for performing HipChat API calls. For details on how to obtain a token and room id, see the tutorial.

./hipchat_room_message

Used to send a message to a room.

$ cat message.txt | ./hipchat_room_message -t <token> -r <room> -f "System"

Configuration

hipchat-cli can be configured with one of the following options in a combination of those.

Command-line options

Command-line options are passed into hipchat-cli. A list of options is available by executing hipchat_room_message -h.

$ ./hipchat_room_message -h
Usage: ./hipchat_room_message -t <token> -r <room id> -f <from name>

This script will read from stdin and send the contents to the given room as
a system message. Or use -i message.

OPTIONS:
   -h             Show this message
   -t <token>     API token
   -r <room id>   Room ID
   -f <from name> From name (optional in v2 API)
   -c <color>     Message color (yellow, red, green, purple, gray
                                 or random - default: yellow)
   -m <format>    Message format (html or text - default: html)
   -i <input>     Optional: Input to send to room (default: stdin)
   -l <level>     Nagios message level (critical, warning, unknown,
                                        ok, down, up).  Will override color.
   -n             Trigger notification for people in the room
   -o             API host (api.hipchat.com)
   -v <version>   API version (default: v1)
   -k             Allow curl to make insecure SSL connections

Usage example:

$ ./hipchat_room_message -vv2 -t <TOKEN> -r <ROOM> -i "This is a message"

Environment variables

All options available as command-line options can be passed in as environment variables.

Environment variableDescription
HIPCHAT_TOKENAPI token
HIPCHAT_ROOM_IDRoom ID
HIPCHAT_FROMFrom name
HIPCHAT_COLORMessage color (yellow, red, green, purple, gray or random - default: yellow)
HIPCHAT_FORMATMessage format (html or text - default: html)
HIPCHAT_NOTIFYTrigger notification for people in the room (default: 0)
HIPCHAT_HOSTAPI host (default: api.hipchat.com)
HIPCHAT_LEVELMessage Level (targetting Nagios states, critical, warning, unknown, ok)
HIPCHAT_APIAPI version (default: v1)

Usage example:

$ cat message.txt | HIPCHAT_TOKEN=<token> HIPCHAT_ROOM_ID=1234 ./hipchat_room_message -f "System"

Configuration file

All environment variables can be specified in a configuration file. The configuration file is /etc/hipchat.

Usage example:

Configuration in /etc/hipchat:

HIPCHAT_TOKEN=<token>
HIPCHAT_ROOM_ID=1234

Command-line:

$ cat message.txt | HIPCHAT_FROM="System" ./hipchat_room_message -c green