-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrouting.rb
47 lines (39 loc) · 1.12 KB
/
routing.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
require 'sinatra'
require_relative './stat_tracker'
tracker = StatTracker.new
get '/' do
'Navi is a tiny stat tracker of no real utility.'
end
get '/memory_script.py' do
location = File.join Dir.pwd, 'logstats.py'
return [200, File.read(location)]
end
get '/ping_script.py' do
location = File.join Dir.pwd, 'logping.py'
return [200, File.read(location)]
end
get '/trace_script.py' do
location = File.join Dir.pwd, 'logtrace.py'
return [200, File.read(location)]
end
post '/stat/:name' do |stat_name|
if stat_name == "memory"
#logger.debug "Logging #{n}"
tracker.log params['time'], 'active', params['active']
tracker.log params['time'], 'free', params['free']
tracker.log params['time'], 'total', params['total']
200
elsif stat_name == "ping"
tracker.log params['time'], 'ping result', params['result']
200
elsif stat_name == "log"
tracker.log params['time'], "log_message", params['message']
elsif stat_name == "domain"
param_lines = params['route_data'].split("\n")
param_lines.each do |line|
tracker.log params['time'], "trace", line
end
200
else
end
end