forked from krobertson/metis
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rehashing to work as an NRPE replacement
- Loading branch information
1 parent
dd80445
commit bcb8564
Showing
29 changed files
with
252 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,12 @@ | ||
require 'clockwork' | ||
require 'ohai' | ||
|
||
class Metis | ||
end | ||
|
||
require 'metis/version' | ||
|
||
require 'metis/mixin/from_file' | ||
require 'metis/mixin/params_validate' | ||
require 'metis/mixin/convert_to_class_name' | ||
|
||
require 'metis/host' | ||
|
||
require 'metis/dsl/check_dsl' | ||
require 'metis/dsl/host_role_dsl' | ||
|
||
require 'metis/context' | ||
require 'metis/check_definition' | ||
require 'metis/check_definition_list' | ||
require 'metis/configuration_definition' | ||
require 'metis/provider' | ||
require 'metis/provider/check' | ||
require 'metis/provider/check_true' | ||
require 'metis/provider/check_http' | ||
require 'metis/provider/check_port' | ||
|
||
require 'metis/resource' | ||
require 'metis/resource/check' | ||
require 'metis/resource/check_true' | ||
require 'metis/resource/check_http' | ||
require 'metis/resource/check_port' | ||
|
||
require 'metis/solo_context' | ||
require 'metis/agent_context' | ||
require 'metis/nrpe_packet' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'metis/mixin/params_validate' | ||
|
||
class Metis | ||
class CheckDefinition | ||
include Metis::Mixin::ParamsValidate | ||
|
||
attr_accessor :name, :params | ||
|
||
def initialize | ||
@name = nil | ||
@params = {} | ||
@requires = [] | ||
end | ||
|
||
def attribute(attr_name, validation_opts={}) | ||
shim_method=<<-SHIM | ||
def #{attr_name}(arg=nil) | ||
set_or_return(:#{attr_name.to_s}, arg, #{validation_opts.inspect}) | ||
end | ||
SHIM | ||
set_or_return(attr_name.to_sym, nil, validation_opts) | ||
self.instance_eval(shim_method) | ||
end | ||
|
||
def require_gem(*libs) | ||
@requires << libs | ||
@requires.flatten! | ||
end | ||
|
||
def execute(&block) | ||
set_or_return(:execute, block, :kind_of => [Proc]) | ||
end | ||
|
||
def _requires | ||
@requires | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'metis/mixin/from_file' | ||
require 'metis/check_definition' | ||
|
||
class Metis | ||
class CheckDefinitionList | ||
include Metis::Mixin::FromFile | ||
|
||
attr_accessor :defines | ||
|
||
def initialize | ||
@defines = Hash.new | ||
end | ||
|
||
def define(check_name, &block) | ||
@defines[check_name] = CheckDefinition.new | ||
@defines[check_name].instance_eval(&block) | ||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'metis/mixin/from_file' | ||
|
||
class Metis | ||
class ConfigurationDefinition | ||
include Metis::Mixin::FromFile | ||
|
||
def initialize(context) | ||
@context = context | ||
end | ||
|
||
def configure(check_name, &block) | ||
raise "Unknown check definition: #{check_name}" unless @context.definitions[check_name] | ||
@context.definitions[check_name].instance_eval(&block) | ||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Metis | ||
class Context | ||
|
||
attr_reader :definitions | ||
|
||
def initialize | ||
@definitions = Hash.new | ||
end | ||
|
||
def load | ||
load_checks | ||
load_configs | ||
true | ||
end | ||
|
||
def load_checks | ||
Dir.glob("checks/*.rb").each do |filename| | ||
checklist = Metis::CheckDefinitionList.new | ||
checklist.from_file(filename) | ||
definitions.merge!(checklist.defines) do |key, oldval, newval| | ||
puts "Overriding duplicate definition #{key}, new definition found in #{filename}" | ||
newval | ||
end | ||
end | ||
end | ||
|
||
def load_configs | ||
configdefinition = ConfigurationDefinition.new(self) | ||
configdefinition.from_file("config.rb") | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Metis | ||
module Mixin | ||
module FromFile | ||
|
||
# Loads a given ruby file, and runs instance_eval against it in the context of the current | ||
# object. | ||
# | ||
# Raises an IOError if the file cannot be found, or is not readable. | ||
def from_file(filename) | ||
if File.exists?(filename) && File.readable?(filename) | ||
self.instance_eval(IO.read(filename), filename, 1) | ||
else | ||
raise IOError, "Cannot open or read #{filename}!" | ||
end | ||
end | ||
|
||
# Loads a given ruby file, and runs class_eval against it in the context of the current | ||
# object. | ||
# | ||
# Raises an IOError if the file cannot be found, or is not readable. | ||
def class_from_file(filename) | ||
if File.exists?(filename) && File.readable?(filename) | ||
self.class_eval(IO.read(filename), filename, 1) | ||
else | ||
raise IOError, "Cannot open or read #{filename}!" | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.