KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Additional Alert options

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Wish list
View previous topic :: View next topic  
Author Message
Malice



Joined: 19 Jan 2016
Posts: 1

PostPosted: Tue Jan 19, 2016 8:14 am    Post subject: Additional Alert options Reply with quote

We are starting to use slack https://slack.com/ to create channels for each alerting system to keep track all in one place.

It would be great if hostmon had the ability to plug straight into the Slack API so we don't have to rely on a system such as email which has no guaranteed delivery reliability.

cheers.
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2833

PostPosted: Wed Jan 20, 2016 5:32 pm    Post subject: Reply with quote

You may use "Execure external program" action with the folowing JScript.

Code:
objArgs = WScript.Arguments;
var http = new ActiveXObject("MSXML2.ServerXMLHTTP");
http.setOption(2,13056);
var url = "https://hooks.slack.com/services/T0JSK6152/B0JSBEQG5/mr4w8zwBnfwLrtxvpyHJKL";
var alertmsg = "";
for (i = 0; i < objArgs.length; i++)
{
   alertmsg+=objArgs(i)+' ';
}
http.open("POST", url, false);
http.setRequestHeader("Content-type", "application/json");
try {
data = '{"text":"'+alertmsg+'"}';
http.send(data);
} catch(e) {
  throw new Error(e.message);
  WScript.Quit;
}
var resp = http.responseText;
WScript.StdOut.Write(resp);


Just save script into slack.js, add new "Execute external program" action with the following parameters:
Command line: cmd /c cscript D:\SCRIPTS\slack.js TestName=%TestName% Status=%Status% Reply=%Reply% Recurrences=%Recurrences%
Window mode: WS_HIDE

Please note, url value (Line 4 of this script) should be replaced by your "Webhook URL"

How to get your "Webhook URL":
1. Sign in to Slack
2. Create channel for HostMonitor alerts (e.g. #HostMonitor)
3. Click on your username (top left corner) -> Apps & Custom Integrations
4. Click on "Build your own" button (top right corner)
5. Click on "Make a Custom integration" (Something just for my team)
6. Select Incomming WebHooks
7. Post to Channel: select #HostMonitor
8. Click on "Add incomming WebHooks integration"
9. Copy your "Webhook URL" and paste it to Line 4 of slack.js
10. Review incomming WebHooks settings and click "Save Settings"
Back to top
View user's profile Send private message Send e-mail Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 11808
Location: USA

PostPosted: Thu Jan 21, 2016 6:19 am    Post subject: Reply with quote

PS I think we will add new action in future versions

Regards
Alex
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Wish list All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index