Created
August 30, 2018 17:22
-
-
Save tareqy/7ff62746fadb0ded7a1058453209c77f to your computer and use it in GitHub Desktop.
PRTG PHP-FPM Sensor
This file contains 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 characters
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> | |
"@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment