Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- #requires -version 4.0
- # ___ ___ _____ ___
- #| _ \ _ \_ _/ __|
- #| _/ / | || (_ |
- #|_| |_|_\ |_| \___|
- # FALSE POSITIVE CHECKER
- # ================================
- #>
- param( [int]$id = 0,
- [string]$message = "",
- [string]$match = "",
- [int]$triggers = 10,
- [int]$wait = 10)
- $prtgprot = ""
- $prtghost = ""
- $prtgport = 80
- $prtguser = ""
- $prtgpass = 0
- $logfile = "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)\$($id)-notifications.log"
- # this will output debug messages to the console
- function Console-ShowMessage([string]$type,$message){
- $date = (Get-Date).ToString()
- $log = ([string]::Format("[{0}] [{1}] - {2}",$date,$type,$message));
- $log | Out-File $logfile -Append
- }
- $url = ([string]::Format("{0}://{1}:{2}/api/scannow.htm?id={3}&username={4}&passhash={5}",
- $prtgprot,$prtghost,$prtgport,$id,$prtguser,$prtgpass));
- $i = 0;
- if($message -match $match){
- Console-ShowMessage -type "warning" -message "Sensor is probably in a false positive state - force checking..."
- try{
- while($i -lt $triggers)
- {
- Start-Sleep -Seconds $wait
- Invoke-WebRequest $url | Out-Null
- $i++;
- }
- Console-ShowMessage -type "success" -message "Sensor has been triggered a few times and should be UP now."
- }
- catch [Exception]{
- Console-ShowMessage -type "error" -message "Could not trigger the sensor check. Notes below:"
- Console-ShowMessage -type "notes" -message $_.Exception.Message
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement