class Arborist::Monitor::SNMP::Process
SNMP running process checks.
This only checks running userland processes.
Constants
- PROCESS
OIDS for discovering running processes. Of course, Windows does it slightly differently.
Public Class Methods
node_properties()
click to toggle source
Return the properties used by this monitor.
# File lib/arborist/monitor/snmp/process.rb, line 44 def self::node_properties return USED_PROPERTIES end
run( nodes )
click to toggle source
Class run
creates a new instance and immediately runs it.
# File lib/arborist/monitor/snmp/process.rb, line 51 def self::run( nodes ) return new.run( nodes ) end
Public Instance Methods
run( nodes )
click to toggle source
Perform the monitoring checks.
Calls superclass method
Arborist::Monitor::SNMP#run
# File lib/arborist/monitor/snmp/process.rb, line 58 def run( nodes ) super do |host, snmp| self.gather_processlist( host, snmp ) end end
Protected Instance Methods
gather_processlist( host, snmp )
click to toggle source
Collect running processes on host
from an existing (and open)
+snmp+ connection.
# File lib/arborist/monitor/snmp/process.rb, line 72 def gather_processlist( host, snmp ) config = self.identifiers[ host ].last['config'] || {} errors = [] procs = self.system =~ /windows\s+/i ? self.get_windows( snmp ) : self.get_procs( snmp ) self.log.debug "Running processes for host: %s: %p" % [ host, procs ] self.results[ host ] = { count: procs.size } # Check against what is running. # Array( config['check'] || self.class.check ).each do |process| process_r = Regexp.new( process ) found = procs.find{|p| p.match(process_r) } errors << "'%s' is not running" % [ process ] unless found end self.results[ host ][ :error ] = errors.join( ', ' ) unless errors.empty? end
get_procs( snmp )
click to toggle source
Parse OIDS and return an Array of running processes.
# File lib/arborist/monitor/snmp/process.rb, line 120 def get_procs( snmp ) oids = [ PROCESS[:netsnmp][:list], PROCESS[:netsnmp][:args] ] procs = snmp.walk( oid: oids.first ).each_with_object( [] ) do |(_, value), acc| acc << value end args = snmp.walk( oid: oids.last ).each_with_object( [] ) do |(_, value), acc| acc << value end return procs.zip( args ).collect do |(process, arg)| next if process.empty? process << " %s" % [ arg.to_s ] unless arg.empty? process end.compact end
get_windows( snmp )
click to toggle source
Parse OIDS and return an Array of running processes. Windows specific behaviors.
# File lib/arborist/monitor/snmp/process.rb, line 95 def get_windows( snmp ) oids = [ PROCESS[:windows][:path], PROCESS[:windows][:list], PROCESS[:windows][:args] ] paths = snmp.walk( oid: oids[0] ).each_with_object( [] ) do |(_, value), acc| acc << value end procs = snmp.walk( oid: oids[1] ).each_with_object( [] ) do |(_, value), acc| acc << value end args = snmp.walk( oid: oids[2] ).each_with_object( [] ) do |(_, value), acc| acc << value end return paths.zip( procs, args ).collect do |(path, process, arg)| next unless path && process next if path.empty? path << process unless process.empty? path << " %s" % [ arg.to_s ] if arg && ! arg.empty? path end.compact end