This PRTG slack notification script was originally posted by myself here: https://kb.paessler.com/en/topic/66113-how-can-prtg-send-notifications-to-slack#reply-249147
This is our version of the script originally provided with PRTG by Paessler. – we are using the #colorstatus as well to determine to current issue and we are using actually icons to show the status – this is working pretty well for us. Besides that, reformatted the whole notification a bit so it is easier to read in the prtg slack notification messages.
It is easy to adjust and even use additional statuses/color-codes if needed..
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 67 68 69 70 71 72 73 74 75 76 77 78 | # ---------------------------------------------------------------------------------------------- # Copyright (c) WCOM AB 2016. # ---------------------------------------------------------------------------------------------- # 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]$SlackWebHook, [string]$SlackChannel, [string]$SiteName, [string]$Device, [string]$Name, [string]$Status, [string]$Down, [string]$DateTime, [string]$LinkDevice, [string]$Message, [string]$Color ) string $StatusIcon string $SlackTextFormatting Switch ($Color) { '#b4cc38' { #UP $StatusIcon = ':white_check_mark:' $SlackTextFormatting = '*' } '#d71920' { #DOWN $StatusIcon = ':name_badge:' $SlackTextFormatting = '`' } '#ffcb05' { #WARNING $StatusIcon = ':radioactive_sign:' $SlackTextFormatting = '`' } '#447fc1' { #PAUSE $StatusIcon = ':double_vertical_bar:' $SlackTextFormatting = '~' } default { $StatusIcon = ':interrobang:' } } Add-Type -AssemblyName System.Web.Extensions function ConvertTo-Json ([Object] $value) { [System.Web.Script.Serialization.JavaScriptSerializer] $jsSerializer = New-Object 'System.Web.Script.Serialization.JavaScriptSerializer' $jsSerializer.Serialize($value) } $postSlackMessage = ConvertTo-Json(@{ channel = $SlackChannel; unfurl_links = "true"; username = "PRTG"; icon_url = "https://www.paessler.com/common/files/banner/banner_3s_80x80.png" text = "$($StatusIcon) <$($LinkDevice)|$($Device) $SlackTextFormatting$($Name)$SlackTextFormatting> >Status *$($Status) $($Down)* on $($DateTime) ``````$($Message)``````"; }) $postSlackMessage | Out-File -FilePath slack.log [System.Net.WebClient] $webclient = New-Object 'System.Net.WebClient' $webclient.UploadData($SlackWebHook, [System.Text.Encoding]::UTF8.GetBytes($postSlackMessag |