city-watch 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/city_watch/reader/watchman.rb +11 -8
- data/lib/version.rb +1 -1
- data/views/watchmen/DiskUsage/summary.html.erb +1 -1
- metadata +1 -1
@@ -26,14 +26,15 @@ module Reader
|
|
26
26
|
|
27
27
|
def sparkline_image_tags
|
28
28
|
data_sets.map do |set|
|
29
|
-
|
30
|
-
|
29
|
+
dat = get_data_set(set)
|
30
|
+
[set.to_sym, dat.length > 1 ? sparkline_img_tag(dat.map {|(tm,val)| val }, set) : nil]
|
31
|
+
end.select {|(name,tag)| !tag.nil? }
|
31
32
|
end
|
32
33
|
|
33
|
-
def get_data_set(data_set_name,s_time=(Time.now - (60*60*
|
34
|
-
CityWatch.redis.zrevrangebyscore(data_set_key(data_set_name),
|
34
|
+
def get_data_set(data_set_name,s_time=(Time.now - (60*60*4)),e_time=Time.now)
|
35
|
+
CityWatch.redis.zrevrangebyscore(data_set_key(data_set_name), e_time.to_i, s_time.to_i, :with_scores => true).map do |(val,score)|
|
35
36
|
timestamp,value = val.split(",")
|
36
|
-
[Time.at(timestamp.to_i), value]
|
37
|
+
[Time.at(timestamp.to_i), Float(value)]
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -50,11 +51,13 @@ module Reader
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def sparkline(dat)
|
53
|
-
|
54
|
+
require 'base64'
|
55
|
+
require 'city_watch/util/spark_pr'
|
56
|
+
Base64.encode64(Spark.smooth(dat, :height => 14, :step => 4).to_png).gsub("\n",'')
|
54
57
|
end
|
55
58
|
|
56
|
-
def sparkline_img_tag(dat)
|
57
|
-
"<img src=\"data:image/png;base64,#{sparkline(dat)}\"/>"
|
59
|
+
def sparkline_img_tag(dat,alt="")
|
60
|
+
"<img src=\"data:image/png;base64,#{sparkline(dat)}\" alt=\"#{alt}\" title=\"#{alt}\"/>"
|
58
61
|
end
|
59
62
|
|
60
63
|
def key(more)
|
data/lib/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
<h4><%=@name%></h4>
|
2
|
-
<strong>Root FS usage: </strong><%=@current_data%>
|
2
|
+
<strong>Root FS usage: </strong><%=@current_data%> <%= sparkline_image_tags.map {|(name,tag)| tag }.join(" ")%>
|