Class: NotifyMe::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/notifyme/check.rb

Class Method Summary collapse

Class Method Details

.http(args = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/notifyme/check.rb', line 15

def http(args = {})
  require 'http_request'
  url = args[:url]
  hr = HttpRequest.get(url)
  if args[:include]
    raise "The page #{url} doesn't include \"#{args[:include]}\"." unless hr.body.include?(args[:include])
  else
    raise "Can't open #{url}." unless hr.code_200?
  end
end

.process(args = {}) ⇒ Object



4
5
6
7
8
# File 'lib/notifyme/check.rb', line 4

def process(args = {})
  if %x{ps aux | grep #{args[:name]} | grep -v grep}.strip == ''
    raise "Process #{args[:name]} is not running!"
  end
end

.tcp(args = {}) ⇒ Object



10
11
12
13
# File 'lib/notifyme/check.rb', line 10

def tcp(args = {})
  require 'socket'
  TCPSocket.new(args[:host] || 'localhost', args[:port])
end