Domanda

I've a problem with result of a *.cfg file, containing $prescript parameter, running by check_logfiles.exe. My platform is MS Windows Server 2008 R2 64 bit. I have to check in a dir, if there are *.err files. For do this job, i've write this powershell script:

$mypath="W:\nrpe\tmp\"
$logfile = $args
$logfile = Foreach-Object {$logfile -replace '\\', '_' -replace "__", "" -replace ":", ""}
$result = ls $args -Filter *.err|Measure-Object -Line | select -expand lines
echo "$result file/s present with .*err string"| out-file -filepath $mypath$logfile'.log' -append -encoding unicode
exit 0

I've chose to elaborate $logfile parameter, because i have to check more paths, and i want to use the same script.

This is the cfg file:

$scriptpath = 'C:\Windows\System32\WindowsPowerShell\v1.0';
$seekfilesdir = 'C:\nrpe\tmp';

$prescript = 'powershell.exe';
$prescriptparams = '-File C:\nrpe\libexec\check_err_file.ps1 \\\networkpath\FTP_Data\ExtraUE\Input';
$options = 'supersmartprescript';

$log='W:\nrpe\tmp\networkpath_FTP_Data_ExtraUE_Input';
  @searches = (
  {
    tag => 'check_logfiles_test',
    type => 'simple',
    logfile => $log,
    criticalpatterns => ['.*'],
    criticalexceptions => ['0 file'],
    options => 'count,noprotocol,noperfdata',
  }
  );

The $log file it's empity if i run checklogfiles:

C:\nrpe\libexec\check_logfiles -f C:\nrpe\cfg\check_logfiles_test.cfg

But if i Run powershell manually, it works correctly:

PS C:> C:\nrpe\libexec\check_err_file.ps1 \networkpath\FTP_Data\ExtraUE\Input

Content of W:\nrpe\tmp\networkpath_FTP_Data_ExtraUE_Input:

1 file/s present with .*err string

this is trace log:

Fri Feb  7 16:55:08 2014: call (smart) prescript powershell.exe
Fri Feb  7 16:55:08 2014: found script in C:\Windows\System32\WindowsPowerShell\v1.0/powershell.exe
Fri Feb  7 16:55:08 2014: execute C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\nrpe\libexec\check_err_file.ps1 \\networkpath\FTP_Data\ExtraUE\Input
Fri Feb  7 16:57:50 2014: script said: 
Fri Feb  7 16:57:50 2014: script powershell.exe exits with code 1
Fri Feb  7 16:57:50 2014: failed supersmart prescript. aborting...

ON Nagios this istance is in " CRITICAL : (Service Check Timed Out) "

Do you know what could be the problem?

È stato utile?

Soluzione

Option to control how much time Nagios will allow various types of commands to execute before killing them off. Option is available for controlling maximum time allotted for service checks. All values are in seconds.

/etc/nagios/nagios.cfg

service_check_timeout=180

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top