Class: Monittr::Services::Process

Inherits:
Base
  • Object
show all
Defined in:
lib/monittr.rb

Overview

A “process” service in Monit

mmonit.com/monit/documentation/monit.html#pid_testing

<service type=“3”>

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Method Summary collapse

Methods inherited from Base

#inspect, #load, #value

Constructor Details

#initialize(xml) ⇒ Process

Returns a new instance of Process.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/monittr.rb', line 133

def initialize(xml)
  @xml = xml
  super( { :name      => value('name'                          ),
           :status    => value('status',                  :to_i),
           :monitored => value('monitor',                 :to_i),
           :pid       => value('pid',                     :to_i),
           :uptime    => value('uptime',                  :to_i),
           :memory    => value('memory/percent',          :to_f),
           :cpu       => value('cpu/percent',             :to_i)
         } )
  rescue Exception => e
    puts "ERROR: #{e.class} -- #{e.message}, In: #{e.backtrace.first}"
    super( { :name => 'Error',
             :status  => 3,
             :message => e.message } )
end