Class: Metis::Client
- Inherits:
-
Object
- Object
- Metis::Client
- Defined in:
- lib/metis/client.rb
Instance Method Summary collapse
-
#initialize(socket, context) ⇒ Client
constructor
A new instance of Client.
- #process ⇒ Object
Constructor Details
#initialize(socket, context) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/metis/client.rb', line 5 def initialize(socket, context) @socket = socket @context = context end |
Instance Method Details
#process ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/metis/client.rb', line 10 def process query = Metis::NrpePacket.read(@socket) # ensure it doesn't specify any commands if query.buffer =~ /!/ send_response(Metis::STATUS_CRITICAL, "Arguments not allowed") return end # find the command check_name = query.buffer.to_sym check_definition = @context.definitions[check_name] # ensure it exists unless check_definition send_response(Metis::STATUS_WARNING, "Command #{query.buffer} not found") return end # run it provider = Metis::Provider.new(check_definition, @context) provider.run send_response(provider.response_code, provider.) rescue Exception => e send_response(Metis::STATUS_CRITICAL, "Error encountered while processing: #{e.}") ensure @socket.close end |