Sha256: a60f930b80caa3ada778cffd3673124a6095a18759d2e4ed8b01dc80c499baef
Contents?: true
Size: 773 Bytes
Versions: 16
Compression:
Stored size: 773 Bytes
Contents
#!/usr/bin/env ruby RUBIX_ROOT = File.expand_path('../../../../lib', __FILE__) $: << RUBIX_ROOT unless $:.include?(RUBIX_ROOT) require 'rubix' require 'net/http' require 'timeout' class HttpAvailabilityMonitor < Rubix::Monitor include Rubix::ZabbixMonitor def host_group_name 'Zabbix servers' end def measure hosts.each do |host| measure_host(host) end end def measure_host host begin timeout(1) do if Net::HTTP.get_response(URI.parse("http://#{host.ip}/")).code.to_i == 200 write [host.name, 'webserver.available', 1] return end end rescue => e puts e.message end write [host.name, 'webserver.available', 0] end end HttpAvailabilityMonitor.run if $0 == __FILE__
Version data entries
16 entries across 16 versions & 1 rubygems