xuyangus 发表于 2019-1-15 13:19:46

使用Ruby编写nagios监控脚本监控Windows主机

  以下通过一个自己写的实例来说明:
  监控目的是判断指定的文件是否存,如不存在就报警,而传入的参数是指定文件的根路径,也可以改成全路径,例子只是为了说明ruby脚本在nagios中的部署方法,而并不是为了说明使用ruby来判断文件是否存在有多便利。
  #!/usr/bin/env ruby
# To use in nagios for NSClient++:
#   - Put the script into the %SCRIPT% directory
# modifications in NSC.ini:
# =========================
#
# in :
# CheckExternalScripts.dll
#
# in :
# allow_arguments=1
# allow_nasty_meta_chars=1
# allowed_hosts=x.x.x.x
#
# in :
# allow_arguments=1
# allow_nasty_meta_chars=1
#
# in :
# rb=ruby.exe scripts\%SCRIPT% %ARGS%
#
# in :
# check_sftpDayfile=check_sftpDayfile.rb $ARG1$
#
#
# nagios usage:
# =============
#
# define service{
#      use                     generic-service
#      host_name               windowsxx
#      service_description   SFtp Dayfile
#      check_command         check_nrpe!check_sftpDayfile!"d:/path"
# }
def fu(ss)
mm=ss.to_s
if ss
页: [1]
查看完整版本: 使用Ruby编写nagios监控脚本监控Windows主机