New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Perl pipe in custom XML sensor always fails in PRTG.

Votes:

0

Your Vote:

Up

Down

I have a custom XML exe/script sensor set up, the .exe is perl.exe and I pass the script name as the parameter.

If I run the script from the cmd prompt, it works great, but as soon as I run it from within PRTG as a custom sensor, it simply reports "no data". If I replace the pipe with static data it works fine, so I suspect there's some subtle point I'm missing about opening this pipe when PRTG runs the script vs when I run it at the cmd line. What that difference is however I'm at a loss...

Here's the line in question:

open (READ_PIPE, "ssh -q -l Administrator -i \"C:\\Documents and Settings\\Administrator\\.ssh\\id_rsa\" tstevens-fp4b \"show interface e1/1 | xml | no-more\" |") or die $!;

This opens an ssh to the device using a preshared key, executes a command, and that's piped to a filehandle I read to gather some stats.

As mentioned, this works flawlessly from the cmd prompt but when I point to the same script in PRTG I get nothing!! It's driving me crazy I've tried about 1000 variations of the above trying to get this working with no luck.

Any clues appreciated, thanks, Tim

custom-sensor exe-script perl xml

Created on Feb 16, 2011 5:55:52 PM by  Tim Stevenson (50) 1 1

Last change on Feb 21, 2011 10:58:52 AM by  Daniel Zobel [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Well just to follow up - I finally resolved this, by installing the full cygwin package on this windows 2003 server and using the ssh.exe from there rather than openssh for windows. I guess cygwin is a bit more 'isolated' from the windows permissions madness and it works fantastic now. :)

Just wish I hadn't wasted so many hours messing with this.

Tim

Created on Feb 18, 2011 11:00:02 PM by  Tim Stevenson (50) 1 1



5 Replies

Votes:

0

Your Vote:

Up

Down

Dear Tim,

just to check, are you sure that the PRTG Probe service (usually running under the "LOCAL SYSTEM" user account) is able to access the

"C:\\Documents and Settings\\Administrator\\"

folder?

Best Regards

Created on Feb 16, 2011 6:08:31 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi, thanks for the response. I did consider this might be a permissions problem, I did already try changing the security context to "use windows credentials of parent device" and populating the credentials at the root to those of the Administrator account, but that doesn't seem to change anything.

Is there some sort of debugging I can turn on or something to see what the script is doing or trying to do? I have tried the "write exe result" option but it does not produce any file/output when this pipe option is included in the script!

I'm sure I could get to the bottom of it if there was some sort of console or something where I could see what error etc is being thrown with this line in there.

Thanks for any help,

Tim

Created on Feb 16, 2011 6:49:33 PM by  Tim Stevenson (50) 1 1



Votes:

0

Your Vote:

Up

Down

A bit more information: I moved the private & public key files into the EXEXML directory & pointed to that instead, like so: open (READ_PIPE, "ssh -q -l Administrator -i \"C:
Program Files
PRTG Network Monitor
Custom Sensors
EXEXML
id_rsa\" tstevens-fp4b \"show interface e1/1 | xml | no-more\" |") or die $!;

That does seem to change *something*, I now get this line in the "last message" for the sensor: The operation completed successfully. (0x0)

Web search seems to suggest this is some error around authentication, not sure exactly what. So I'm thinking the PSK is not working right when PRTG executes this ssh vs me as admin at the cmd prompt....

Tim

Created on Feb 16, 2011 7:12:18 PM by  Tim Stevenson (50) 1 1



Votes:

0

Your Vote:

Up

Down

Ok - I have narrowed this down, it's the pipe from ssh that hangs up. If I immediately kill the ssh process that PRTG runs using task mgr right after it starts, then the perl script continues and I see the channels populated (with 0 values of course).

So to narrow the question down - does anyone know how to successfully run an ssh session using a preshared key when spawned from PRTG? I have tried it from a perl script, a batch file, a powershell script, I've tried each using both security context options - they all fail. All work when I open them from the cmd prompt.

At a loss.... :( Tim

Created on Feb 17, 2011 5:07:58 PM by  Tim Stevenson (50) 1 1



Accepted Answer

Votes:

0

Your Vote:

Up

Down

Well just to follow up - I finally resolved this, by installing the full cygwin package on this windows 2003 server and using the ssh.exe from there rather than openssh for windows. I guess cygwin is a bit more 'isolated' from the windows permissions madness and it works fantastic now. :)

Just wish I hadn't wasted so many hours messing with this.

Tim

Created on Feb 18, 2011 11:00:02 PM by  Tim Stevenson (50) 1 1



Please log in or register to enter your reply.


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.