sensu-plugins-nginx 0.0.6 → 1.0.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +11 -2
- data/README.md +4 -4
- data/bin/metrics-nginx.rb +7 -5
- data/lib/sensu-plugins-nginx/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +5 -7
- metadata.gz.sig +0 -0
- data/bin/nginx-metrics.rb +0 -115
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4929bc899f1b85b16f1568ae7cf81524895b7ee6
|
|
4
|
+
data.tar.gz: 50943d1afac42702f95a50ac2751da88171c3f20
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0acdcb24b8fb792989353206aee966bece39b930c2e6133a9df6259e2813f544d710352773131fb60cb99073ade348e8bdaa76aa0cb4c60de2102c4360644db
|
|
7
|
+
data.tar.gz: 668fa7cccc1096cee779fadd1db308e3f4d7ff9913b4efe9c34f38242ff28ce5ce9e45d641d28439876b33e051ac0014f549762de99425dc485a41762feb25e8
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
[1.0.0] - 2015-12-03
|
|
9
|
+
### Added
|
|
10
|
+
- metrics-nginx.rb: Added default hostname of 'localhost'
|
|
11
|
+
- metrics-nginx.rb: Added usage
|
|
12
|
+
|
|
13
|
+
### Removed
|
|
14
|
+
- Removed nginx-metrics.rb; use metrics-nginx.rb instead
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Update to rubocop 0.32.1
|
|
8
18
|
|
|
9
19
|
## [0.0.6] - 2015-08-04
|
|
10
20
|
### Changed
|
|
@@ -13,7 +23,6 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
|
13
23
|
## [0.0.5] - 2015-07-15
|
|
14
24
|
- bump version due to wrong file name, no code changes
|
|
15
25
|
|
|
16
|
-
|
|
17
26
|
## [0.0.4] - 2015-07-14 **YANKED**
|
|
18
27
|
### Changed
|
|
19
28
|
- updated sensu-plugin gem to 1.2.0
|
data/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
## Sensu-Plugins-nginx
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-nginx)
|
|
4
4
|
[](http://badge.fury.io/rb/sensu-plugins-nginx)
|
|
5
5
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nginx)
|
|
6
6
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nginx)
|
|
7
7
|
[](https://gemnasium.com/sensu-plugins/sensu-plugins-nginx)
|
|
8
|
-
[
|
|
8
|
+
[](https://codeship.com/projects/75658)
|
|
9
9
|
|
|
10
10
|
## Functionality
|
|
11
11
|
|
|
12
|
-
**nginx
|
|
12
|
+
**metrics-nginx**
|
|
13
13
|
|
|
14
14
|
Fetch the nginx status page and convert the response into graphite metrics
|
|
15
15
|
|
|
16
16
|
## Files
|
|
17
|
-
* bin/nginx
|
|
17
|
+
* bin/metrics-nginx.rb
|
|
18
18
|
Get the nginx metrics from the status page url for use with Graphite
|
|
19
19
|
|
|
20
20
|
## Usage
|
data/bin/metrics-nginx.rb
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
# gem: sensu-plugin
|
|
16
16
|
#
|
|
17
17
|
# USAGE:
|
|
18
|
-
#
|
|
18
|
+
# metrics-nginx.rb -h hostname -p port -q status_path
|
|
19
|
+
# metrics-nginx.rb -u http://hostname:port/status_path
|
|
19
20
|
#
|
|
20
21
|
# NOTES:
|
|
21
22
|
#
|
|
@@ -42,10 +43,11 @@ class NginxMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
42
43
|
option :hostname,
|
|
43
44
|
short: '-h HOSTNAME',
|
|
44
45
|
long: '--host HOSTNAME',
|
|
45
|
-
description: 'Nginx hostname'
|
|
46
|
+
description: 'Nginx hostname',
|
|
47
|
+
default: 'localhost'
|
|
46
48
|
|
|
47
49
|
option :port,
|
|
48
|
-
short: '-
|
|
50
|
+
short: '-p PORT',
|
|
49
51
|
long: '--port PORT',
|
|
50
52
|
description: 'Nginx port',
|
|
51
53
|
default: '80'
|
|
@@ -64,7 +66,7 @@ class NginxMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
64
66
|
|
|
65
67
|
# Main function
|
|
66
68
|
#
|
|
67
|
-
def run
|
|
69
|
+
def run
|
|
68
70
|
found = false
|
|
69
71
|
attempts = 0
|
|
70
72
|
until found || attempts >= 10
|
|
@@ -92,7 +94,7 @@ class NginxMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
# #YELLOW
|
|
95
|
-
response.body.split(/\r?\n/).each do |line|
|
|
97
|
+
response.body.split(/\r?\n/).each do |line|
|
|
96
98
|
if line.match(/^Active connections:\s+(\d+)/)
|
|
97
99
|
connections = line.match(/^Active connections:\s+(\d+)/).to_a
|
|
98
100
|
output "#{config[:scheme]}.active_connections", connections[1]
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sensu-plugins-nginx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.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-
|
|
33
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
|
34
34
|
dependencies:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
36
|
name: sensu-plugin
|
|
@@ -150,14 +150,14 @@ dependencies:
|
|
|
150
150
|
requirements:
|
|
151
151
|
- - '='
|
|
152
152
|
- !ruby/object:Gem::Version
|
|
153
|
-
version:
|
|
153
|
+
version: 0.32.1
|
|
154
154
|
type: :development
|
|
155
155
|
prerelease: false
|
|
156
156
|
version_requirements: !ruby/object:Gem::Requirement
|
|
157
157
|
requirements:
|
|
158
158
|
- - '='
|
|
159
159
|
- !ruby/object:Gem::Version
|
|
160
|
-
version:
|
|
160
|
+
version: 0.32.1
|
|
161
161
|
- !ruby/object:Gem::Dependency
|
|
162
162
|
name: yard
|
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -174,10 +174,9 @@ dependencies:
|
|
|
174
174
|
version: '0.8'
|
|
175
175
|
description: |-
|
|
176
176
|
This plugin provides native nginx instrumentation
|
|
177
|
-
for metrics collection, including: metrics via `stub_status
|
|
177
|
+
for metrics collection, including: metrics via `stub_status`.
|
|
178
178
|
email: "<sensu-users@googlegroups.com>"
|
|
179
179
|
executables:
|
|
180
|
-
- nginx-metrics.rb
|
|
181
180
|
- metrics-nginx.rb
|
|
182
181
|
extensions: []
|
|
183
182
|
extra_rdoc_files: []
|
|
@@ -186,7 +185,6 @@ files:
|
|
|
186
185
|
- LICENSE
|
|
187
186
|
- README.md
|
|
188
187
|
- bin/metrics-nginx.rb
|
|
189
|
-
- bin/nginx-metrics.rb
|
|
190
188
|
- lib/sensu-plugins-nginx.rb
|
|
191
189
|
- lib/sensu-plugins-nginx/version.rb
|
|
192
190
|
homepage: https://github.com/sensu-plugins/sensu-plugins-nginx
|
metadata.gz.sig
CHANGED
|
Binary file
|
data/bin/nginx-metrics.rb
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env ruby
|
|
2
|
-
#
|
|
3
|
-
# nginx-metrics
|
|
4
|
-
#
|
|
5
|
-
# DESCRIPTION:
|
|
6
|
-
# Pull nginx metrics for backends through stub status module
|
|
7
|
-
#
|
|
8
|
-
# OUTPUT:
|
|
9
|
-
# metric data
|
|
10
|
-
#
|
|
11
|
-
# PLATFORMS:
|
|
12
|
-
# Linux
|
|
13
|
-
#
|
|
14
|
-
# DEPENDENCIES:
|
|
15
|
-
# gem: sensu-plugin
|
|
16
|
-
#
|
|
17
|
-
# USAGE:
|
|
18
|
-
# #YELLOW
|
|
19
|
-
#
|
|
20
|
-
# NOTES:
|
|
21
|
-
#
|
|
22
|
-
# LICENSE:
|
|
23
|
-
# Copyright 2012 Pete Shima <me@peteshima.com>
|
|
24
|
-
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
|
25
|
-
# for details.
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
require 'sensu-plugin/metric/cli'
|
|
29
|
-
require 'net/https'
|
|
30
|
-
require 'uri'
|
|
31
|
-
require 'socket'
|
|
32
|
-
|
|
33
|
-
#
|
|
34
|
-
# Nginx Metrics
|
|
35
|
-
#
|
|
36
|
-
class NginxMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
37
|
-
option :url,
|
|
38
|
-
short: '-u URL',
|
|
39
|
-
long: '--url URL',
|
|
40
|
-
description: 'Full URL to nginx status page, example: https://yoursite.com/nginx_status This ignores ALL other options EXCEPT --scheme'
|
|
41
|
-
|
|
42
|
-
option :hostname,
|
|
43
|
-
short: '-h HOSTNAME',
|
|
44
|
-
long: '--host HOSTNAME',
|
|
45
|
-
description: 'Nginx hostname'
|
|
46
|
-
|
|
47
|
-
option :port,
|
|
48
|
-
short: '-P PORT',
|
|
49
|
-
long: '--port PORT',
|
|
50
|
-
description: 'Nginx port',
|
|
51
|
-
default: '80'
|
|
52
|
-
|
|
53
|
-
option :path,
|
|
54
|
-
short: '-q STATUSPATH',
|
|
55
|
-
long: '--statspath STATUSPATH',
|
|
56
|
-
description: 'Path to your stub status module',
|
|
57
|
-
default: 'nginx_status'
|
|
58
|
-
|
|
59
|
-
option :scheme,
|
|
60
|
-
description: 'Metric naming scheme, text to prepend to metric',
|
|
61
|
-
short: '-s SCHEME',
|
|
62
|
-
long: '--scheme SCHEME',
|
|
63
|
-
default: "#{Socket.gethostname}.nginx"
|
|
64
|
-
|
|
65
|
-
# Main function
|
|
66
|
-
#
|
|
67
|
-
def run # rubocop:disable all
|
|
68
|
-
found = false
|
|
69
|
-
attempts = 0
|
|
70
|
-
until found || attempts >= 10
|
|
71
|
-
attempts += 1
|
|
72
|
-
if config[:url]
|
|
73
|
-
uri = URI.parse(config[:url])
|
|
74
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
75
|
-
if uri.scheme == 'https'
|
|
76
|
-
http.use_ssl = true
|
|
77
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
78
|
-
end
|
|
79
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
|
80
|
-
response = http.request(request)
|
|
81
|
-
if response.code == '200'
|
|
82
|
-
found = true
|
|
83
|
-
elsif !response.header['location'].nil?
|
|
84
|
-
config[:url] = response.header['location']
|
|
85
|
-
end
|
|
86
|
-
else
|
|
87
|
-
response = Net::HTTP.start(config[:hostname], config[:port]) do |connection|
|
|
88
|
-
request = Net::HTTP::Get.new("/#{config[:path]}")
|
|
89
|
-
connection.request(request)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# #YELLOW
|
|
95
|
-
response.body.split(/\r?\n/).each do |line| # rubocop:disable Style/Next
|
|
96
|
-
if line.match(/^Active connections:\s+(\d+)/)
|
|
97
|
-
connections = line.match(/^Active connections:\s+(\d+)/).to_a
|
|
98
|
-
output "#{config[:scheme]}.active_connections", connections[1]
|
|
99
|
-
end
|
|
100
|
-
if line.match(/^\s+(\d+)\s+(\d+)\s+(\d+)/)
|
|
101
|
-
requests = line.match(/^\s+(\d+)\s+(\d+)\s+(\d+)/).to_a
|
|
102
|
-
output "#{config[:scheme]}.accepts", requests[1]
|
|
103
|
-
output "#{config[:scheme]}.handled", requests[2]
|
|
104
|
-
output "#{config[:scheme]}.requests", requests[3]
|
|
105
|
-
end
|
|
106
|
-
if line.match(/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/)
|
|
107
|
-
queue = line.match(/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/).to_a
|
|
108
|
-
output "#{config[:scheme]}.reading", queue[1]
|
|
109
|
-
output "#{config[:scheme]}.writing", queue[2]
|
|
110
|
-
output "#{config[:scheme]}.waiting", queue[3]
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
ok
|
|
114
|
-
end
|
|
115
|
-
end
|