Hi, I have a problem with notification/alert settings. l have a group that contains different groups/devices. I need to send a notification when number of alarms is bigger than (for example) 10. I don't care about single device down, I need to be notified when a number of sensor greater than "x" is down.
Is it possible with PRTG? Thanks Paolo
Article Comments
Thanks @Florian, I found the API call, is there some EXE/Script sensor already tested (where I can use my string) without write it down by myself?
thanks
Regards
Jan, 2022 - Permalink
Hello Paolo,
You can use the following template to execute the API call and return the value in PRTG. However, please note that we don't provide support for it.
param( [string] $hostname = "", # PRTG IP/DNS [string] $username = "", # PRTG Account [string] $passhash = "", # Account passhash [string] $groupid = "" # Group ID for the API call ) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12 function Skip-SSLCertificates{ $Provider = New-Object Microsoft.CSharp.CSharpCodeProvider $Compiler = $Provider.CreateCompiler() $Params = New-Object System.CodeDom.Compiler.CompilerParameters $Params.GenerateExecutable = $false $Params.GenerateInMemory = $true $Params.IncludeDebugInformation = $false $Params.ReferencedAssemblies.Add("System.DLL") > $null $TASource=@' namespace Local.ToolkitExtensions.Net.CertificatePolicy { public class TrustAll : System.Net.ICertificatePolicy { public bool CheckValidationResult(System.Net.ServicePoint sp,System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Net.WebRequest req, int problem) { return true; } } } '@ $TAResults=$Provider.CompileAssemblyFromSource($Params,$TASource) $TAAssembly=$TAResults.CompiledAssembly ## We create an instance of TrustAll and attach it to the ServicePointManager $TrustAll = $TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll") [System.Net.ServicePointManager]::CertificatePolicy = $TrustAll } function Invoke-Request { Param( $baseurl = $script:hostname, $user = $script:username, $passh = $script:passhash, $groupid = $script:groupid ) $url = "https://$baseurl/api/table.json?content=sensors&output=json&columns=objid,sensor,status&id=$groupid&username=$user&passhash=$passh" Invoke-RestMethod $url -Method Get } try { Skip-SSLCertificates # Get number of sensors with Down state $count = ((Invoke-Request).sensors | where {$_.status_raw -eq "5"}).count Write-Output "$($count):Message" Exit 0 } catch { Write-Output "0:$($_.exception.message) At line : $($_.InvocationInfo.ScriptLineNumber)" Exit 1 }
Regards.
Jan, 2022 - Permalink
Hello Paolo,
Thank you for your message.
Regarding what you would like to achieve, you need to use a custom script with the EXE/Script sensor which will get the number of down sensors from that group. Then, you can configure the threshold trigger to this sensor.
To get that information, you can use the following API call to get a list of the sensors which belong to that group and then count the ones in down state:
Note that the script must return the data in a specific format depending on the custom sensor used, which is described here: https://www.paessler.com/manuals/prtg/custom_sensors
If you have questions, do not hesitate.
Regards.
Dec, 2021 - Permalink