sensu 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +13 -0
- data/lib/sensu/api/routes/aggregates.rb +1 -0
- data/lib/sensu/api/routes/checks.rb +2 -1
- data/lib/sensu/api/routes/events.rb +11 -1
- data/lib/sensu/api/routes/results.rb +30 -21
- data/lib/sensu/client/http_socket.rb +8 -2
- data/lib/sensu/client/socket.rb +11 -5
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/daemon.rb +2 -2
- data/lib/sensu/server/process.rb +43 -15
- data/lib/sensu/server/tessen.rb +168 -0
- data/sensu.gemspec +3 -2
- metadata +21 -6
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4df9a85ddc254d1263f15db61a541de388de666b
|
4
|
+
data.tar.gz: 4d3437ab1679588fbdc302eb31212e7d7354f5b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0958335b7aa9b62c2ecab2a1ca02c9f62a004ad9a47879a618fef67f0eb3bc1bc21126bfbfdcfebefe34d38decec7f45995cf3bd3c822fcd92541f84dffe2c74'
|
7
|
+
data.tar.gz: 32de7e4fcb1e8f51f0dde8ff54cb304a0c729e9560303fc56914ae8c91bff56750b11ea648213761705a6cb54bbc7cf9e5dc9dea17dd308246352010bde842a0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,19 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.4.0] - 2018-05-02
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Sensu call-home mechanism, the Tessen client (opt-in). It sends anonymized data about the Sensu installation to the Tessen hosted service (Sensu Inc), on sensu-server startup and every 6 hours thereafter. All data reports are logged for transparency/awareness and transmitted over HTTPS. The anonymized data currently includes the flavour of Sensu (Core or Enterprise), the Sensu version, and the Sensu client and server counts.
|
12
|
+
- API list endpoints (e.g. /events) now all support pagination.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Support for writing multiple check results to the client socket (in one payload).
|
16
|
+
- Improved event last_ok, now updating the value when storing latest check results for better accuracy.
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
- Include child process (e.g. check execution) stop (SIGTERM/KILL) error message in timeout output. This helps when debugging defunct/zombie processes, e.g. "Execution timed out - Unable to TERM/KILL the process: Operation not permitted".
|
20
|
+
|
8
21
|
## [1.3.3] - 2018-04-18
|
9
22
|
|
10
23
|
### Fixed
|
@@ -13,14 +13,19 @@ module Sensu
|
|
13
13
|
# GET /events
|
14
14
|
def get_events
|
15
15
|
@response_content = []
|
16
|
+
raw_event_json = []
|
16
17
|
@redis.smembers("clients") do |clients|
|
17
18
|
unless clients.empty?
|
18
19
|
clients.each_with_index do |client_name, index|
|
19
20
|
@redis.hgetall("events:#{client_name}") do |events|
|
20
21
|
events.each do |check_name, event_json|
|
21
|
-
|
22
|
+
raw_event_json << event_json
|
22
23
|
end
|
23
24
|
if index == clients.length - 1
|
25
|
+
raw_event_json = pagination(raw_event_json)
|
26
|
+
raw_event_json.each do |event_json|
|
27
|
+
@response_content << Sensu::JSON.load(event_json)
|
28
|
+
end
|
24
29
|
respond
|
25
30
|
end
|
26
31
|
end
|
@@ -35,8 +40,13 @@ module Sensu
|
|
35
40
|
def get_events_client
|
36
41
|
client_name = parse_uri(EVENTS_CLIENT_URI).first
|
37
42
|
@response_content = []
|
43
|
+
raw_event_json = []
|
38
44
|
@redis.hgetall("events:#{client_name}") do |events|
|
39
45
|
events.each do |check_name, event_json|
|
46
|
+
raw_event_json << event_json
|
47
|
+
end
|
48
|
+
raw_event_json = pagination(raw_event_json)
|
49
|
+
raw_event_json.each do |event_json|
|
40
50
|
@response_content << Sensu::JSON.load(event_json)
|
41
51
|
end
|
42
52
|
respond
|
@@ -30,30 +30,35 @@ module Sensu
|
|
30
30
|
@response_content = []
|
31
31
|
@redis.smembers("clients") do |clients|
|
32
32
|
unless clients.empty?
|
33
|
+
result_keys = []
|
33
34
|
clients.each_with_index do |client_name, client_index|
|
34
35
|
@redis.smembers("result:#{client_name}") do |checks|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
checks.each do |check_name|
|
37
|
+
result_keys << "result:#{client_name}:#{check_name}"
|
38
|
+
end
|
39
|
+
if client_index == clients.length - 1
|
40
|
+
result_keys = pagination(result_keys)
|
41
|
+
unless result_keys.empty?
|
42
|
+
result_keys.each_with_index do |result_key, result_key_index|
|
43
|
+
@redis.get(result_key) do |result_json|
|
44
|
+
_, client_name, check_name = result_key.split(":")
|
45
|
+
history_key = "history:#{client_name}:#{check_name}"
|
46
|
+
@redis.lrange(history_key, -21, -1) do |history|
|
47
|
+
history.map! do |status|
|
48
|
+
status.to_i
|
49
|
+
end
|
50
|
+
unless result_json.nil?
|
51
|
+
check = Sensu::JSON.load(result_json)
|
52
|
+
check[:history] = history
|
53
|
+
@response_content << {:client => client_name, :check => check}
|
54
|
+
end
|
55
|
+
if result_key_index == result_keys.length - 1
|
56
|
+
respond
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
54
|
-
|
55
|
-
elsif client_index == clients.length - 1
|
56
|
-
@redis.ping do
|
61
|
+
else
|
57
62
|
respond
|
58
63
|
end
|
59
64
|
end
|
@@ -70,6 +75,7 @@ module Sensu
|
|
70
75
|
client_name = parse_uri(RESULTS_CLIENT_URI).first
|
71
76
|
@response_content = []
|
72
77
|
@redis.smembers("result:#{client_name}") do |checks|
|
78
|
+
checks = pagination(checks)
|
73
79
|
unless checks.empty?
|
74
80
|
checks.each_with_index do |check_name, check_index|
|
75
81
|
result_key = "result:#{client_name}:#{check_name}"
|
@@ -126,8 +132,11 @@ module Sensu
|
|
126
132
|
if result_exists
|
127
133
|
@redis.srem("result:#{client_name}", check_name) do
|
128
134
|
@redis.del(result_key) do
|
129
|
-
|
130
|
-
|
135
|
+
history_key = "history:#{client_name}:#{check_name}"
|
136
|
+
@redis.del(history_key) do
|
137
|
+
@redis.del("#{history_key}:last_ok") do
|
138
|
+
no_content!
|
139
|
+
end
|
131
140
|
end
|
132
141
|
end
|
133
142
|
end
|
@@ -129,8 +129,14 @@ module Sensu
|
|
129
129
|
end
|
130
130
|
if @http[:content_type] and @http[:content_type].include?("application/json") and @http_content
|
131
131
|
begin
|
132
|
-
|
133
|
-
|
132
|
+
object = Sensu::JSON::load(@http_content)
|
133
|
+
if object.is_a?(Array)
|
134
|
+
object.each do |check|
|
135
|
+
process_check_result(check)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
process_check_result(object)
|
139
|
+
end
|
134
140
|
send_response(202, "OK", {:response => "ok"})
|
135
141
|
rescue Sensu::JSON::ParseError, ArgumentError
|
136
142
|
send_response(400, "Failed to parse JSON body", {:response => "Failed to parse JSON body"})
|
data/lib/sensu/client/socket.rb
CHANGED
@@ -116,16 +116,22 @@ module Sensu
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
# Parse
|
120
|
-
# error. For TCP, record parser errors, so the
|
121
|
-
# +watchdog+ can report them.
|
119
|
+
# Parse one or more JSON check results. For UDP, immediately
|
120
|
+
# raise a parser error. For TCP, record parser errors, so the
|
121
|
+
# connection +watchdog+ can report them.
|
122
122
|
#
|
123
123
|
# @param [String] data to parse for a check result.
|
124
124
|
def parse_check_result(data)
|
125
125
|
begin
|
126
|
-
|
126
|
+
object = Sensu::JSON.load(data)
|
127
127
|
cancel_watchdog
|
128
|
-
|
128
|
+
if object.is_a?(Array)
|
129
|
+
object.each do |check|
|
130
|
+
process_check_result(check)
|
131
|
+
end
|
132
|
+
else
|
133
|
+
process_check_result(object)
|
134
|
+
end
|
129
135
|
respond("ok")
|
130
136
|
rescue Sensu::JSON::ParseError, ArgumentError => error
|
131
137
|
if @protocol == :tcp
|
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/daemon.rb
CHANGED
@@ -4,11 +4,11 @@ gem "eventmachine", "1.2.5"
|
|
4
4
|
|
5
5
|
gem "sensu-json", "2.1.1"
|
6
6
|
gem "sensu-logger", "1.2.2"
|
7
|
-
gem "sensu-settings", "10.
|
7
|
+
gem "sensu-settings", "10.14.0"
|
8
8
|
gem "sensu-extension", "1.5.2"
|
9
9
|
gem "sensu-extensions", "1.9.1"
|
10
10
|
gem "sensu-transport", "7.1.0"
|
11
|
-
gem "sensu-spawn", "2.
|
11
|
+
gem "sensu-spawn", "2.5.0"
|
12
12
|
gem "sensu-redis", "2.3.0"
|
13
13
|
|
14
14
|
require "time"
|
data/lib/sensu/server/process.rb
CHANGED
@@ -2,6 +2,7 @@ require "sensu/daemon"
|
|
2
2
|
require "sensu/server/filter"
|
3
3
|
require "sensu/server/mutate"
|
4
4
|
require "sensu/server/handle"
|
5
|
+
require "sensu/server/tessen"
|
5
6
|
|
6
7
|
module Sensu
|
7
8
|
module Server
|
@@ -374,6 +375,9 @@ module Sensu
|
|
374
375
|
@redis.sadd("ttl", result_key) if check[:ttl]
|
375
376
|
@redis.rpush(history_key, check[:status])
|
376
377
|
@redis.ltrim(history_key, -21, -1)
|
378
|
+
if check[:status] == 0
|
379
|
+
@redis.set("#{history_key}:last_ok", check.fetch(:executed, Time.now.to_i))
|
380
|
+
end
|
377
381
|
@redis.exec do
|
378
382
|
yield
|
379
383
|
end
|
@@ -395,6 +399,8 @@ module Sensu
|
|
395
399
|
# result exit status codes.
|
396
400
|
# @yieldparam total_state_change [Float] percentage for the
|
397
401
|
# check history (exit status codes).
|
402
|
+
# @yieldparam last_ok [Integer] execution timestamp of the last
|
403
|
+
# OK check result.
|
398
404
|
def check_history(client, check)
|
399
405
|
history_key = "history:#{client[:name]}:#{check[:name]}"
|
400
406
|
@redis.lrange(history_key, -21, -1) do |history|
|
@@ -412,7 +418,10 @@ module Sensu
|
|
412
418
|
end
|
413
419
|
total_state_change = (state_changes.fdiv(20) * 100).to_i
|
414
420
|
end
|
415
|
-
|
421
|
+
@redis.get("#{history_key}:last_ok") do |last_ok|
|
422
|
+
last_ok = last_ok.to_i unless last_ok.nil?
|
423
|
+
yield(history, total_state_change, last_ok)
|
424
|
+
end
|
416
425
|
end
|
417
426
|
end
|
418
427
|
|
@@ -544,29 +553,27 @@ module Sensu
|
|
544
553
|
# resulting event.
|
545
554
|
# @yieldparam event [Hash]
|
546
555
|
def create_event(client, check)
|
547
|
-
check_history(client, check) do |history, total_state_change|
|
556
|
+
check_history(client, check) do |history, total_state_change, last_ok|
|
548
557
|
check[:history] = history
|
549
558
|
check[:total_state_change] = total_state_change
|
550
559
|
@redis.hget("events:#{client[:name]}", check[:name]) do |event_json|
|
551
560
|
stored_event = event_json ? Sensu::JSON.load(event_json) : nil
|
552
561
|
flapping = check_flapping?(stored_event, check)
|
553
562
|
event = {
|
563
|
+
:id => random_uuid,
|
554
564
|
:client => client,
|
555
565
|
:check => check,
|
556
566
|
:occurrences => 1,
|
557
567
|
:occurrences_watermark => 1,
|
568
|
+
:last_ok => last_ok,
|
558
569
|
:action => (flapping ? :flapping : :create),
|
559
570
|
:timestamp => Time.now.to_i
|
560
571
|
}
|
561
572
|
if stored_event
|
562
573
|
event[:id] = stored_event[:id]
|
563
574
|
event[:last_state_change] = stored_event[:last_state_change]
|
564
|
-
event[:last_ok] = stored_event[:last_ok]
|
565
575
|
event[:occurrences] = stored_event[:occurrences]
|
566
576
|
event[:occurrences_watermark] = stored_event[:occurrences_watermark] || event[:occurrences]
|
567
|
-
else
|
568
|
-
event[:id] = random_uuid
|
569
|
-
event[:last_ok] = event[:timestamp]
|
570
577
|
end
|
571
578
|
if check[:status] != 0 || flapping
|
572
579
|
if history[-1] == history[-2]
|
@@ -582,9 +589,6 @@ module Sensu
|
|
582
589
|
event[:last_state_change] = event[:timestamp]
|
583
590
|
event[:action] = :resolve
|
584
591
|
end
|
585
|
-
if check[:status] == 0
|
586
|
-
event[:last_ok] = event[:timestamp]
|
587
|
-
end
|
588
592
|
event_silenced?(event) do |event|
|
589
593
|
yield(event)
|
590
594
|
end
|
@@ -1056,6 +1060,8 @@ module Sensu
|
|
1056
1060
|
# configuration, it's deep merged with the defaults. The check
|
1057
1061
|
# `:name`, `:issued`, and `:executed` values are always
|
1058
1062
|
# overridden to guard against an invalid definition.
|
1063
|
+
#
|
1064
|
+
# @return [Array] check definition, unmatched client tokens
|
1059
1065
|
def create_keepalive_check(client)
|
1060
1066
|
check = {
|
1061
1067
|
:thresholds => {
|
@@ -1073,7 +1079,8 @@ module Sensu
|
|
1073
1079
|
check = deep_merge(check, client[:keepalive])
|
1074
1080
|
end
|
1075
1081
|
timestamp = Time.now.to_i
|
1076
|
-
check.merge(:name => "keepalive", :issued => timestamp, :executed => timestamp)
|
1082
|
+
check.merge!(:name => "keepalive", :issued => timestamp, :executed => timestamp)
|
1083
|
+
object_substitute_tokens(check, client)
|
1077
1084
|
end
|
1078
1085
|
|
1079
1086
|
# Create client keepalive check results. This method will
|
@@ -1098,7 +1105,7 @@ module Sensu
|
|
1098
1105
|
unless client_json.nil?
|
1099
1106
|
client = Sensu::JSON.load(client_json)
|
1100
1107
|
next if client[:keepalives] == false
|
1101
|
-
check = create_keepalive_check(client)
|
1108
|
+
check, unmatched_tokens = create_keepalive_check(client)
|
1102
1109
|
time_since_last_keepalive = Time.now.to_i - client[:timestamp]
|
1103
1110
|
check[:output] = "No keepalive sent from client for "
|
1104
1111
|
check[:output] << "#{time_since_last_keepalive} seconds"
|
@@ -1114,6 +1121,10 @@ module Sensu
|
|
1114
1121
|
check[:output] << "#{time_since_last_keepalive} seconds ago"
|
1115
1122
|
check[:status] = 0
|
1116
1123
|
end
|
1124
|
+
unless unmatched_tokens.empty?
|
1125
|
+
check[:output] << " - Unmatched client token(s): " + unmatched_tokens.join(", ")
|
1126
|
+
check[:status] = 1 if check[:status] == 0
|
1127
|
+
end
|
1117
1128
|
publish_check_result(client[:name], check)
|
1118
1129
|
end
|
1119
1130
|
end
|
@@ -1430,6 +1441,8 @@ module Sensu
|
|
1430
1441
|
:hexdigest => @settings.hexdigest
|
1431
1442
|
}
|
1432
1443
|
)
|
1444
|
+
tessen = @settings[:tessen] || {}
|
1445
|
+
tessen_enabled = tessen.fetch(:enabled, false)
|
1433
1446
|
info = {
|
1434
1447
|
:id => server_id,
|
1435
1448
|
:hostname => system_hostname,
|
@@ -1442,6 +1455,9 @@ module Sensu
|
|
1442
1455
|
}
|
1443
1456
|
},
|
1444
1457
|
:sensu => sensu,
|
1458
|
+
:tessen => {
|
1459
|
+
:enabled => tessen_enabled
|
1460
|
+
},
|
1445
1461
|
:timestamp => Time.now.to_i
|
1446
1462
|
}
|
1447
1463
|
@redis.sadd("servers", server_id)
|
@@ -1464,6 +1480,16 @@ module Sensu
|
|
1464
1480
|
end
|
1465
1481
|
end
|
1466
1482
|
|
1483
|
+
# Set up Tessen, the call home mechanism.
|
1484
|
+
def setup_tessen
|
1485
|
+
@tessen = Tessen.new(
|
1486
|
+
:settings => @settings,
|
1487
|
+
:logger => @logger,
|
1488
|
+
:redis => @redis
|
1489
|
+
)
|
1490
|
+
@tessen.run if @tessen.enabled?
|
1491
|
+
end
|
1492
|
+
|
1467
1493
|
# Unsubscribe from transport subscriptions (all of them). This
|
1468
1494
|
# method is called when there are issues with connectivity, or
|
1469
1495
|
# the process is stopping.
|
@@ -1497,6 +1523,7 @@ module Sensu
|
|
1497
1523
|
setup_results
|
1498
1524
|
setup_task_elections
|
1499
1525
|
setup_server_registry_updater
|
1526
|
+
setup_tessen
|
1500
1527
|
@state = :running
|
1501
1528
|
end
|
1502
1529
|
|
@@ -1513,10 +1540,10 @@ module Sensu
|
|
1513
1540
|
# Pause the Sensu server process, unless it is being paused or
|
1514
1541
|
# has already been paused. The process/daemon `@state` is first
|
1515
1542
|
# set to `:pausing`, to indicate that it's in progress. All run
|
1516
|
-
# timers are cancelled,
|
1517
|
-
# Sensu server will unsubscribe from all
|
1518
|
-
# subscriptions, relinquish any Sensu server tasks,
|
1519
|
-
# process/daemon `@state` to `:paused`.
|
1543
|
+
# timers are cancelled, their references are cleared, and Tessen
|
1544
|
+
# is stopped. The Sensu server will unsubscribe from all
|
1545
|
+
# transport subscriptions, relinquish any Sensu server tasks,
|
1546
|
+
# then set the process/daemon `@state` to `:paused`.
|
1520
1547
|
def pause
|
1521
1548
|
unless @state == :pausing || @state == :paused
|
1522
1549
|
@state = :pausing
|
@@ -1524,6 +1551,7 @@ module Sensu
|
|
1524
1551
|
timer.cancel
|
1525
1552
|
end
|
1526
1553
|
@timers[:run].clear
|
1554
|
+
@tessen.stop if @tessen
|
1527
1555
|
unsubscribe
|
1528
1556
|
relinquish_tasks
|
1529
1557
|
@state = :paused
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require "em-http-request"
|
2
|
+
require "sensu/constants"
|
3
|
+
|
4
|
+
module Sensu
|
5
|
+
module Server
|
6
|
+
class Tessen
|
7
|
+
attr_accessor :settings, :logger, :redis, :options
|
8
|
+
attr_reader :timers
|
9
|
+
|
10
|
+
# Create a new instance of Tessen. The instance variable
|
11
|
+
# `@timers` is use to track EventMachine timers for
|
12
|
+
# stopping/shutdown.
|
13
|
+
#
|
14
|
+
# @param options [Hash] containing the Sensu server Settings,
|
15
|
+
# Logger, and Redis connection.
|
16
|
+
def initialize(options={})
|
17
|
+
@timers = []
|
18
|
+
@settings = options[:settings]
|
19
|
+
@logger = options[:logger]
|
20
|
+
@redis = options[:redis]
|
21
|
+
@options = @settings.to_hash.fetch(:tessen, {})
|
22
|
+
end
|
23
|
+
|
24
|
+
# Determine if Tessen is enabled (opt-in).
|
25
|
+
#
|
26
|
+
# @return [TrueClass, FalseClass]
|
27
|
+
def enabled?
|
28
|
+
enabled = @options[:enabled] == true
|
29
|
+
unless enabled
|
30
|
+
note = "tessen collects anonymized data to help inform the sensu team about installations"
|
31
|
+
note << " - you can opt-in via configuration: {\"tessen\": {\"enabled\": true}}"
|
32
|
+
@logger.info("the tessen call-home mechanism is not enabled", :note => note)
|
33
|
+
end
|
34
|
+
enabled
|
35
|
+
end
|
36
|
+
|
37
|
+
# Run Tessen, scheduling data reports (every 6h).
|
38
|
+
def run
|
39
|
+
schedule_data_reports
|
40
|
+
end
|
41
|
+
|
42
|
+
# Stop Tessen, cancelling and clearing timers.
|
43
|
+
def stop
|
44
|
+
@timers.each do |timer|
|
45
|
+
timer.cancel
|
46
|
+
end
|
47
|
+
@timers.clear
|
48
|
+
end
|
49
|
+
|
50
|
+
# Schedule data reports, sending data to the Tessen service
|
51
|
+
# immediately and then every 6 hours after that.
|
52
|
+
def schedule_data_reports
|
53
|
+
send_data
|
54
|
+
@timers << EM::PeriodicTimer.new(21600) do
|
55
|
+
send_data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Send data to the Tessen service.
|
60
|
+
def send_data(&block)
|
61
|
+
create_data do |data|
|
62
|
+
tessen_api_request(data, &block)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Create data to be sent to the Tessen service.
|
67
|
+
#
|
68
|
+
# @return [Hash]
|
69
|
+
def create_data
|
70
|
+
get_install_id do |install_id|
|
71
|
+
get_client_count do |client_count|
|
72
|
+
get_server_count do |server_count|
|
73
|
+
identity_key = @options.fetch(:identity_key, "")
|
74
|
+
flavour, version = get_version_info
|
75
|
+
timestamp = Time.now.to_i
|
76
|
+
data = {
|
77
|
+
:tessen_identity_key => identity_key,
|
78
|
+
:install => {
|
79
|
+
:id => install_id,
|
80
|
+
:sensu_flavour => flavour,
|
81
|
+
:sensu_version => version
|
82
|
+
},
|
83
|
+
:metrics => {
|
84
|
+
:points => [
|
85
|
+
{
|
86
|
+
:name => "client_count",
|
87
|
+
:value => client_count,
|
88
|
+
:timestamp => timestamp
|
89
|
+
},
|
90
|
+
{
|
91
|
+
:name => "server_count",
|
92
|
+
:value => server_count,
|
93
|
+
:timestamp => timestamp
|
94
|
+
}
|
95
|
+
]
|
96
|
+
}
|
97
|
+
}
|
98
|
+
yield data
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Get the Sensu installation ID. The ID is randomly generated
|
105
|
+
# and stored in Redis. This ID provides context and allows
|
106
|
+
# multiple Sensu servers to report data for the same installation.
|
107
|
+
def get_install_id
|
108
|
+
@redis.setnx("tessen:install_id", rand(36**12).to_s(36)) do |created|
|
109
|
+
@redis.get("tessen:install_id") do |install_id|
|
110
|
+
yield install_id
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Get the Sensu client count for the installation. This count
|
116
|
+
# currently includes proxy clients.
|
117
|
+
#
|
118
|
+
# @yield [count]
|
119
|
+
# @yieldparam [Integer] client count
|
120
|
+
def get_client_count
|
121
|
+
@redis.scard("clients") do |count|
|
122
|
+
yield count.to_i
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Get the Sensu server count for the installation.
|
127
|
+
#
|
128
|
+
# @yield [count]
|
129
|
+
# @yieldparam [Integer] server count
|
130
|
+
def get_server_count
|
131
|
+
@redis.scard("servers") do |count|
|
132
|
+
yield count.to_i
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Get the Sensu version info for the local Sensu service.
|
137
|
+
def get_version_info
|
138
|
+
if defined?(Sensu::Enterprise::VERSION)
|
139
|
+
["enterprise", Sensu::Enterprise::VERSION]
|
140
|
+
else
|
141
|
+
["core", Sensu::VERSION]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Make a Tessen service API request.
|
146
|
+
#
|
147
|
+
# @param data [Hash]
|
148
|
+
def tessen_api_request(data)
|
149
|
+
@logger.debug("sending data to the tessen call-home service", {
|
150
|
+
:data => data,
|
151
|
+
:options => @options
|
152
|
+
})
|
153
|
+
connection = {}
|
154
|
+
connection[:proxy] = @options[:proxy] if @options[:proxy]
|
155
|
+
post_options = {:body => Sensu::JSON.dump(data)}
|
156
|
+
http = EM::HttpRequest.new("https://tessen.sensu.io/v1/data", connection).post(post_options)
|
157
|
+
http.callback do
|
158
|
+
@logger.debug("tessen call-home service response", :status => http.response_header.status)
|
159
|
+
yield if block_given?
|
160
|
+
end
|
161
|
+
http.errback do
|
162
|
+
@logger.debug("tessen call-home service error", :error => http.error)
|
163
|
+
yield if block_given?
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/sensu.gemspec
CHANGED
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency "eventmachine", "1.2.5"
|
16
16
|
s.add_dependency "sensu-json", "2.1.1"
|
17
17
|
s.add_dependency "sensu-logger", "1.2.2"
|
18
|
-
s.add_dependency "sensu-settings", "10.
|
18
|
+
s.add_dependency "sensu-settings", "10.14.0"
|
19
19
|
s.add_dependency "sensu-extension", "1.5.2"
|
20
20
|
s.add_dependency "sensu-extensions", "1.9.1"
|
21
21
|
s.add_dependency "sensu-transport", "7.1.0"
|
22
|
-
s.add_dependency "sensu-spawn", "2.
|
22
|
+
s.add_dependency "sensu-spawn", "2.5.0"
|
23
23
|
s.add_dependency "sensu-redis", "2.3.0"
|
24
24
|
s.add_dependency "em-http-server", "0.1.8"
|
25
25
|
s.add_dependency "parse-cron", "0.1.4"
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency "rspec", "~> 3.0.0"
|
29
29
|
s.add_development_dependency "em-http-request", "~> 1.1"
|
30
30
|
s.add_development_dependency "addressable", "2.3.8"
|
31
|
+
s.add_development_dependency "webmock", "3.3.0"
|
31
32
|
|
32
33
|
s.files = Dir.glob("{exe,lib}/**/*") + %w[sensu.gemspec README.md CHANGELOG.md MIT-LICENSE.txt]
|
33
34
|
s.executables = s.files.grep(%r{^exe/}) { |file| File.basename(file) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
jOeGyhtQa9j4FFmsEJDg59f5v/3hECXsa3Xuml3foaFHzX3Ya/YIyd2YFxvkFKIu
|
32
32
|
GVbe7A3YdxzdkH2Es/Ym9twdxXaIDdXzj8sWhw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2018-
|
34
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: eventmachine
|
@@ -81,14 +81,14 @@ dependencies:
|
|
81
81
|
requirements:
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 10.
|
84
|
+
version: 10.14.0
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - '='
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 10.
|
91
|
+
version: 10.14.0
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: sensu-extension
|
94
94
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,14 +137,14 @@ dependencies:
|
|
137
137
|
requirements:
|
138
138
|
- - '='
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 2.
|
140
|
+
version: 2.5.0
|
141
141
|
type: :runtime
|
142
142
|
prerelease: false
|
143
143
|
version_requirements: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
145
|
- - '='
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: 2.
|
147
|
+
version: 2.5.0
|
148
148
|
- !ruby/object:Gem::Dependency
|
149
149
|
name: sensu-redis
|
150
150
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,6 +243,20 @@ dependencies:
|
|
243
243
|
- - '='
|
244
244
|
- !ruby/object:Gem::Version
|
245
245
|
version: 2.3.8
|
246
|
+
- !ruby/object:Gem::Dependency
|
247
|
+
name: webmock
|
248
|
+
requirement: !ruby/object:Gem::Requirement
|
249
|
+
requirements:
|
250
|
+
- - '='
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: 3.3.0
|
253
|
+
type: :development
|
254
|
+
prerelease: false
|
255
|
+
version_requirements: !ruby/object:Gem::Requirement
|
256
|
+
requirements:
|
257
|
+
- - '='
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
version: 3.3.0
|
246
260
|
description: A monitoring framework that aims to be simple, malleable, and scalable.
|
247
261
|
email:
|
248
262
|
- portertech@gmail.com
|
@@ -301,6 +315,7 @@ files:
|
|
301
315
|
- lib/sensu/server/mutate.rb
|
302
316
|
- lib/sensu/server/process.rb
|
303
317
|
- lib/sensu/server/socket.rb
|
318
|
+
- lib/sensu/server/tessen.rb
|
304
319
|
- lib/sensu/utilities.rb
|
305
320
|
- sensu.gemspec
|
306
321
|
homepage: http://sensuapp.org
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
{]�j-��������[���T�Y�O����E��h��+�1�̔5�� �H��?����u㊃��B��گٞh��zq��m�F���~����B$w8�tº�X@���^���\&���F���#<�4.T:���T��V�:E�������<K0�NJ��|�m�Z��5K���k[��_�k���u��|�+�Q�-��8E'q�d�p�\T�����G�BW�e���������{��(
|