Function Send-Chat{
Param(
[string] $Msg
)
Add-Type -AssemblyName System.Web
$url = "http://your ip:port/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%22el3fotmx3xHbiXGz17aTTXFUJ5DTzgun6bwhLA5bfqso%22"
$json = 'payload={{"text": "{0}"}}' -f [System.Web.HttpUtility]::UrlEncode($Msg)
Try{
$Response = Invoke-WebRequest -Uri $url -Method POST -Body $json
}Catch [exception]{
$_
}
}
Send-Chat ("{0:yyyy-MM-dd HH:mm:ss} DB Server CPU Loading {1:f0}%, Memory Loading {2:f0}%" -f (Get-Date), $CPUSensor, $MemSensor)
0 意見:
張貼留言