sensu-plugins-elasticsearch 0.3.2 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd1578a35f585df777a0e1c90e333d6d2a5463c
4
- data.tar.gz: b702fb67209f601680305df43988c8085e47e643
3
+ metadata.gz: d7cd67baf0aee4b5113c8168a5ab1497825578e3
4
+ data.tar.gz: f68dcbde8239e84eb7bd7a2ff6a4749a4229ebbd
5
5
  SHA512:
6
- metadata.gz: 46c95cbfb1fa1798a2f42296cd00e105eac50b0a7b1450563dab5296a36a28890bc754e197253e2df924726fb17203c3083cab84de90af2f877b48658ab8d82b
7
- data.tar.gz: 057d2d45e35b9b085958a15186032b3152c4bdf8d80fe6b18bb5f1710cf1b70bb2167eb42df171327be5686f0b71db0f53b32dd1603a4391b0e464049592a935
6
+ metadata.gz: 738b0414e12bf04a69d85a82cf6cb7c01e3183030b850636d2a1181eff66d9786c8a4599b3286b1ed83c1a6524ee63cb2af86505b72b13409255ee719143b61a
7
+ data.tar.gz: 71695dab68c8fea9b76bbabab4d97b532871069eea58eef198dee4c0bc73b893d1dc5b4ee0ac28f26d6435623897318490e498d0fd37fe57dda138eaa9905b4d
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -5,6 +5,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## [0.4.0] - 2016-01-22
9
+ ### Added
10
+ - metrics-es-node-graphite.rb: Added file system and cpu stats
11
+ - metrics-es-cluster.rb: Added cluster metrics including optional percolator metrics, allocation status, and option to run on non-master nodes
12
+
8
13
  ## [0.3.2] - 2015-12-29
9
14
  ### Changed
10
15
  - Update metrics-es-node.rb for Elasticsearch 2.0
@@ -5,7 +5,7 @@
5
5
  # DESCRIPTION:
6
6
  # This plugin uses the ES API to collect metrics, producing a JSON
7
7
  # document which is outputted to STDOUT. An exit status of 0 indicates
8
- # the plugin has successfully collected and produced.
8
+ # the plugin has successfully collected and produced metrics.
9
9
  #
10
10
  # OUTPUT:
11
11
  # metric data
@@ -63,6 +63,18 @@ class ESClusterMetrics < Sensu::Plugin::Metric::CLI::Graphite
63
63
  proc: proc(&:to_i),
64
64
  default: 30
65
65
 
66
+ option :allow_non_master,
67
+ description: 'Allow check to run on non-master nodes',
68
+ short: '-a',
69
+ long: '--allow-non-master',
70
+ default: false
71
+
72
+ option :enable_percolate,
73
+ description: 'Enables percolator stats',
74
+ short: '-o',
75
+ long: '--enable-percolate',
76
+ default: false
77
+
66
78
  option :user,
67
79
  description: 'Elasticsearch User',
68
80
  short: '-u USER',
@@ -113,12 +125,42 @@ class ESClusterMetrics < Sensu::Plugin::Metric::CLI::Graphite
113
125
  document_count['_all']['total']['docs']['count']
114
126
  end
115
127
 
128
+ def acquire_cluster_metrics
129
+ cluster_stats = get_es_resource('/_cluster/stats')
130
+ cluster_metrics = Hash.new { |h, k| h[k] = {} }
131
+ cluster_metrics['fs']['total_in_bytes'] = cluster_stats['nodes']['fs']['total_in_bytes']
132
+ cluster_metrics['fs']['free_in_bytes'] = cluster_stats['nodes']['fs']['free_in_bytes']
133
+ cluster_metrics['fs']['store_in_bytes'] = cluster_stats['indices']['store']['size_in_bytes']
134
+ cluster_metrics['fielddata']['memory_size_in_bytes'] = cluster_stats['indices']['fielddata']['memory_size_in_bytes']
135
+ cluster_metrics['fielddata']['evictions'] = cluster_stats['indices']['fielddata']['evictions']
136
+ cluster_metrics['filter_cache']['memory_size_in_bytes'] = cluster_stats['indices']['filter_cache']['memory_size_in_bytes']
137
+ cluster_metrics['filter_cache']['evictions'] = cluster_stats['indices']['filter_cache']['evictions']
138
+ cluster_metrics['mem'] = cluster_stats['nodes']['jvm']['mem']
139
+ if config[:enable_percolate]
140
+ cluster_metrics['percolate']['total'] = cluster_stats['indices']['percolate']['total']
141
+ cluster_metrics['percolate']['time_in_millis'] = cluster_stats['indices']['percolate']['time_in_millis']
142
+ cluster_metrics['percolate']['queries'] = cluster_stats['indices']['percolate']['queries']
143
+ end
144
+ cluster_metrics
145
+ end
146
+
147
+ def acquire_allocation_status
148
+ cluster_config = get_es_resource('/_cluster/settings')
149
+ %w(none new_primaries primaries all).index(cluster_config['transient']['cluster']['routing']['allocation']['enable'])
150
+ end
151
+
116
152
  def run
117
- if master?
153
+ if config[:allow_non_master] || master?
118
154
  acquire_health.each do |k, v|
119
155
  output(config[:scheme] + '.' + k, v)
120
156
  end
157
+ acquire_cluster_metrics.each do |cluster_metric|
158
+ cluster_metric[1].each do |k, v|
159
+ output(config[:scheme] + '.' + cluster_metric[0] + '.' + k, v)
160
+ end
161
+ end
121
162
  output(config[:scheme] + '.document_count', acquire_document_count)
163
+ output(config[:scheme] + '.allocation_status', acquire_allocation_status)
122
164
  end
123
165
  ok
124
166
  end
@@ -94,6 +94,12 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
94
94
  boolean: true,
95
95
  default: false
96
96
 
97
+ option :disable_fs_stats,
98
+ description: 'Disable filesystem statistics',
99
+ long: '--disable-fs-stats',
100
+ boolean: true,
101
+ default: false
102
+
97
103
  option :user,
98
104
  description: 'Elasticsearch User',
99
105
  short: '-u USER',
@@ -129,6 +135,7 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
129
135
  process_stats = !config[:disable_process_stats]
130
136
  jvm_stats = !config[:disable_jvm_stats]
131
137
  tp_stats = !config[:disable_thread_pool_stats]
138
+ fs_stats = !config[:disable_fs_stats]
132
139
 
133
140
  es_version = Gem::Version.new(acquire_es_version)
134
141
 
@@ -138,6 +145,7 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
138
145
  stats_query_array.push('os') if os_stat == true
139
146
  stats_query_array.push('process') if process_stats == true
140
147
  stats_query_array.push('tp_stats') if tp_stats == true
148
+ stats_query_array.push('fs_stats') if fs_stats == true
141
149
  stats_query_string = stats_query_array.join(',')
142
150
  else
143
151
  stats_query_string = [
@@ -150,7 +158,8 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
150
158
  "process=#{process_stats}",
151
159
  "thread_pool=#{tp_stats}",
152
160
  'transport=true',
153
- 'thread_pool=true'
161
+ 'thread_pool=true',
162
+ "fs=#{fs_stats}"
154
163
  ].join('&')
155
164
  end
156
165
 
@@ -177,6 +186,12 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
177
186
  metrics['os.mem.free_in_bytes'] = node['os']['mem']['free_in_bytes']
178
187
  # ... Process uptime in millis?
179
188
  metrics['os.uptime'] = node['os']['uptime_in_millis'] if node['os']['uptime_in_millis']
189
+
190
+ metrics['os.cpu.sys'] = node['os']['cpu']['sys']
191
+ metrics['os.cpu.user'] = node['os']['cpu']['user']
192
+ metrics['os.cpu.idle'] = node['os']['cpu']['idle']
193
+ metrics['os.cpu.usage'] = node['os']['cpu']['usage']
194
+ metrics['os.cpu.stolen'] = node['os']['cpu']['stolen']
180
195
  end
181
196
 
182
197
  if process_stats
@@ -254,6 +269,16 @@ class ESNodeGraphiteMetrics < Sensu::Plugin::Metric::CLI::Graphite
254
269
  end
255
270
  end
256
271
 
272
+ if fs_stats
273
+ node['fs'].each do |fs, fs_value|
274
+ unless fs =~ /(timestamp|data)/
275
+ fs_value.each do |k, v|
276
+ metrics["fs.#{fs}.#{k}"] = v
277
+ end
278
+ end
279
+ end
280
+ end
281
+
257
282
  metrics.each do |k, v|
258
283
  output([config[:scheme], k].join('.'), v, timestamp)
259
284
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsElasticsearch
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 3
5
- PATCH = 2
4
+ MINOR = 4
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-12-30 00:00:00.000000000 Z
33
+ date: 2016-01-22 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rest-client
metadata.gz.sig CHANGED
Binary file