class ContinuentNagiosMonitorOnline

Private Instance Methods

configure() click to toggle source
Calls superclass method
# File bin/tungsten_nagios_online, line 117
def configure
  super()
  
  description("Check that all datasources or the local replication service are ONLINE.")
  
  add_option(:service, {
    :on => "--service String",
    :help => "The replication service or cluster to check"
  })

  add_option(:skip_shunned, {
    :on => "--skip-shunned String",
    :help => "Ignore Continuent Tungsten datasources that have been shunned.",
    :parse => method(:parse_boolean_option),
    :default => "false"
  })

  add_option(:skip_manually_shunned, {
    :on => "--skip-manually-shunned String",
    :help => "Ignore Continuent Tungsten datasources that have been shunned manually.",
    :parse => method(:parse_boolean_option),
    :default => "false"
  })
end
main() click to toggle source
# File bin/tungsten_nagios_online, line 33
def main
  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
  else
    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
  end
  
  opt_default(:service, TI.default_dataservice())
  if opt(:service) == nil
    critical("The --service option was not given")
  end
  
  not_online = []
  shunned = []

  status = TI.status(opt(:service))
  if status.is_replication?()
    # Replication Only
    status.replicators().each{
      |name|
      rep_status = status.replicator_status(name)

      if rep_status != "ONLINE"
        not_online << name
      end
    }
  elsif status.is_physical?()
    # Physical Dataservice
    status.replicators().each{
      |name|
      ds_status = status.datasource_status(name)
      ds_lastshunreason = status.datasource_value(name, 'lastShunReason')
      rep_status = status.replicator_status(name)
      
      if ds_status == "SHUNNED"
        if opt(:skip_shunned) == true || (opt(:skip_manually_shunned) == true && ds_lastshunreason == "MANUALLY-SHUNNED")
          shunned << name
          next
        end
      end

      if ds_status != "ONLINE" || rep_status != "ONLINE"
        not_online << name
      end
    }
  else
    # Composite Dataservices
    status.datasources().each{
      |name|
      ds_status = status.datasource_status(name)
      ds_lastshunreason = status.datasource_value(name, 'lastShunReason')
      
      if ds_status == "SHUNNED"
        if opt(:skip_shunned) == true || (opt(:skip_manually_shunned) == true && ds_lastshunreason == "MANUALLY-SHUNNED")
          shunned << name
          next
        end
      end

      if ds_status != "ONLINE"
        not_online << name
      end
    }
  end
  
  if not_online.size() > 0
    critical("#{not_online.join(', ')} #{TU.pluralize(not_online, "is", "are")} not ONLINE")
  end
  
  ok("All services are ONLINE")
end
script_name() click to toggle source
# File bin/tungsten_nagios_online, line 142
def script_name
  "tungsten_nagios_online"
end