views:

480

answers:

2

I have this running:

if (open(PS_ELF, "/bin/ps -eLf|")) {
  while (<PS_ELF>) {
    if ($_ =~ m/some regex/) {
      # do some stuff
    }
  }
}

If called locally, the loop runs just fine, once for every output line of ps -eLf

Now if the same script is called from Nagios via NRPE, PS_ELF does only contain one line (the first line output by ps).

This puzzles me; what could be the reason?

Maybe this is not limited to/caused by Nagios at all, I just included it for the sake of completeness.

I'm on SUSE Enterprise Linux 10 SP2 and perl v5.8.8.

+1  A: 

It's probably more something to do with how NRPE plugins work than Perl itself.

Your plugin is working like explained here (return code + output) ?

sebthebert
Yes, output and return code are set as documented. :-/I've uploaded the complete script, may this helps to understand my problem: http://home.arcor.de/reik/check_threads
Node
+2  A: 

I changed 'ps -eLf' to 'ps -eLfww' (ww for unlimited output) and this fixed the problem even if I don't understand why there is a difference when called remotely.

Node