Nagios Prescript不起作用

时间:2014-02-05 12:00:28

标签: windows powershell nagios

我的问题是* .cfg文件的结果,包含$ prescript参数,由check_logfiles.exe运行。 我的平台是MS Windows Server 2008 R2 64位。 如果有* .err文件,我必须检查目录。为了完成这项工作,我写了这个powershell脚本:

$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

我选择详细说明$ logfile参数,因为我必须检查更多路径,并且我想使用相同的脚本。

这是cfg文件:

$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',
  }
  );

$ log文件,如果我运行checklogfiles,它是真实的:

  

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

但如果我手动运行powershell,它可以正常工作:

  

PS C:> C:\ NRPE \ libexec目录\ check_err_file.ps1   \ networkpath \ FTP_Data \ ExtraUE \输入

内容W:\ nrpe \ tmp \ networkpath_FTP_Data_ExtraUE_Input:

  

带有。*错误字符串

的1个文件

这是跟踪日志:

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...

在Nagios上,这个因素是“关键:(服务检查超时)”

你知道可能是什么问题吗?

1 个答案:

答案 0 :(得分:0)

选项可以控制Nagios在杀死它们之前允许执行各种类型命令的时间。 选项可用于控制分配给服务检查的最长时间。所有值都以秒为单位。

<强> /etc/nagios/nagios.cfg

service_check_timeout = 180