How to set up notifications on DingTalk for PRTG
In order for you to integrate with DingTalk, you can follow the steps below:
1. You can download DingTalk Desktop via https://www.dingtalk.com/en. After downloading, you can log in with your credentials.
2. On the Group, click on Group Settings (top right hand corner) > click on Group Assistant > click on Add Robot > click on
.
.
.
3. There will be a pop-up with the name ChatBot. Click on Add Robot > Select Custom (Custom message services via Webhook).
4. Click on Add.
5. Put in the Group Name you preferred under Add to Group. Please select Security Settings that you preferred. Click on the I have read and accepted. For my example, I have put in the Custom Keyword of PRTG. Click Finished.
6. After that you will obtain the Webhook URL. Please keep this safe. You will require this later.
7. Please do copy the script below (PowerShell script, please save as .ps1) and paste it to C:\Program Files (x86)\PRTG Network Monitor\notifications\exe in your PRTG core server. Please do ensure that your Powershell execution policy has been set properly, you can refer to https://kb.paessler.com/en/topic/71356-guide-for-powershell-based-custom-sensors.
Param(
[string]$DingTalkWebHook,
[string]$SiteName,
[string]$Device,
[string]$Status,
[string]$Down,
[string]$DateTime,
[string]$Message,
[string]$Probe,
[string]$Group,
[string]$SensorID,
[string]$Name
)
$postDingTalkMessage = ConvertTo-Json -Depth 3 ([pscustomobject]@{
actionCard=@{
title = "PRTG";
text = "## $($sitename) `n`n"+
"### Device Details- `n"+
"- Probe- "+"$($Probe) "+
"- Group- "+"$($Group) `n"+
"- Name of Device- "+"$($Device) `n"+
"### Sensor Details- `n"+
"- Name Of Sensor- "+"$($Name) `n"+
"- Status Of Sensor- "+"$($Status)$($Down) `n"+
"- Event Date and Time- "+"$($DateTime) `n"+
"- Sensor Message-`n"+
"> $($Message) `n";
hideAvatar = "0";
}
msgtype = "actionCard";
})
$postDingTalkMessage | Out-File utf8 -FilePath DingTalk.log
$postDingTalkMessage.text | Out-File utf8 -FilePath DingTalk.log -Append
Invoke-RestMethod -Method Post -ContentType 'application/json;charset=utf-8' -Uri $DingTalkWebHook -Body $postDingTalkMessage
8. Login to your PRTG web interface. Go to Setup > Account Settings > Notification Templates.
9. Press the + button to add Notification Template and select Execute Program.
10. For the executable file, select the PowerShell script name which you have saved in Step 7.
11. For parameters, please use the sample parameters below. Please do change the <insert URL here> with the Webhook URL which you have obtained in Step 6. Do fill in the Domain/Computer Name, Username, and password with the Administrative Rights.
-DingTalkWebHook '<insert URL here>' -SiteName '%sitename' -Device '%device' -Status '%status' -Down '%down' -DateTime '%datetime' -Message '%message' -Probe '%probe' -Group '%group' -Uptime '%uptime' -Downtime '%downtime' -Cumsince '%cumsince' -PRTGHome '%home' -SensorID '%sensorid' -DeviceID '%deviceid' -Name '%name'
12. Then set up your Notification Triggers based on your own requirements.
https://www.paessler.com/manuals/prtg/sensor_notifications_settings
Then you are all set.
Example of the notification I obtained from Ding Talk.
.
Add comment