I need to verify that some TCP/UDP ports are open. As a source I have a client and as a destination I have another one. The sensor used is Custom EXE/Script Sensor. The EXE file to connect to the source client is PsExec of Windows Sysinternals and the port scanner (copied to the client) is PortQry from Microsoft download center. Setting of the sensor:
EXE/Script: PsExec.exe
Parameters:
\\x.x.x.x -nobanner cmd /c "C:\Temp\PortQry.exe -n x.x.x.x -e portxxxx -nr -q"
the result is always:
Response not well-formed: "( ¦S
launched by console the result is (Ok):
cmd exited on x.x.x.x with error code 0.
launched by console the result is (Fail):
cmd exited on x.x.x.x with error code 1.
How can I read it in the sensor correctly?
Thanks
Article Comments
Hi there,
Please activate the "Write EXE result to disk" option in the sensor's settings and post the log files (Result of Sensor XXX.Data.txt and Result of Sensor XXX.txt) located on the corresponding probe under "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)".
Best regards.
Apr, 2018 - Permalink
Hi Andrea,
I had similar issue on a VB script. The reason is the syntax expected to be returned by the script sensor.
The return value should be like "<value> : <message>".
I had a short test without teh PSExec and could handle it like this:
"PortQry.exe -n <machineIPName> -e <port> -nr -q && ECHO 1 : Portscan succeeded || ECHO 0 : Portscan failed"
(Attention: you need first the succeeded ECHO case to be bound with "&&" and then the error case with "||")
In this case you get a 0 for success and -1 in case of a failure.
To use inline here directly the %errorlevel% variable is not working as it is not updated yet durign the execution. It always outline the former value. (Would need to execute it twice ;-) )
Alternative you just put your command in a script and then add a command line like this:
ECHO %errorlevel% : <any text> |
With a prior condition you can also add a case dependant message text.
I hope this helps to come to your final solution.
Regards,
jo
Apr, 2018 - Permalink
Are you able to use the PORT sensor? of course if you want to do this on a remote machine you need to install a probe.
If you want to do this on 100 machines then you might have an issue with probes, and doing as you are now might be a valid way.
Apr, 2018 - Permalink
Hi, AndrewG, The machines I have to test are segregated by a firewall, so I have to run the test not from the probe but from the device itself to another.
Jun, 2018 - Permalink
I don't have much experience with script sensors, but can't you just set limits on the "value" channel of the script ? As it checks the return value of the script, set the upper and lower limit to 0 so that non-zero value returns an error ?
Apr, 2018 - Permalink