-2

I am running a perl script from Nagios to check some files for certain characteristics on a windows machine. When I run the script from Nagios it responds with a result of:

UNKNOWN ERROR - execution of LANG=C ls -l resulted in an error 32512 -

My Code is from this GitHub with a single modification of line 168 so I can use it with windows:

use lib 'C$\Progra~1\Nagios\NRDS_Win\plugins';

The odd thing is the program actually outputs the expected result from the command line on the windows machine.

Here is the command:

check_files.pl -D c:\logs -F Health.log -a '~,300'

Here is an example:

CRITICAL - Health.log is 10703 (more than 300) seconds old - 1 Health.log files found

I modified line that defined LANG=C ls -l in the code but now i just get:

UNKNOWN ERROR - could not execute ls -l - No such file or directory

mithrix
  • 542
  • 1
  • 4
  • 21

1 Answers1

2

ls is unix command and by default there is no such command in windows.

If you need it, you can install it e.g. from GNU CoreUtils

You also need to change shell command on line 639 from LANG=C ls -l to just ls -l because in windows you can't set environment variables like that.

Markus Laire
  • 2,837
  • 2
  • 17
  • 23
  • 6
    Even if they did, `LANG=C ls -l` would still be an invalid Windows command – ikegami Jul 27 '16 at 17:35
  • 'ls' is on the windows box and I did change the LANG=C line to just be ls -l but I still get an: UNKNOWN ERROR - could not execute ls -l - No such file or directory in nagios but if I run the same command from the command prompt it works fine – mithrix Jul 27 '16 at 19:55
  • 1
    You should check that `ls` is on the path from within whatever environment Nagios is running in. It may be different than the command line path. – Bill Ruppert Jul 28 '16 at 02:08