Hi there,
Could you try the following script? Just change the URL parameter on top:
param(
$url = "http://myserver/php_fm.txt"
)
$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>1</LimitMode>
<LimitMaxError>1</LimitMaxError>
"@
}
Write-Host @"
</result>
"@
}
Write-Host @"
</PRTG>
"@
You can add this script in PRTG via the EXE/Script Advanced Sensor and by entering "-url "http://myserver/php"" into the "Parameters"-field.
Best regards.
Add comment