Revisiting my ServerGrid server monitoring system recently I considered some of the extendability previously discussed with the Hubot Servergrid Scripts. I wondered if I could undertake some HipChat integration whilst at the same time collecting information from a locked-down door entry system.
The RFID Paxton Net2 system stores data on a Windows box by default, in a SQL Server instance. To begin with I considered writing some software that connected to the SQL server directly to get events out, however I noticed that there's the ability within the Net2 software to drive events out of the system.
Now, the way I saw it I had the opportunity using these event tasks to get myself out of writing some PHP to SQL Server software at the same time as getting out of having to write Visual Studio style software. My hopes sank a little to begin with when I realised the Net2 system only allows EXE file launching upon events.
So here came the cunning plan - use a Curl executable to connect to an intermediary system that can collect the event-driven data from door entry box and then push data to HipChat via their own API. The problem comes with providing options to the executable (as an aside I found a way to completely bomb the Net2 system by accidentally providing the full curl call in the "File Open" dialogue for selecting the exe to launch.
The way around this was to write a batch file that could be converted to an executable file - this would need to be undertaken for each user on the door entry system unfortunately in order to get personlised data and messages. Each batch file is a simple affair, calling an API end point much like the one I built on the Hubot system:
Obviously, the Person_Name and Door_Name items are changed to the corresponding values to the doors and people
that you want to notify about. The SomeAPIKeyForServerGrid is obviously a key you choose to communicate with your ServerGrid API
For my case, I'm simply tracking the primary front door and I'm not bothering with internal doors. In your case you might want to notify for specific doors like your server room or the main programming area.
Due to the fact the Net2 system doesn't allow .bat files to be operated I have to use a BAT to EXE converter ( I used the f2ko.de system to undertake this ). Once I have all of my user exe files built up I am able to create a new trigger based on the authentication of a user on a particular door.
Having created my curl exe files I need to create the end point for ServerGrid - I'm also going to include the HipChat API mechanism available from The HipChat Github site. This is version 1 of the API and it is becoming deprecated - you might want to consider swinging to API v2 - note that if you are not the administrator of the system you will have to ask one to create a notification token for the version 1 API (by default all user tokens now only work with v2 API).
I'm taking in a person's name and a door name for my API - I'll auto-generate the date/time stamp when the item is inserted into the database so I need to create a simple controller with a save class and an API end point:
The primary processing part of the API ( based on the Hubot example on this blog ). In this code I've provided a variety of witty messages to integrate with the user and door collection data. You can change these as necessary and drop them to more straight-laced items as required.
Does all the main processing called from the API end point
Putting this all together, the Net2 system receives an authentication from it's reader. This fires off a Curl request to our ServerGrid API. This in turn then logs the activity and send off an API call to the HipChat system which displays the notification in the Chat room. The only thing left is to try a token on your system and see if it all fires up!
Our system now displays a notification when people enter via the main door which helps keep track of who is in the building and hopefully once the extra doorbell is installed we'll be able to program a notification directly into HipChat to warn that someone is at the door!
Next Item.. Securing the Internet of Things
Previous Item.. Hubot Servergrid Scripts