Class: Perus::Pinger::Running

Inherits:
Command
  • Object
show all
Defined in:
lib/perus/pinger/metrics/running.rb

Instance Attribute Summary

Attributes inherited from Command

#id, #options

Instance Method Summary collapse

Methods inherited from Command

abstract!, abstract?, #cleanup, #darwin?, description, human_name, inherited, #initialize, metric!, metric?, option, options, #shell, subclasses

Constructor Details

This class inherits a constructor from Perus::Pinger::Command

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/perus/pinger/metrics/running.rb', line 9

def run
    begin
        ps_result = shell("ps aux | grep -v grep | grep #{options.process_path}")
    rescue ShellCommandError
        ps_result = ''
    end
    
    metric_name = "#{File.basename(options.process_path)}_running"
    {metric_name => ps_result.empty? ? 'no' : 'yes'}
end