Why does ps return only one line of output in my Perl script when I call it Nagios?

I have this run:

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 each output line ps -eLf

Now, if the same script is called from Nagios via NRPE , it PS_ELFcontains only one line (the first line is output ps).

It puzzles me; what could be the reason?

Perhaps this is not limited to / caused by Nagios at all, I just included it for completeness.

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

+3
source share
3 answers

, . , , . , , NRPE (), , , - NRPE.

bash script:

#!/bin/bash
echo `env | grep COLUMNS`

COLUMN , , (, NRPE).

script - NRPE

$ /tmp/check_env.sh
COLUMNS=174

. script NRPE, :

nagios-server $ check_nrpe -H client -c check_env
COLUMNS=80

ps -eaf 80 , ww , COLUMNS.

+2

"ps -eLf" "ps -eLfww" (ww ), , , .

+2

This is most likely due to the way NRPE plugins work than Perl itself.

Does your plugin work as described here (return code + output)?

+1
source

Source: https://habr.com/ru/post/1702718/


All Articles