The Power(shell) of Pushover alerts…

Up until a month ago I carried a pager for server outage alerts.. Working in Messaging means we cant rely on email to send the alerts, so its now back to getting called by an operations team to get those alerts..

There has to be another way and thankfully there is with he power of push technology.

Pushover.net is a service teamed with its own iOS and Android applications which allows you to generate and send push alert notifications. Using Powershell for example it is a quick and simple method of getting text to devices without the need to eMail or SMS, including your tablet which would not receive SMS in the first instance.

They are simple alerts up to 512 characters with provision for URL’s. With an account setup you use the API codes for your account and each device gets a named references, you can even generate API’s for specific sources.

So with an account setup and both my android devices listed, I can push alerts to one or both of the devices. This is where it gets useful for system alerting. With one account each on call engineer can have their device listed, and for the period of on call, their specific device will get the alerts generated.

The Powershell function is quite simple and takes four parameters; Message, Title, Priority & device

function SendToPushOver (
    [string]$script:xStrMessage,
    [string]$script:xStrTitle,
    [string]$script:xStrPriority,
    [string]$script:xStrDevice)
{
    $parameters = New-Object System.Collections.Specialized.NameValueCollection
    $parameters.Add("token", "HpokAR0UrNgffu13B4Hg5D4477Sqr3") # Application API Token goes here
    $parameters.Add("user", "KkEItErFdIZGg2kXfzNbedshkysHm9") # Acount API Token goes here
    $parameters.Add("message", "$xStrMessage")
    $parameters.Add("title", "$xStrTitle")
    $parameters.Add("priority", "$xStrPriority")
    $parameters.Add("device", "$xStrDevice")

    $client = New-Object System.Net.WebClient

    $client.UploadValues("https://api.pushover.net/1/messages.json", $parameters)

    [string]$script:xStrMessage=""
    [string]$script:xStrTitle=""
    [string]$script:xStrPriority=""
    [string]$script:xStrDevice=""
}

Now this function can be called from a or batch file, scheduled task or alerting system such as SCOM. The following is called on my home server at start-up to let me know reboot was successful

powershell -command "& { . d:\Apps\pushover.ps1; SendToPushOver 'Server has Started' 'Server Alert' '1' 'Nexus7' }"

At the moment I have only used this on my home server where I don’t suffer the restrictions of a corporate proxy server. For this to work successfully you would need to specify and authenticate with a proxy if you live inside an enterprise infrastructure.

Pushover has a number of other supported scripts including C#, Go, Node.js, Perl, PHP, Python & Ruby and has other methods of delivery.. Another of my personal favorite services IfTTT can generate alerts to devices, meaning any action can send an alert to your device. A simple example would be if the temperature has dropped below 0 degrees..!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s