sensu-plugins-pdns 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/bin/metrics-pdns.rb +42 -3
- data/lib/sensu-plugins-pdns/version.rb +2 -2
- 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: 05e1e1c5734632df327366c589c4e3457d9298c0
|
4
|
+
data.tar.gz: d7601f43eef2cb18d27b8ca8a8cf3d28f00ae465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6004dd6093fe520179a43887d9192f5c239c6f5bb9f75a9f4496b2478321f9c9e599066021eebf764637125a30535b1077318f493f7e2562dd4d86922f1e1cc0
|
7
|
+
data.tar.gz: 7e4062d6a695efc8c37e0e261bf4c51eeaffb306c7522f6f16a2c2a70f7b1719a248a187459fcc84272bd28d071e41751e74266e880b912b45a7976c18724aae
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
## [Unreleased]
|
5
5
|
|
6
|
+
## [0.1.0] - 2017-08-31
|
7
|
+
### Added
|
8
|
+
- Add support to capture more PowerDNS metrics like queries/second (@haashah)
|
9
|
+
|
6
10
|
## 0.0.1 - 2017-08-27
|
7
11
|
### Added
|
8
12
|
- Initial release
|
9
13
|
|
10
14
|
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-pdns/compare/0.0.1...HEAD
|
15
|
+
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-pdns/compare/0.0.1...0.1.0
|
data/README.md
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
## Functionality
|
8
8
|
metrics-pdns.rb - Query PowerDNS for statistics. Record stats as metrics and output in Graphite plaintext format
|
9
9
|
|
10
|
+
Arguments:
|
11
|
+
* --syslog: specify the path to syslog to fetch the extra pdns stats from. default: /var/log/messages
|
12
|
+
* --extra: flag to enable sending of stats collected from syslog. default value is false.
|
13
|
+
|
10
14
|
Details:
|
11
15
|
[PowerDNS statistics](https://doc.powerdns.com/recursor/metrics.html)
|
12
16
|
|
data/bin/metrics-pdns.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
#
|
20
20
|
# NOTES:
|
21
21
|
# Requires sudo permissions for the sensu user to run rec_control
|
22
|
+
# Requires sudo permissions for the sensu user to run tail and pkill commands
|
23
|
+
# when using the extra flag for syslog stats.
|
22
24
|
#
|
23
25
|
# LICENSE:
|
24
26
|
# <Hammad Shah> <haashah@gmail.com>
|
@@ -37,15 +39,52 @@ class PdnsGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
37
39
|
long: '--scheme SCHEME',
|
38
40
|
default: "#{Socket.gethostname}.pdns"
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
option :syslog_path,
|
43
|
+
description: 'Path to the syslog',
|
44
|
+
long: '--syslog SYSLOG',
|
45
|
+
default: '/var/log/messages'
|
46
|
+
|
47
|
+
option :extra_stats,
|
48
|
+
description: 'flag to send stats collected from syslog like qps',
|
49
|
+
boolean: true,
|
50
|
+
short: '-e',
|
51
|
+
long: '--extra',
|
52
|
+
default: false
|
53
|
+
|
54
|
+
def cmd_run(cmd)
|
55
|
+
result = `#{cmd}`.split("\n")
|
42
56
|
if $CHILD_STATUS.exitstatus > 0
|
43
|
-
critical
|
57
|
+
critical "Failed to execute #{cmd}"
|
58
|
+
end
|
59
|
+
result
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_syslog
|
63
|
+
# send signal to pdns process to dump stats
|
64
|
+
cmd_run('sudo pkill -SIGUSR1 pdns_recursor')
|
65
|
+
# parse stats from syslog
|
66
|
+
metrics = cmd_run("sudo tail #{config[:syslog_path]} -n 6 | grep pdns_recursor")
|
67
|
+
return if metrics.nil?
|
68
|
+
metrics.each do |metric|
|
69
|
+
next unless metric.include?('stats:')
|
70
|
+
(_jargon, stats) = metric.split('stats:')
|
71
|
+
keyvalues = stats.split(',')
|
72
|
+
keyvalues.each do |keyvalue|
|
73
|
+
key = keyvalue.strip!.scan(/\D+/)[0].strip
|
74
|
+
key.gsub!(/[()]|\s/, '-')
|
75
|
+
value = keyvalue.scan(/\d+/)[0]
|
76
|
+
output([config[:scheme], key].join('.'), value)
|
77
|
+
end
|
44
78
|
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def run
|
82
|
+
metrics = cmd_run('sudo rec_control get-all')
|
45
83
|
metrics.each do |metric|
|
46
84
|
(key, value) = metric.split("\t")
|
47
85
|
output([config[:scheme], key].join('.'), value)
|
48
86
|
end
|
87
|
+
parse_syslog if config[:extra_stats]
|
49
88
|
ok
|
50
89
|
end
|
51
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-pdns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hammad Shah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.6.
|
178
|
+
rubygems_version: 2.6.11
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Sensu Plugins for PowerDNS metrics
|