class ContinuentNagiosManagedConfiguration

Private Instance Methods

configure() click to toggle source
Calls superclass method
# File bin/tungsten_nagios_managed_configuration, line 65
def configure
  super()
  
  add_option(:lastrun, {
    :on => "--lastrun String",
    :help => "Path to the lastrun file written by tungsten_manage_configuration",
    :required => true
  })
  
  description("Check that the local managed configuration has run recently and was successful")
end
main() click to toggle source
# File bin/tungsten_nagios_managed_configuration, line 33
def main
  unless File.exist?(opt(:lastrun))
    critical("The #{opt(:lastrun)} file is not present")
  end
  
  begin
    last_exit_code = File.new(opt(:lastrun)).read().chomp()
    
    if last_exit_code.to_s() != "0"
      critical("The last run of tungsten_manage_configuration was not successful")
    end
  rescue
    critical("There were issues reading #{opt(:lastrun)}")
  end
  
  begin
    mtime = File.mtime(opt(:lastrun))
    difference = Time.now()-mtime
    add_perfdata("lastrun", "#{difference};#{opt(:warning_level)};#{opt(:critical_level)};")
    
    if is_critical?(difference)
      critical("The tungsten_manage_configuration script last ran #{difference}s ago")
    elsif is_warning?(difference)
      warning("The tungsten_manage_configuration script last ran #{difference}s ago")
    else
      ok("The tungsten_manage_configuration script was successful")
    end
  rescue
    critical("There were issues reading #{opt(:lastrun)} modification time")
  end
end
script_name() click to toggle source
# File bin/tungsten_nagios_managed_configuration, line 77
def script_name
  "tungsten_nagios_managed_configuration"
end
uses_thresholds?() click to toggle source
# File bin/tungsten_nagios_managed_configuration, line 81
def uses_thresholds?
  true
end