-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor_client.rb
59 lines (52 loc) · 1.28 KB
/
monitor_client.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# encoding: utf-8
require "open-uri"
require "net/http"
require "yaml"
def location
YAML.load(File.read(File.join(File.dirname(__FILE__),"config/location.yml")))["loc"]
rescue => e
return e
end
def video_in_folder
video_path = Dir.glob(File.join(File.dirname(__FILE__),"/downloads/*")).first
if video_path
video_path.split("/").last
else
nil
end
rescue => e
return e
end
def client_ip
# (open('http://checkip.dyndns.org/').read.scan(/(\d+\.\d+\.\d+\.\d+)/))[0][0]
open('http://utilities.notes18.com/ip_address').read.to_s
rescue => e
return e
end
def video_on_net
open("http://www.xinyegroup.com/dalaoju/s.aspx?id=#{location}").read.strip
rescue => e
return e
end
def process
%x[ps aux|grep vlc|grep down] + %x[ps aux|grep ruby|grep rb]
rescue => e
return e
end
def performance
%x[uptime] +"\n"+ %x[iostat] + %x[free -ml] + %x[sensors]
rescue => e
return e
end
loop do
begin
print "."
status = {location: location, ip: client_ip, video_in_folder: video_in_folder, video_on_net: video_on_net, performance: performance, process: process}
#Net::HTTP.post_form URI.parse("http://www.younoter.com:82/dalaoju"), status
Net::HTTP.post_form URI.parse("http://dlj.notes18.com:82/dalaoju"), status
rescue => e
puts e
sleep 60
end
sleep 300
end