Sending Alerts to Mobile Phone using Pushover from HTTP.OutboundAdapter
I wanted to see some alerts that occur in my Productions in a Mobile Device, I came across Pushover.net recently that although has an upfront cost $5 you can send as many messages as you like after that, there is a 7 day free trial to check it out.
To Integrate this with a production I did the following.
Create an account and set up a device on https://pushover.net/
Record the following API Keys from the web site on the main page you will see
Your User Key example: ueh3t7478foi3ruf2ogb3syu4fs34s
You then need to create an application I set
Name : Cache
Type : Application
And left the oter settings blank.
This will give you a
API Token/Key example: auh000es1aaaa7ddeb3i4jfkgwswero
I then created this class to add an operation to the production, replace your Key, token and device name into
Do httprequest.SetParam("token","auh000es1aaaa7ddeb3i4jfkgwswero") Do httprequest.SetParam("user","ueh3t7478foi3ruf2ogb3syu4fs34s") Do httprequest.SetParam("device","motogplay")
Class TrustDev.TrustMon.Operations.PushOverSender Extends Ens.BusinessOperation { Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter"; Property Adapter As EnsLib.HTTP.OutboundAdapter; Parameter INVOCATION = "Queue"; Method OnD03Alert(pReq As TrustDev.TrustMon.Messages.Alert, Output pResp As %String) As %Status { Set Message = "Server = <b>"_pReq.ServerName_"</b>" Set Message = Message _ "Alert Code = "_pReq.EventDescription Set title = pReq.EventCode_" : Priority "_pReq.EventAlertValue Set httprequest = ##class(%Net.HttpRequest).%New() Set httprequest.SSLConfiguration = "pushover" Set httprequest.Https = $$$YES Set httprequest.Server = "api.pushover.net" Set httprequest.Location = "/1/messages.json" Set httprequest.ContentType = "application/x-www-form-urlencoded" Do httprequest.SetParam("token","auh000es1aaaa7ddeb3i4jfkgwswero") Do httprequest.SetParam("user","ueh3t7478foi3ruf2ogb3syu4fs34s") Do httprequest.SetParam("device","motogplay") Do httprequest.SetParam("title",title) Do httprequest.SetParam("html",1) Do httprequest.SetParam("message",Message) Do httprequest.Post(,0) set stream = httprequest.HttpResponse.Data while 'stream.AtEnd { Set pResp = stream.Read($$$MaxStringLength) } Quit $$$OK } XData MessageMap { <MapItems> <MapItem MessageType="TrustDev.TrustMon.Messages.Alert"> <Method>OnD03Alert</Method> </MapItem> </MapItems> } }
The message I pass into this class is the following, but you could adapt this to your own requirements.
Class TrustDev.TrustMon.Messages.Alert Extends Ens.Request { Property SiteName As %String; Property ServerName As %String; Property ServerId As %Integer; Property ProductionName As %String; Property EventDateTime As %DateTime; Property EventCode As %String; Property EventItem As %String; Property EventCodeId As %String; Property EventDescription As %String(MAXLEN = 50, TRUNCATE = 1); Property EventValue As %Double; Property EventValueUnits As %String; Property EventSD25 As %Double; Property EventAlertValue As %Double; Property EventAlertNow As %Boolean; Property ErrorCode As %String; Property EventValue2 As %Double; Property EventValue3 As %Double; Property EventValue4 As %Double; Property EventValue5 As %Double; }
Your going to need a empty SSL Client Configuration
In Ensemble go to System > Security Management > SSL/TLS Configurations
Click Create New Configuration
Name it Pushover and leave all the other fields as default and click save
On a Production add a new Operation using the class TrustDev.TrustMon.Operations.PushOverSender
In the basic settings set
HTTP Server = https://api.pushover.net/1/messages.json
In Connection Setting set the SSL Configuration to pushover, as created above
Uncheck SSL Check Server Identity
This should now be working, click Actions -> test and add some values to the Request Details and you should get your first notification through.
Good Luck! :)