class ContinuentNagiosMonitorProgress
Private Instance Methods
configure()
click to toggle source
Calls superclass method
# File bin/tungsten_nagios_progress, line 106 def configure super() description("Check that the replication service is making progress. For Continuent Tungsten installations, a heartbeat command will be run to force activity.") add_option(:delay, { :on => "--delay String", :help => "The number of seconds to wait when monitoring progress", :parse => method(:parse_integer_option), :default => 1 }) add_option(:service, { :on => "--service String", :help => "The replication service or cluster to check" }) add_option(:metric, { :on=> "--metric String", :help=>"The field to use to determine progess", :default=> "currentLastSeqno" }) end
find_values(input_values,stage,key)
click to toggle source
# File bin/tungsten_nagios_progress, line 134 def find_values(input_values,stage,key) #Note: When currentLastSeqno is selected it will be combined with currentLastfragno to ensure the field # always go up. stage_values=input_values.find{|x| x['stage']=stage} if key=='currentLastSeqno' (stage_values['currentLastSeqno']+stage_values['currentLastFragno'].rjust(5,'0')).to_s().to_f() else stage_values[key].to_s().to_f() end end
main()
click to toggle source
# File bin/tungsten_nagios_progress, line 33 def main unless TI.is_replicator?() critical("The server is not a Tungsten Replicator") end unless TI.is_running?("replicator") critical("The Tungsten Replicator is not running") end if TI.is_commercial?() unless TI.is_manager?() critical("The server is not a Continuent Tungsten Manager") end unless TI.is_running?("manager") critical("The Continuent Tungsten Manager is not running") end end opt_default(:service, TI.default_dataservice()) if opt(:service) == nil critical("The --service option was not given") end unless TI.trepctl_value(opt(:service), "state") == "ONLINE" critical("The #{opt(:service)} replication service is not ONLINE") end unless ["appliedLastSeqno","currentLastSeqno"].include?(opt(:metric)) critical("Unknown metric #{opt(:metric)}") end stages = { "master" => ["binlog-to-q","q-to-thl"], "slave" => ["remote-to-thl","thl-to-q","q-to-dbms"], "relay" => ["remote-to-thl","thl-to-q","q-to-dbms"], "direct" => ["d-binlog-to-q","d-q-to-thl","d-thl-to-pq","d-pq-to-dbms"] } pre_results=Hash.new role=TI.trepctl_value(opt(:service), "role").to_s() pre_values = TI.trepctl_name_all(opt(:service),'tasks') stages[role].each do |stage_name| pre_results[stage_name]=find_values(pre_values,stage_name,opt(:metric)) end if TI.is_commercial?() TI.ensure_cctrl("cluster heartbeat") end if opt(:delay).is_a?(Integer) TU.debug("Go to sleep for #{opt(:delay)} seconds") sleep(opt(:delay)) end replicator_making_progress=false post_values = TI.trepctl_name_all(opt(:service),'tasks') stages[role].each do |stage_name| if find_values(post_values,stage_name,opt(:metric)) - pre_results[stage_name] > 0 replicator_making_progress=true end end if replicator_making_progress ok("Tungsten Replicator #{opt(:service)} service is making progress") else critical("Tungsten Replicator #{opt(:service)} service did not show progress") end end
script_name()
click to toggle source
# File bin/tungsten_nagios_progress, line 130 def script_name "tungsten_nagios_progress" end