forked from WCOMAB/PRTGSlackNotification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPRTGSlackNotification.ps1
More file actions
66 lines (64 loc) · 2.09 KB
/
PRTGSlackNotification.ps1
File metadata and controls
66 lines (64 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# ----------------------------------------------------------------------------------------------
# Copyright (c) WCOM AB 2015.
# ----------------------------------------------------------------------------------------------
# This source code is subject to terms and conditions of the The MIT License (MIT)
# copy of the license can be found in the LICENSE file at the root of this distribution.
# ----------------------------------------------------------------------------------------------
# You must not remove this notice, or any other, from this software.
# ----------------------------------------------------------------------------------------------
Param(
[string]$SlackToken,
[string]$SlackChannel,
[string]$SiteName,
[string]$Device,
[string]$Name,
[string]$Status,
[string]$Down,
[string]$DateTime,
[string]$LinkDevice,
[string]$Message,
[string]$ColorofState,
[string]$LinkSensor,
[string]$LastCheck,
[string]$StateSince,
[string]$LastMessage
)
$attachments = ConvertTo-Json -Depth 4 @(@{
fallback = "New notification for $($Device) - $($Name) is $($Status) $($Down). $($LinkDevice)"
title = "${Name}: Status $($Status) $($Down)"
title_link = $LinkSensor
color = $ColorofState
text = $Message
fields = @( @{
title = "Date"
value = $DateTime
short = 1
}
@{
title = "Letzte Ueberpruefung"
value = $LastCheck
short = 1
}
@{
title = "Status seid"
value = $StateSince
short = 1
}
@{
title = "Letzte Meldung"
value = $LastMessage
short = 1
}
)
})
$postSlackMessage = @{
token = $SlackToken
channel = $SlackChannel
unfurl_links = "true"
username = $sitename
text = "*New notification* for <$($LinkDevice)|$($Device)>"
attachments = $attachments
}
$postSlackMessage | Out-File -FilePath slack.log
$postSlackMessage.text | Out-File -FilePath slack.log -Append
Invoke-RestMethod -Uri https://slack.com/api/chat.postMessage -Body $postSlackMessage | Out-File -FilePath slack.log -Append