city-watch 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,6 +61,25 @@ module Reader
61
61
  "<img src=\"data:image/png;base64,#{sparkline(dat)}\" alt=\"#{alt}\" title=\"#{alt} max: #{dat.max} min: #{dat.min}\"/>"
62
62
  end
63
63
 
64
+ def sparkline_for(set)
65
+ dat = get_data_set(set)
66
+ if dat.length > 1
67
+ puts dat.inspect
68
+ require 'base64'
69
+ require 'city_watch/util/spark_pr'
70
+ Base64.encode64(Spark.smooth(dat.map {|(tm,val)| val }, :height => 14, :step => 4).to_png).gsub("\n",'')
71
+ end
72
+ end
73
+
74
+ def sparkline_img_tag_for(set)
75
+ dat = get_data_set(set)
76
+ if dat.length > 1
77
+ "<img src=\"data:image/png;base64,#{sparkline(dat)}\" alt=\"#{set}\" title=\"#{set} max: #{dat.max} min: #{dat.min}\"/>"
78
+ else
79
+ ""
80
+ end
81
+ end
82
+
64
83
  def key(more)
65
84
  "#{key_prefix}::#{more}"
66
85
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CityWatch
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  <h4><%=@name%></h4>
2
- <%= sparkline_image_tags.map {|(name,tag)| tag }.join("&nbsp;")%><br/>
3
- <strong>User: </strong><%=@current_data["usr"]%><br/>
4
- <strong>Idle: </strong><%=@current_data["idle"]%><br/>
5
- <strong>System: </strong><%=@current_data["sys"]%><br/>
2
+ <strong>User: </strong><%=@current_data["usr"]%>&nbsp;<%=sparkline_img_tag_for(:cpu_user)%><br/>
3
+ <strong>Idle: </strong><%=@current_data["idle"]%>&nbsp;<%=sparkline_img_tag_for(:cpu_idle)%><br/>
4
+ <strong>System: </strong><%=@current_data["sys"]%>&nbsp;<%=sparkline_img_tag_for(:cpu_system)%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: city-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis