View previous topic :: View next topic |
Author |
Message |
Malice
Joined: 19 Jan 2016 Posts: 1
|
Posted: Tue Jan 19, 2016 8:14 am Post subject: Additional Alert options |
|
|
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 |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed Jan 20, 2016 5:32 pm Post subject: |
|
|
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 |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12805 Location: USA
|
Posted: Thu Jan 21, 2016 6:19 am Post subject: |
|
|
PS I think we will add new action in future versions
Regards
Alex |
|
Back to top |
|
|
eddymicro
Joined: 13 Nov 2002 Posts: 95
|
Posted: Wed Nov 28, 2018 6:48 am Post subject: |
|
|
Alex,
We are going to post some alerts to Slack, is this still the recommended way to do that? |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12805 Location: USA
|
|
Back to top |
|
|
|