I'm trying to make a custom sensor for PSPING, a TCP ping tool :(https://technet.microsoft.com/en-us/sysinternals/jj729731.aspx)
the output from the commandline is "noisy" so, I created a batch file to try an just get the one value I want
FOR /f "tokens=9" %%G IN ('psping -q google.com:443 ^|find "Average"') do echo %%G
This still gives this output: PsPing v2.01 - PsPing - ping, latency, bandwidth measurement utility Copyright (C) 2012-2014 Mark Russinovich Sysinternals - www.sysinternals.com
100% C:\temp>echo 4.79ms 4.79ms
If I add this as a custom sensor, I get the error : Response not well formed (then the batch file contents)
I'd appreciate any pointers on how to get this working.
C:\temp>
Article Comments
Here is a small (vb.net) code snippet for the PsPing wrapper program
Sub Main()
Dim p As New Process
'// process details
With (p.StartInfo)
.UseShellExecute = False
.RedirectStandardOutput = True
.FileName = "c:\temp\psping.exe"
.Arguments = "-q google.com:443"
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
'// start the PsPing process and catch the output
p.Start()
Dim output() As String = p.StandardOutput.ReadToEnd.Split(Convert.ToChar(10))
p.WaitForExit()
'// loop through the result finding the 'Average' value
For Each line As String In output
Dim parts() As String = line.Split(","c)
For Each part As String In parts
If part.Contains("Average") Then
'// return the found 'Average' value to PRTG
Console.WriteLine(part.Split("="c)(1).Replace("ms", "").Trim & ":Ok")
Environment.Exit(0)
End If
Next
Next
'// 'Average' value not found return an error
Console.WriteLine("0:Could not find Average part")
Environment.Exit(2)
End Sub
Mar, 2015 - Permalink
Hello,
Tried your vb snippet but always get this error, when i try to run it:
Microsoft VBScript compilation error: Expected end of statement )" (code: PE132)
Mar, 2018 - Permalink
As you already mentioned, the PsPing utility writes its copyright message to the console. As a result of this, the copyright message is also part of the 'sensor output' and PRTG raises the error 'Response not well formed'
How can this be fixed?
You can write a separate program that will function as a wrapper for PsPing. This wrapper will need to execute PsPing in a shell and redirect the output to a memory stream.
After reading the data from the stream, the wrapper will need to write the well formatted message to the console, to be picked up by PRTG.
Mar, 2015 - Permalink