#!/usr/bin/env ruby
# To use in nagios for NSClient++:
# - Put the script into the %SCRIPT% directory
# modifications in NSC.ini:
#
# in [modules]:
# CheckExternalScripts.dll
#
# in [NRPE]:
# allow_arguments=1
# allow_nasty_meta_chars=1
# allowed_hosts=x.x.x.x
#
# in [External Script]:
# allow_arguments=1
# allow_nasty_meta_chars=1
#
# in [Script Wrappings]:
# rb=ruby.exe scripts\%SCRIPT% %ARGS%
#
# in [Wrapped Scripts]:
# 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<10 then
mm="0"+ss.to_s;
end
return mm
end
rootpath=""
#读取参数
if ARGV[0] then
rootpath=ARGV[0];
end
d=Time.now.day
m=Time.now.mon
y=Time.now.year.to_s
fullpath=rootpath+y+"_"+fu(m)+"_"+fu(d)+"/test.txt"
#p fullpath
if File.exist?(fullpath) then
print "Ok,"+fullpath+" File exist!";exit 0;
else
print "Error,"+fullpath+" File no exits!!";exit 2;
end