Integrating Uptime Infrastructure Monitor alerting with Atlassian Hipchat rooms

by Jul 19, 2016

So I got bored this past Friday night. Having a young child often means earlier bedtimes and well, sometimes I just can't sleep. I got to thinking about work as often happens, and how we use Uptime in our day to day. I use software like Skype and Hipchat all day long. If anything I am more available via instant message than I am by email! So I thought to myself "Why not do an integration for Uptime?" One of the themes at this year's Monitorama conference that recently passed in Portland, was monitoring software needing to work more like WE (humans) do already. Why reinent your workflow right? I'll be honest, I get emails ALL DAY LONG, and I do actually use our demo lab of UIM to monitor real stuff that I am a one man band supporting. But, like most, I too have an email rule to sort the monitoring alert emails from the rest (and one for marketing too but SSHH! Don't tell them I said that 🙂 )

So I bring you… a Hipchat integration script for Uptime! And, well, really any of our tools with very slight modification! I wrote this in Powershell for Windows based monitoring stations after failing miserably at using Curl from the command line. I plan on writing it in Python for portability into Linux based monitoring stations as time allows, but for the moment, this is what I got. It's pretty free of extraneous "features". Basically, it runs as an action profile script in Uptime and takes environment variables that Uptime passes along about the event triggering the action. Those variables get crafted into a plain English message (you expected middle-English did you?!?) and color codes the message in the chat room based upon the severity of the alert. Critical is red, warning orange, and a return to OK is green. We love stoplights in IT don't we? Here's a screenshot:

Now, for a little How-to. It's actually quite simple. First, if you already have a chatroom you like to use for this sort of thing, feel free to use it, but I generally suggest creating a new one for this sole reason. I won't cover how to do that here… So, now you have that, click on that gear in the bottom right, configure integrations… Then click on the first box "build your own". From there, give the room a name and hit create… Next you'll get a URL to post to and a curl example. Copy and paste the URL they give you, into my script in place of the "https://yoururlhere.com" link I have… The rest should be fine unless you decide you DO NOT like stoplights and want to use different colors, and that part of the could should be pretty obvious…

Save the PS1 file out to your ./uptime/scripts folder along with the .bat file. You'll need to edit that file however to reflect the location of said uptime/scripts folder. I use c:uptime, because, well, it's JUST EASIER. You might be using the default c:program files…yada…yadadadadada.. folder.. if you are just make sure what you put in there is accurate.

The batch does an execution policy bypass for you because well, I'm bad and I don't sign anything I write (does anybody? probably..) The script then gets called via uptime as an action profile script. So you want to create a new action profile in Uptime, perhaps call it something reasonable like "Hipchat send to room blah blah so on and so forth". You may wish to change the firing order, or not. By default it will happen the first and every subsequent time. This MAY get annoying, so again, you have the option to change it.. Perhaps you do it on the first action and never again? It's up to you. Not to sound like a brown-noser, but that's one of the things I love about Uptime. Configurability. Not to mention the fact you can DO STUFF LIKE THIS IN THE FIRST PLACE. Woo! Ok. So that profile would look liike so:

Ok and now for the code. No.. I'm not putting it here of course, it's going on GitHub of course! I may want to improve it at some point and never fear I will version it with notes and you can see all that anyway, because, Github. 🙂 The link:

github.com/…/Uptime-Hipchat-Alert

What do you guys think? Useful? Totally worthless? Want to see another integration? Let's talk about it! Hit me up in the replies below!

~Robert