Guest User

Untitled

a guest
Sep 7th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #$output = & "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\check_emc_hw.bat"
  2. $output = & "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\check_emc_hw.bat"
  3. & "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\check_emc_hw.bat"
  4. #$output = check_emc_hw.bat
  5. #write-host $output
  6.  
  7.  
  8. # Path and Filter
  9. #$Path = "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\emc_hw.txt"
  10. #$regex = "FAULT"
  11. #For Testing
  12. $regex = "JWXP"
  13. #Number of disks in the SAN
  14. #$disks_to_check = 45
  15.  
  16. # Result of the filter
  17. Write-Host "OUTPUT"
  18. $output
  19. $fault = foreach ($line in ( $output | select-string -pattern $regex ) ) {
  20. $line.line }
  21.  
  22. $string = ($output | select-string -pattern $regex -AllMatches | %{$_.matches} | %{$_.value})
  23.  
  24. #write-host $string
  25.  
  26. #Number of disks OK and NOK
  27. $result = $string.length
  28.  
  29. #write-host $result
  30.  
  31. # PRTG Sensor condition
  32. if ($result -gt 0) {
  33. write-host "2:Hadware fault on $fault"
  34. exit 2
  35. }
  36.  
  37. else {
  38. write-host "0:Hardware OK Result: $output"
  39. exit 0
  40. }
  41.  
  42. endif
Add Comment
Please, Sign In to add comment