city-watch 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,8 @@ class CPUUsage
2
2
 
3
3
  include Watchman
4
4
 
5
+ set_default :usage_threshold, 60
6
+
5
7
  def self.data
6
8
  out = MPstat.data.select do |line|
7
9
  line[:run][/^Average:/]
@@ -9,4 +11,21 @@ class CPUUsage
9
11
  out.length > 0 ? out.first.merge({:summary => [:usr, :idle, :sys]}) : {:nodata => true}
10
12
  end
11
13
 
14
+ add_rule(:cpu_usage_high) do |data|
15
+
16
+ if (usage = data[:usr].to_i) && usage > option(:usage_threshold)
17
+ send_alert "CPU usage is over #{option(:usage_threshold)}% (#{usage}%)", data
18
+ set_flag :cpu_usage_high
19
+ else
20
+ clear_flag :cpu_usage_high
21
+ end
22
+
23
+ end
24
+
25
+ dataset(:save_dataset) do |data|
26
+ add_to_data_set(:cpu_user,data[:usr].to_f)
27
+ add_to_data_set(:cpu_idle,data[:idle].to_f)
28
+ add_to_data_set(:cpu_system,data[:sys].to_f)
29
+ end
30
+
12
31
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CityWatch
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
3
3
  end
@@ -0,0 +1,5 @@
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/>
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.6.8
4
+ version: 0.6.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -256,6 +256,7 @@ files:
256
256
  - views/layouts/default.html.erb
257
257
  - views/server/detail.html.erb
258
258
  - views/server/summary.html.erb
259
+ - views/watchmen/CPUUsage/summary.html.erb
259
260
  - views/watchmen/DiskUsage/summary.html.erb
260
261
  - views/watchmen/SystemInfo/detail.html.erb
261
262
  - views/watchmen/SystemInfo/summary.html.erb