Class: GaddyGaddyCheck
- Inherits:
-
Object
- Object
- GaddyGaddyCheck
- Defined in:
- lib/gg_check/gaddy_gaddy_check.rb
Direct Known Subclasses
AirPiCheck, AirPrintServerCheck, BrewPiCheck, CloudPrintServerCheck, LycheeCheck, MinecraftServerCheck, NASCheck, SeafileCheck, SqueezeBoxClientCheck, SqueezeBoxServerCheck, VPNProxyCheck, WebBrowserCheck, WebKioskCheck, WebcamMotionCheck, WindowsPrintServerCheck
Instance Method Summary collapse
-
#extra ⇒ Object
Will return extra info given as parameter.
-
#initialize(extra) ⇒ GaddyGaddyCheck
constructor
A new instance of GaddyGaddyCheck.
-
#process_alive?(regexp) ⇒ Boolean
Will check if a process is live.
-
#run_cmd(cmd) ⇒ Object
Will run a command and return: status, stdout, stderr.
-
#socket(host, port, message, sleep_sec = 1) ⇒ Object
Will open a socket connection and send a message and wait for a result.
Constructor Details
#initialize(extra) ⇒ GaddyGaddyCheck
Returns a new instance of GaddyGaddyCheck.
17 18 19 |
# File 'lib/gg_check/gaddy_gaddy_check.rb', line 17 def initialize(extra) @extra = extra.split(',') end |
Instance Method Details
#extra ⇒ Object
Will return extra info given as parameter
24 25 26 |
# File 'lib/gg_check/gaddy_gaddy_check.rb', line 24 def extra @extra end |
#process_alive?(regexp) ⇒ Boolean
Will check if a process is live
51 52 53 54 |
# File 'lib/gg_check/gaddy_gaddy_check.rb', line 51 def process_alive? (regexp) status, process_lines, stderr = run_cmd "ps -ef|grep -e '#{regexp}'|grep -v grep".strip process_lines.size > 0 end |
#run_cmd(cmd) ⇒ Object
Will run a command and return: status, stdout, stderr
32 33 34 |
# File 'lib/gg_check/gaddy_gaddy_check.rb', line 32 def run_cmd cmd systemu cmd end |
#socket(host, port, message, sleep_sec = 1) ⇒ Object
Will open a socket connection and send a message and wait for a result
39 40 41 42 43 44 45 46 |
# File 'lib/gg_check/gaddy_gaddy_check.rb', line 39 def socket(host,port,,sleep_sec=1) Socket.tcp(host, port) {|sock| sock.print sleep sleep_sec sock.close_write sock.read } end |