sensu-plugins-eventstore 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/{metrics-stats.rb → metrics-eventstore-stats-stream.rb} +38 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0e69b6da1a9133bddaac28961fa80ceff486e2d
|
4
|
+
data.tar.gz: 1cea373cc00a28da343382c1e3817c83b947e9a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f6556254599dd9f34b0b575c5aafc6ea0b8911a282566f8a57c7f65259b29c750876d052c3f3d35df9a7112859208d8771ab24630f46a92800bbec313659f1b
|
7
|
+
data.tar.gz: 17ddfc644220f4aeddf23b34c0072b32376bd2f4f52755ed854fe8a809e078d7601d2994fb58297af778500fb44b230c3cdc8a84f651941b35f9ccddc7a2f876
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Stats
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
6
|
# Metrics for the event store stats
|
@@ -46,10 +46,28 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
46
46
|
default: 'localhost'
|
47
47
|
|
48
48
|
option :port,
|
49
|
-
description: 'What port to use. (Default
|
49
|
+
description: 'What port to use. (Default 2114)',
|
50
50
|
short: '-p',
|
51
51
|
long: '--port port',
|
52
|
-
default: '
|
52
|
+
default: '2114'
|
53
|
+
|
54
|
+
option :use_authentication,
|
55
|
+
description: 'Should use authentication (Default false)',
|
56
|
+
short: '-ua',
|
57
|
+
long: '--auth auth',
|
58
|
+
default: 'false'
|
59
|
+
|
60
|
+
option :auth_user,
|
61
|
+
description: 'Username for stats stream auth. (Default "admin")',
|
62
|
+
short: '-usr',
|
63
|
+
long: '--auth_user auth_user',
|
64
|
+
default: 'admin'
|
65
|
+
|
66
|
+
option :auth_password,
|
67
|
+
description: 'What port to use. (Default "changeit")',
|
68
|
+
short: '-pwd',
|
69
|
+
long: '--auth_password auth_password',
|
70
|
+
default: 'changeit'
|
53
71
|
|
54
72
|
def run
|
55
73
|
discover_via_dns = config[:discover_via_dns]
|
@@ -78,12 +96,7 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
78
96
|
def collect_metrics(address, port)
|
79
97
|
stream_url = "http://#{address}:#{port}/streams/$stats-#{address}:#{port}"
|
80
98
|
|
81
|
-
|
82
|
-
stream_temp_file = open stream_url, "Accept" => "application/atom+xml"
|
83
|
-
|
84
|
-
puts "open result:: temp file found? "
|
85
|
-
|
86
|
-
p stream_temp_file
|
99
|
+
stream_temp_file = get_stream stream_url
|
87
100
|
|
88
101
|
namespace_regex = / xmlns="[A-Za-z:\/.0-9]+"/
|
89
102
|
|
@@ -98,12 +111,9 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
98
111
|
.sort { |node| DateTime.parse node.xpath('.//updated').text }
|
99
112
|
.last
|
100
113
|
|
101
|
-
|
102
|
-
event_number = event_number_regex.match latest_entry.at_xpath('.//id').content
|
114
|
+
latest_event_url = latest_entry.at_xpath('.//id').content
|
103
115
|
|
104
|
-
|
105
|
-
|
106
|
-
element_temp_file = open latest_event_url, "Accept" => "application/json"
|
116
|
+
element_temp_file = get_stream latest_event_url
|
107
117
|
json_stats = JSON.parse element_temp_file.read
|
108
118
|
|
109
119
|
stats_dict = parse_json_stats json_stats
|
@@ -113,6 +123,20 @@ class Stats < Sensu::Plugin::Metric::CLI::Graphite
|
|
113
123
|
ok
|
114
124
|
end
|
115
125
|
|
126
|
+
def get_stream(stream_url)
|
127
|
+
puts "opening stream @ url #{stream_url}"
|
128
|
+
|
129
|
+
use_auth = config[:use_authentication]
|
130
|
+
|
131
|
+
if "true".casecmp(use_auth) == 0
|
132
|
+
username = config[:auth_user]
|
133
|
+
password = config[:auth_password]
|
134
|
+
return open stream_url, http_basic_authentication:[username, password], "Accept" => "application/atom+xml"
|
135
|
+
else
|
136
|
+
return open stream_url, "Accept" => "application/atom+xml"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
116
140
|
def add_metric(json_stats, stats_dict, stat_name_mapping)
|
117
141
|
stat_value = json_stats[stat_name_mapping[:source_name]]
|
118
142
|
stats_dict[stat_name_mapping[:target_name]] = stat_value
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-eventstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Wroe
|
@@ -70,7 +70,7 @@ description: A collection of checks and metrics for event store, designed for se
|
|
70
70
|
email: Jamie.Wroe@live.co.uk
|
71
71
|
executables:
|
72
72
|
- check-gossip.rb
|
73
|
-
- metrics-stats.rb
|
73
|
+
- metrics-eventstore-stats-stream.rb
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
@@ -78,7 +78,7 @@ files:
|
|
78
78
|
- LICENSE
|
79
79
|
- README.md
|
80
80
|
- bin/check-gossip.rb
|
81
|
-
- bin/metrics-stats.rb
|
81
|
+
- bin/metrics-eventstore-stats-stream.rb
|
82
82
|
- lib/ip-helper.rb
|
83
83
|
homepage: https://github.com/JWroe/sensu-plugins-eventstore
|
84
84
|
licenses:
|