netdata-client 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/com.netdata.monitor.plist.dist +3 -0
- data/exe/netdatacli +13 -1
- data/lib/netdata/client/controller.rb +10 -7
- data/lib/netdata/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8171602fe100225682a866be89d6670d825847ee
|
4
|
+
data.tar.gz: b23deb081fe6502ce501d0d81b980a90e4244eed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61ff2f57377312fe4adf9eb99f6bc4334342bd607ab6c4585076e8267c7f375d383c11a552bdcaf78554d3430d787292d03ae2eda73086e77314b5606ea5204f
|
7
|
+
data.tar.gz: fd23f25cde337bf43050901b879a6f4708a44a96049a6b394a252ffea7c3bd9438c4bfbe68cba2c0d663a39319e832e4ec548763cc84fd0169e6724e3e3c99a2
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ instances:
|
|
24
24
|
|
25
25
|
If you're using OSX > 10.4:
|
26
26
|
|
27
|
-
1. Rename `com.netdata.monitor.plist.dist` to `com.netdata.monitor.plist` and update the ProgramArguments value to point to where the gem lives (i.e. `/Library/Ruby/Gems/2.0.0`).
|
27
|
+
1. Rename `com.netdata.monitor.2mins.plist.dist` to `com.netdata.monitor.2mins.plist` and update the ProgramArguments value to point to where the gem lives (i.e. `/Library/Ruby/Gems/2.0.0`).
|
28
28
|
2. `cp com.netdata.monitor.plist /Library/LaunchDaemons`
|
29
29
|
3. `launchtl load -w /Library/LaunchDaemons/com.netdata.monitor.plist`
|
30
30
|
|
data/exe/netdatacli
CHANGED
@@ -3,6 +3,18 @@ lib = File.expand_path('../../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
require "netdata/client"
|
6
|
+
require "optparse"
|
7
|
+
|
8
|
+
main = false
|
9
|
+
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
# opt.banner = "netdatacli [...flags]"
|
12
|
+
|
13
|
+
opt.on("-m", "--2min", "Trigger the 2 minute actions") { |o| main = true }
|
14
|
+
end.parse!
|
6
15
|
|
7
16
|
client = Netdata::Client::Controller.new
|
8
|
-
|
17
|
+
|
18
|
+
if main
|
19
|
+
client.report_interval_2_mins
|
20
|
+
end
|
@@ -6,8 +6,9 @@ module Netdata
|
|
6
6
|
@config = ::YAML::load_file(File.expand_path("~/.netdatacli.yml"))
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def report_interval_2_mins
|
10
10
|
aggregator = {}
|
11
|
+
threshold = 50 # numbers higher than this should trigger notifications
|
11
12
|
|
12
13
|
return unless @config
|
13
14
|
|
@@ -42,12 +43,13 @@ module Netdata
|
|
42
43
|
users_cpu = @network.get("data", url, users_cpu_opts)
|
43
44
|
users_cpu_resp = JSON.parse(users_cpu.body)
|
44
45
|
users_cpu_value = users_cpu_resp["result"].first
|
46
|
+
users_cpu_value_history = users_cpu_resp["result"][0..119]
|
45
47
|
users_cpu_users = users_cpu_resp["dimension_names"]
|
46
48
|
|
47
49
|
aggregator[alarms_resp["hostname"]] = {}
|
48
|
-
aggregator[alarms_resp["hostname"]][
|
49
|
-
aggregator[alarms_resp["hostname"]][
|
50
|
-
aggregator[alarms_resp["hostname"]][
|
50
|
+
aggregator[alarms_resp["hostname"]][:cpu] = cpu_value
|
51
|
+
aggregator[alarms_resp["hostname"]][:users_cpu] = { users: users_cpu_users, value: users_cpu_value, history: users_cpu_value_history.select { |val| val > threshold } }
|
52
|
+
aggregator[alarms_resp["hostname"]][:alarms] = alarms_resp unless alarms_resp["alarms"].empty?
|
51
53
|
end
|
52
54
|
|
53
55
|
pp aggregator
|
@@ -56,9 +58,10 @@ module Netdata
|
|
56
58
|
# new thread for each host so we can see mulitple notifications
|
57
59
|
Thread.new {
|
58
60
|
message = ""
|
59
|
-
message += "CPU Warning - #{data[
|
60
|
-
message += "#{data[
|
61
|
-
message += "Alarms are ringing" if data[
|
61
|
+
message += "CPU Warning - #{data[:cpu].round(2)}%\n" if data[:cpu] > threshold
|
62
|
+
message += "#{data[:users_cpu][:users].size} system users active (#{data[:users_cpu][:value].round(2)}% CPU)\n" if data[:users_cpu][:value] > threshold
|
63
|
+
message += "Alarms are ringing" if data[:alarms]
|
64
|
+
message += "#{data[:users_cpu][:history].size} CPU instance(s) > #{threshold}%" if data[:users_cpu][:history].size > 0
|
62
65
|
|
63
66
|
Notify.bubble(message, "Netdata Warning on #{host}") if message.size > 0
|
64
67
|
}.join
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netdata-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Priebe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: notifaction
|