What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

batch file or vbscript required to get conection info using netstat on perticular ports on windows s

Votes:

0

i was testing batch files using below script

@echo off
del c:\test\d.txt
c:\PsExec.exe \\server -u domain\username -p password netstat -n |find /c "IP/PORT" > c:\test\d.txt
for /F %%i in (c:\test\d.txt) do set myRESULT=%%i
echo RESULT IS  %myRESULT%
if %myRESULT%==0 (echo ":Server is Not Connected") 
REM Set PRTG Sensor to Warning by returning <1>
Exit 1
else (echo ":Server is Connected")

if i run script normally i get proper output in txt file.

but if i use this batch scripts using PRTG EXE/Script sensor the output in txt file changed to 0 (output should be 1 or higher if server is connected)

need help...

netstat prtg psexec

Created on Aug 4, 2017 8:33:25 AM

Last change on Aug 4, 2017 11:10:56 AM by  Erhard Mikulik [Paessler Support]



4 Replies

Accepted Answer

Votes:

0

Hello there,

Please try this:

  • In the device you added sensor to, try setting admin credentials in the device's "Settings" (section "Windows Credentials").
  • In the EXE/Script sensor's settings configure it to "Use Windows credentials of parent device".

Does it work then?

Kind regards,

Erhard

Created on Aug 4, 2017 11:39:35 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Hi Erhard Thanks for your help..

now its showing as

Response not wellformed: "(Connecting to server... Starting PSEXESVC service on server... Connecting with PsExec service on server... Starting netstat on server... netstat exited on server with error code 0. )" (code: PE132)

@echo off
del c:\test\d.txt
c:\PsExec.exe \\server -u username -p password netstat -n |find /c "IP" > c:\test\d.txt
for /F %%i in (c:\test\d.txt) do set myRESULT=%%i

if %myRESULT%==0 echo %myRESULT%:Server is Not Connected 

REM Set PRTG Sensor to Warning by returning <1>
Exit 1

else echo %myRESULT%:Server FIX Connected

thanks in advance.

Created on Aug 4, 2017 5:02:40 PM

Last change on Aug 7, 2017 7:26:49 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

its sorted now after re-framing my batch file thanks for your help Erhard.

@echo off del c:\test\d.txt c:\PsExec.exe
server -u username -p password netstat -n |find /c "IP" > c:\test\d.txt for /F %%i in (c:\test\d.txt) do set myRESULT=%%i

if %myRESULT%==1 echo %myRESULT%:Fidessa FIX is Connected

if %myRESULT%==0 echo %myRESULT%:Fidessa FIX is Not Connected

REM Set PRTG Sensor to Warning by returning <1>
Exit 1

Created on Aug 5, 2017 6:28:05 AM

Last change on Aug 7, 2017 7:27:10 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Good to hear it's working now, you're welcome.

Kind regards,

Erhard

Created on Aug 7, 2017 7:27:31 AM by  Erhard Mikulik [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.