sensu-plugins-edgelab 1.17.0 → 1.18.1

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
  SHA256:
3
- metadata.gz: 02abb4c1626d01a1c9434ab4ad55dba2b1be0c225f7f7a63b8e06d549bbeb17c
4
- data.tar.gz: 6c2593babae5d55aebe767a562fc187e618d72b49b57860f09f89bb84a3db8de
3
+ metadata.gz: 90ad58c337bfc140a58a384094de0053e013f989276d605df2c0d206e2b42319
4
+ data.tar.gz: 930af87547809b07cbbeb7e20febd66d417c4e59de1a0557984991655cb53a83
5
5
  SHA512:
6
- metadata.gz: 45f18be0e7706239fc5444e6c8d55c6fc91252e2eadf080f3e61668a8a13b07a53820025341a39a7cdac528055253b9846b4e4624892c5c6633d6bc38b0bbeae
7
- data.tar.gz: b8cf6b8a55bad75d16fd975926ee3daec82611111ff07b5be9e87b6d44f0b186e35618b6583568817f004ad60165acd54b07c24e80f770b612f852c5b02b6c95
6
+ metadata.gz: c38b0b5b8b50e4c49267eda361587759132ef60354316c6507d4bbc1f480790165acbcd5dd95f60175d77e6b938478cadccb65c038ff414ae1b2c954b2e270e2
7
+ data.tar.gz: cb807edb412c2508606df61f141b9751a6fa1c94d78825e9eeff74e504ca6f1f27b8a8e15506221219aed42edffd16137c8a91f3bc95d68bc9a5720b3920454d
@@ -0,0 +1,97 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metric-postgres-connections
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # This plugin collects postgres connection metrics
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: pg
18
+ #
19
+ # USAGE:
20
+ # ./metric-postgres-connections.rb -u db_user -p db_pass -h db_host -d db
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Copyright (c) 2012 Kwarter, Inc <platforms@kwarter.com>
26
+ # Author Gilles Devaux <gilles.devaux@gmail.com>
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/metric/cli'
32
+ require 'pg'
33
+ require 'socket'
34
+
35
+ class PostgresStatsDBMetrics < Sensu::Plugin::Metric::CLI::Graphite
36
+ option :user,
37
+ description: 'Postgres User',
38
+ short: '-u USER',
39
+ long: '--user USER'
40
+
41
+ option :password,
42
+ description: 'Postgres Password',
43
+ short: '-p PASS',
44
+ long: '--password PASS'
45
+
46
+ option :hostname,
47
+ description: 'Hostname to login to',
48
+ short: '-h HOST',
49
+ long: '--hostname HOST'
50
+
51
+ option :port,
52
+ description: 'Database port',
53
+ short: '-P PORT',
54
+ long: '--port PORT'
55
+
56
+ option :database,
57
+ description: 'Database name',
58
+ short: '-d DB',
59
+ long: '--db DB',
60
+ default: 'postgres'
61
+
62
+ option :scheme,
63
+ description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
64
+ long: '--scheme SCHEME',
65
+ default: "#{Socket.gethostname}.postgresql"
66
+
67
+ option :timeout,
68
+ description: 'Connection timeout (seconds)',
69
+ short: '-T TIMEOUT',
70
+ long: '--timeout TIMEOUT',
71
+ default: nil
72
+
73
+ def run
74
+ timestamp = Time.now.to_i
75
+ conn = PG.connect(host: config[:hostname],
76
+ dbname: config[:database],
77
+ user: config[:user],
78
+ password: config[:password],
79
+ port: config[:port],
80
+ connect_timeout: config[:timeout])
81
+
82
+ # https://www.postgresql.org/docs/10/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
83
+ query = <<END_SQL
84
+ SELECT usename, datname, replace(replace(replace(state, ' ', '_'), '(', ''), ')', '') as state, count(*)
85
+ FROM pg_stat_activity WHERE backend_type = 'client backend'
86
+ GROUP BY usename, datname, state;
87
+ END_SQL
88
+
89
+ conn.exec(query) do |result|
90
+ result.each do |row|
91
+ output "#{config[:scheme]}.connections.#{row['usename']}.#{row['datname']}.#{row['state']}", row['count'], timestamp
92
+ end
93
+ end
94
+
95
+ ok
96
+ end
97
+ end
@@ -0,0 +1,111 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metric-postgres-statsdb
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # This plugin collects postgres database metrics from the pg_stat_database table
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: pg
18
+ #
19
+ # USAGE:
20
+ # ./metric-postgres-statsdb.rb -u db_user -p db_pass -h db_host -d db
21
+ #
22
+ # NOTES:
23
+ # Requires PSQL `track_counts` `track_io_timing` for some metrics enabled
24
+ #
25
+ # LICENSE:
26
+ # Copyright (c) 2012 Kwarter, Inc <platforms@kwarter.com>
27
+ # Author Gilles Devaux <gilles.devaux@gmail.com>
28
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
29
+ # for details.
30
+ #
31
+
32
+ require 'sensu-plugin/metric/cli'
33
+ require 'pg'
34
+ require 'socket'
35
+
36
+ class PostgresStatsDBMetrics < Sensu::Plugin::Metric::CLI::Graphite
37
+ option :user,
38
+ description: 'Postgres User',
39
+ short: '-u USER',
40
+ long: '--user USER'
41
+
42
+ option :password,
43
+ description: 'Postgres Password',
44
+ short: '-p PASS',
45
+ long: '--password PASS'
46
+
47
+ option :hostname,
48
+ description: 'Hostname to login to',
49
+ short: '-h HOST',
50
+ long: '--hostname HOST'
51
+
52
+ option :port,
53
+ description: 'Database port',
54
+ short: '-P PORT',
55
+ long: '--port PORT'
56
+
57
+ option :database,
58
+ description: 'Database to connect on',
59
+ short: '-d DB',
60
+ long: '--db DB',
61
+ default: 'postgres'
62
+
63
+ option :all_databases,
64
+ description: 'Get stats for all the databases instead of only the one we are connected on.',
65
+ short: '-a',
66
+ long: '--all-databases',
67
+ boolean: true,
68
+ default: false
69
+
70
+ option :scheme,
71
+ description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
72
+ long: '--scheme SCHEME',
73
+ default: "#{Socket.gethostname}.postgresql"
74
+
75
+ option :timeout,
76
+ description: 'Connection timeout (seconds)',
77
+ short: '-T TIMEOUT',
78
+ long: '--timeout TIMEOUT',
79
+ default: nil
80
+
81
+ def run
82
+ timestamp = Time.now.to_i
83
+ con = PG.connect(host: config[:hostname],
84
+ dbname: config[:database],
85
+ user: config[:user],
86
+ password: config[:password],
87
+ port: config[:port],
88
+ connect_timeout: config[:timeout])
89
+
90
+ query = 'SELECT datname, * FROM pg_stat_database'
91
+ params = []
92
+ unless config[:all_databases]
93
+ query += ' WHERE datname = $1'
94
+ params.append config[:database]
95
+ end
96
+
97
+ con.exec_params(query, params) do |result|
98
+ result.each do |row|
99
+ database = row['datname']
100
+
101
+ row.each do |key, value|
102
+ next if %w[datid datname stats_reset].include?(key)
103
+
104
+ output "#{config[:scheme]}.statsdb.#{database}.#{key}", value.to_s, timestamp
105
+ end
106
+ end
107
+ end
108
+
109
+ ok
110
+ end
111
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-edgelab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgelab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver
@@ -192,22 +192,38 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 0.49.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: pg
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 0.18.4
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 0.18.4
195
209
  description: Sensu plugins developed by Edgelab
196
210
  email:
197
211
  executables:
198
- - check-apt-expired-keys.rb
212
+ - metrics-alb.rb
213
+ - check-nomad-leader.rb
199
214
  - check-cassandra-nodes.rb
200
- - check-consul-services.rb
201
- - check-elasticsearch-cluster-health.rb
202
215
  - check-logstash-pipeline.rb
203
- - check-nomad-jobs.rb
204
- - check-nomad-leader.rb
205
- - check-swarm-cluster.rb
216
+ - metric-postgres-connections.rb
206
217
  - handler-multi-hipchat.rb
207
- - metrics-alb.rb
208
- - metrics-cassandra-basic.rb
209
218
  - metrics-es-indices.rb
219
+ - check-apt-expired-keys.rb
220
+ - check-elasticsearch-cluster-health.rb
221
+ - check-consul-services.rb
210
222
  - metrics-redis-key-pattern.rb
223
+ - check-swarm-cluster.rb
224
+ - metric-postgres-statsdb.rb
225
+ - metrics-cassandra-basic.rb
226
+ - check-nomad-jobs.rb
211
227
  - metrics-swarm-cluster.rb
212
228
  extensions: []
213
229
  extra_rdoc_files: []
@@ -221,6 +237,8 @@ files:
221
237
  - bin/check-nomad-leader.rb
222
238
  - bin/check-swarm-cluster.rb
223
239
  - bin/handler-multi-hipchat.rb
240
+ - bin/metric-postgres-connections.rb
241
+ - bin/metric-postgres-statsdb.rb
224
242
  - bin/metrics-alb.rb
225
243
  - bin/metrics-cassandra-basic.rb
226
244
  - bin/metrics-es-indices.rb
@@ -245,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
263
  version: '0'
246
264
  requirements: []
247
265
  rubyforge_project:
248
- rubygems_version: 2.7.7
266
+ rubygems_version: 2.7.8
249
267
  signing_key:
250
268
  specification_version: 4
251
269
  summary: Contains Edgelab plugins for Sensu