Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- #requires -version 4.1
- # ___ ___ _____ ___
- #| _ \ _ \_ _/ __|
- #| _/ / | || (_ |
- #|_| |_|_\ |_| \___|
- # FALSE POSITIVE CHECKER
- # ================================
- #>
- param( [int]$id = 0, # UNIQE Sensor Identifyer
- [string]$message = "",# Last Error Message
- [string]$match = "",# "PE015" ==> Timeout Error on Sensor
- [int]$triggers = 10,# MAX Counter for repeats on Sensor refreshes
- [int]$wait = 10)# Time delay between repeats in seconds
- $PRTG_PROT = ""
- $PRTG_HOST = ""
- $PRTG_PORT = 0
- $PRTG_USER = ""
- $PRTG_PASS = 0
- $LOGFILE = "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)\$($id)-notifications.log"
- $url = ([string]::Format("{0}://{1}:{2}/api/scannow.htm?id={3}&username={4}&passhash={5}",
- $PRTG_PROT,$PRTG_HOST,$PRTG_PORT,$id,$PRTG_USER,$PRTG_PASS));
- $i = 0;
- # this will output debug messages to the LogFile
- function Console-ShowMessage([string]$type,$message1){
- $date = (Get-Date).ToString()
- $log = ([string]::Format("[{0}] [{1}] - {2}",$date,$type,$message1));
- $log | Out-File $LOGFILE -Append
- }
- if($message -match $match){ #Sensor ran into Timout
- Console-ShowMessage -type "warning" -message1 "Sensor is probably in a false positive state - force checking..."
- try{
- while($i -lt $triggers){ #for($i =< $triggers){
- Console-ShowMessage -type "info" -message1 "Iterate $i"
- Start-Sleep -Seconds $wait
- Invoke-WebRequest $url | Out-Null
- $i++;
- }
- Console-ShowMessage -type "success" -message1 "Sensor has been triggered a few times and should be UP now."
- }
- catch [Exception]{
- Console-ShowMessage -type "error" -message1 "Could not trigger the sensor check. Notes below:"
- Console-ShowMessage -type "notes" -message1 $_.Exception.Message
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement