freebsd-ports/net-mgmt/nagios-check_kumofs/files/check_kumosvr.in

52 lines
1.2 KiB
Ruby

#!/usr/bin/env ruby
#
# Copyright (C) Etolabo Corp. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# search kumostat and load
[
"/usr/local/bin",
File.dirname(__FILE__),
].map {|x| x+"/kumostat"}.each do |ks|
if File::file?(ks)
load ks
break
end
end
NUMBER_OF_LOWEST_ITEMS = 500
def usage
puts "Usage: #{File.basename($0)} address[:port=#{KumoRPC::SERVER_DEFAULT_PORT}]"
exit 1
end
if ARGV.length != 1
usage
end
addr = ARGV.shift
host, port = addr.split(':', 2)
port ||= KumoRPC::SERVER_DEFAULT_PORT
cmd = ARGV.shift
n = KumoServer.new(host, port).GetStatus(KumoServer::STAT_DB_ITEMS)
puts "items: #{n}"
if n < NUMBER_OF_LOWEST_ITEMS
exit 1
else
exit 0
end