HI i am trying to create a custom alert that fires an alert to out slack account
Â
I have created a .bat file as aware we can not call a .vbs directly from the up.time alert script.
Â
“C:/Program Files/uptime software/uptime/scripts/Slackcall.bat”
Â
the .bat files simply calls the .vbs byÂ
Â
cscript //nologo “c:Program Filesuptime softwareuptimescriptsSlackNotification.vbs”
Â
then the .vbs contains the below
Â
Dim WshShell, objEnv
Â
Set WshShell = CreateObject(“WScript.Shell”)
Set objEnv = WshShell.Environment(“Process”)
Â
UPTIME_ALERTTYPE = objEnv(“UPTIME_ALERTTYPE”)
UPTIME_HOSTNAME = objEnv(“UPTIME_HOSTNAME”)
UPTIME_HOSTSTATUS = objEnv(“UPTIME_HOSTSTATUS”)
UPTIME_MESSAGE = objEnv(“UPTIME_MESSAGE”)
Â
sUrl = “https://hooks.slack.com/services/ourslackkey“
Â
sRequest = “{“”text””: “”” + UPTIME_ALERTTYPE + ” occurred on ” + UPTIME_HOSTNAME + ” of type ” + UPTIME_HOSTSTATUS + ” with the following message: ” + UPTIME_MESSAGE + “””}”
Â
HTTPPost sUrl, sRequest
Â
Function HTTPPost(sUrl, sRequest)
 set oHTTP = CreateObject(“Microsoft.XMLHTTP”)
 oHTTP.open “POST”, sUrl, false
 oHTTP.setRequestHeader “Content-Type”, “application/json”
 oHTTP.setRequestHeader “Content-Length”, Len(sRequest)
 oHTTP.send sRequest
 HTTPPost = oHTTP.responseText
End Function
Â
I have tested the bat calling the .vbs manually and it triggers and sends the alert. However when this is tested in up.time i can see the bat file called in task manager and see the .vbs also called but this never successfully sends out the http request.
Â
Any help would be appreciated.