Created
August 30, 2018 17:22
-
-
Save tareqy/7ff62746fadb0ded7a1058453209c77f to your computer and use it in GitHub Desktop.
Revisions
-
tareqy created this gist
Aug 30, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ param( [string]$url ); $status_page = Invoke-WebRequest -uri $url -UseBasicParsing $statistics = ,@("value","name") # listen queue $status_page.RawContent -match '(listen queue:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"listen queue") # max listen queue $status_page.RawContent -match '(max listen queue:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"max listen queue") # listen queue len $status_page.RawContent -match '(listen queue len:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"listen queue") # idle processes $status_page.RawContent -match '(idle processes:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"idle processes") # active processes $status_page.RawContent -match '(active processes:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"active processes") # total processes $status_page.RawContent -match '(total processes: \s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"total processes") # max active processes $status_page.RawContent -match '(max active processes:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"max active processes") # max children reached $status_page.RawContent -match '(max children reached:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"max children reached") # slow requests $status_page.RawContent -match '(slow requests:\s+)(\d+)' | Out-Null $statistics += ,@($matches[2],"slow requests") Write-Host @" <PRTG> "@ for ($i=1; $i -lt $statistics.Count; $i++){ Write-Host @" <result> <channel>$($statistics[$i][1])</channel> <value>$($statistics[$i][0])</value> <Float>0</Float> <unit>Count</unit> "@ if($statistics[$i][1] -eq "listen queue" -or $statistics[$i][1] -eq "listen queue len"){ Write-Host @" <LimitMode>200</LimitMode> <LimitMaxError>200</LimitMaxError> "@ } Write-Host @" </result> "@ } Write-Host @" </PRTG> "@