sensu-plugins-nginx-jw 3.1.2
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 +7 -0
- data/CHANGELOG.md +127 -0
- data/LICENSE +22 -0
- data/README.md +33 -0
- data/bin/check-nginx-status.rb +142 -0
- data/bin/metrics-nginx.rb +132 -0
- data/lib/sensu-plugins-nginx/version.rb +11 -0
- data/lib/sensu-plugins-nginx.rb +3 -0
- metadata +199 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6962c53b7d35817e019f2058f9b87f8aa6d5f499840038106d0bc8d03459ab68
|
|
4
|
+
data.tar.gz: 4b2fd8454be47a05f984207f45e4b6575df5c217f89b0fa89d559ef10d76cd95
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5aea744eefa720c561af9876cc42e3dbd27d823b9e5331f4fc4aa1332f53b40dce7e7e08d87ac06216dc124168fd878940359c1078a3408041edaa3c78617f8c
|
|
7
|
+
data.tar.gz: 8dbd92692f0eff1b166b5f7fcf2f3f86b9d5cdb0ff8893d18badd3408b4cdf203b30851a13ec33ca9b884682f739f5e9c938032c8cb49f0d7a33f90a94b73cda
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
|
+
|
|
4
|
+
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [3.1.2] - 2020-04-03
|
|
9
|
+
### Changed
|
|
10
|
+
- Removed bare centos build from bonsai definition
|
|
11
|
+
|
|
12
|
+
## [3.1.1] - 2020-04-03
|
|
13
|
+
### Changed
|
|
14
|
+
- Fixed travis build
|
|
15
|
+
|
|
16
|
+
## [3.1.0] - 2020-04-03
|
|
17
|
+
### Changed
|
|
18
|
+
- Updated rubocop rubocop requirement from ~> 0.51.0 to ~> 0.81.0
|
|
19
|
+
- Remediated rubocop warnings
|
|
20
|
+
- Updated bundler requirement from ~> 1.7 to ~> 2.1
|
|
21
|
+
- Updated rake requirement from ~> 10.0 to ~> 13.0
|
|
22
|
+
- Updated codeclimate-test-reporter requirement from ~> 0.4 to ~> 1.0
|
|
23
|
+
|
|
24
|
+
## [3.0.0] - 2019-09-16
|
|
25
|
+
### Breaking Changes
|
|
26
|
+
- Bump `sensu-plugin` dependency from `~> 1.2` to `~> 4.0` you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17), [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04), and [2.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29)
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- Travis build automation to generate Sensu Asset tarballs that can be used n conjunction with Sensu provided ruby runtime assets and the Bonsai Asset Index
|
|
30
|
+
- Require latest sensu-plugin for [Sensu Go support](https://github.com/sensu-plugins/sensu-plugin#sensu-go-enablement)
|
|
31
|
+
|
|
32
|
+
## [2.2.3] - 2018-10-01
|
|
33
|
+
### Fixed
|
|
34
|
+
- `check-nginx-status.rb`: Fixed usage of hostheader without setting url
|
|
35
|
+
|
|
36
|
+
## [2.2.2] - 2018-03-28
|
|
37
|
+
### Security
|
|
38
|
+
- updated yard dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 (@majormoses)
|
|
39
|
+
|
|
40
|
+
## [2.2.1] - 2018-03-17
|
|
41
|
+
### Security
|
|
42
|
+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
- misc typos (@majormoses)
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
- uipdated Changelog guidelines location (@majormoses)
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
- ruby 2.4 testing (@majormoses)
|
|
52
|
+
|
|
53
|
+
### [2.2.0] - 2017-07-02
|
|
54
|
+
## Added
|
|
55
|
+
- add jwt token support (@Ishahar)
|
|
56
|
+
|
|
57
|
+
## [2.1.0] - 2017-02-28
|
|
58
|
+
### Added
|
|
59
|
+
- add `check-nginx-status` plugin (@hany)
|
|
60
|
+
|
|
61
|
+
## [2.0.0] - 2016-05-24
|
|
62
|
+
### Changed
|
|
63
|
+
- remove support for rubies < 2.0
|
|
64
|
+
- update to rubocop 0.40 and cleanup
|
|
65
|
+
|
|
66
|
+
### Added
|
|
67
|
+
- ability to specify custom host header values
|
|
68
|
+
|
|
69
|
+
## [1.0.0] - 2015-12-03
|
|
70
|
+
### Added
|
|
71
|
+
- metrics-nginx.rb: Added default hostname of 'localhost'
|
|
72
|
+
- metrics-nginx.rb: Added usage
|
|
73
|
+
|
|
74
|
+
### Removed
|
|
75
|
+
- Removed nginx-metrics.rb; use metrics-nginx.rb instead
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
- Update to rubocop 0.32.1
|
|
79
|
+
|
|
80
|
+
## [0.0.6] - 2015-08-04
|
|
81
|
+
### Changed
|
|
82
|
+
- add gem description
|
|
83
|
+
|
|
84
|
+
## [0.0.5] - 2015-07-15
|
|
85
|
+
- bump version due to wrong file name, no code changes
|
|
86
|
+
|
|
87
|
+
## [0.0.4] - 2015-07-14 **YANKED**
|
|
88
|
+
### Changed
|
|
89
|
+
- updated sensu-plugin gem to 1.2.0
|
|
90
|
+
|
|
91
|
+
## [0.0.3] - 2015-06-10 **YANKED**
|
|
92
|
+
### Changed
|
|
93
|
+
- changed the name of nginx-metrics.rb to metrics-nginx.rb to conform to std naming
|
|
94
|
+
- nginx-metrics.rb is now depericiated and will be removed in a future release
|
|
95
|
+
- clean Rakefile
|
|
96
|
+
- put gem deps in alpha order in gemspec
|
|
97
|
+
- update doc links in README and CONTRIBUTING
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
- add binstubs for ruby files only
|
|
101
|
+
|
|
102
|
+
## [0.0.2] - 2015-06-03 **YANKED**
|
|
103
|
+
### Fixed
|
|
104
|
+
- added binstubs
|
|
105
|
+
|
|
106
|
+
### Changed
|
|
107
|
+
- removed cruft from /lib
|
|
108
|
+
|
|
109
|
+
## 0.0.1 - 2015-02-11 **YANKED**
|
|
110
|
+
- initial stable release
|
|
111
|
+
|
|
112
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/3.1.1...HEAD
|
|
113
|
+
[3.1.1]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/3.1.0...3.1.1
|
|
114
|
+
[3.1.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/3.0.0...3.1.0
|
|
115
|
+
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.2.3...3.0.0
|
|
116
|
+
[2.2.3]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.2.2...2.2.3
|
|
117
|
+
[2.2.2]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.2.1...2.2.2
|
|
118
|
+
[2.2.1]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.2.0...2.2.1
|
|
119
|
+
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.1.0...2.2.0
|
|
120
|
+
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/2.0.0...2.1.0
|
|
121
|
+
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/1.0.0...2.0.0
|
|
122
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.6...1.0.0
|
|
123
|
+
[0.0.6]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.5...0.0.6
|
|
124
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.4...0.0.5
|
|
125
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.3...0.0.4
|
|
126
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.2...0.0.3
|
|
127
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-nginx/compare/0.0.1...0.0.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 Sensu-Plugins
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## Sensu-Plugins-nginx
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-nginx)
|
|
4
|
+
[](http://badge.fury.io/rb/sensu-plugins-nginx)
|
|
5
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nginx)
|
|
6
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nginx)
|
|
7
|
+
[](https://gemnasium.com/sensu-plugins/sensu-plugins-nginx)
|
|
8
|
+
[](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-nginx)
|
|
9
|
+
|
|
10
|
+
## Sensu Asset
|
|
11
|
+
The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator or handler), make sure you include the corresponding Sensu Ruby runtime asset in the list of assets needed by the resource. The current ruby-runtime assets can be found [here](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the [Bonsai Asset Index](bonsai.sensu.io).
|
|
12
|
+
|
|
13
|
+
## Functionality
|
|
14
|
+
|
|
15
|
+
**metrics-nginx**
|
|
16
|
+
|
|
17
|
+
Fetch the nginx status page and convert the response into metrics
|
|
18
|
+
|
|
19
|
+
**check-nginx-status**
|
|
20
|
+
|
|
21
|
+
Check nginx statistics
|
|
22
|
+
|
|
23
|
+
## Files
|
|
24
|
+
* bin/metrics-nginx.rb
|
|
25
|
+
* bin/check-nginx-status.rb
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
|
32
|
+
|
|
33
|
+
## Notes
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# check-nginx-status
|
|
6
|
+
#
|
|
7
|
+
# DESCRIPTION:
|
|
8
|
+
# Sensu Check that fetches Nginx Status
|
|
9
|
+
#
|
|
10
|
+
# OUTPUT:
|
|
11
|
+
# plain text
|
|
12
|
+
#
|
|
13
|
+
# PLATFORMS:
|
|
14
|
+
# Linux
|
|
15
|
+
#
|
|
16
|
+
# DEPENDENCIES:
|
|
17
|
+
# gem: sensu-plugin
|
|
18
|
+
#
|
|
19
|
+
# USAGE:
|
|
20
|
+
# You need to enable nginx status
|
|
21
|
+
# https://easyengine.io/tutorials/nginx/status-page/
|
|
22
|
+
# check-nginx-status.rb --help
|
|
23
|
+
#
|
|
24
|
+
# NOTES:
|
|
25
|
+
#
|
|
26
|
+
# LICENSE:
|
|
27
|
+
# Adapted from official metrics-nginx plugin (Pete Shima <me@peteshima.com>)
|
|
28
|
+
# Magic Online http://www.magic.fr @2016 - hanynowsky@gmail.com
|
|
29
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE for details.
|
|
30
|
+
# Last Modified October 2016
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
require 'net/https'
|
|
34
|
+
require 'uri'
|
|
35
|
+
require 'socket'
|
|
36
|
+
require 'sensu-plugin/check/cli'
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Nginx Status Check
|
|
40
|
+
#
|
|
41
|
+
class CheckNginxStatus < Sensu::Plugin::Check::CLI
|
|
42
|
+
option :url,
|
|
43
|
+
short: '-u URL',
|
|
44
|
+
long: '--url URL',
|
|
45
|
+
description: 'Full URL to nginx status page, example: https://yoursite.com/nginx_status This ignores ALL other options'
|
|
46
|
+
|
|
47
|
+
option :hostname,
|
|
48
|
+
short: '-h HOSTNAME',
|
|
49
|
+
long: '--host HOSTNAME', description: 'Nginx hostname', default: 'localhost'
|
|
50
|
+
|
|
51
|
+
option :port,
|
|
52
|
+
short: '-p PORT',
|
|
53
|
+
long: '--port PORT',
|
|
54
|
+
description: 'Nginx port',
|
|
55
|
+
default: '80'
|
|
56
|
+
|
|
57
|
+
option :activecon,
|
|
58
|
+
short: '-a ACTIVE_CONNECTION_THRESHOLD',
|
|
59
|
+
long: '--activecon ACTIVE_CONNECTION_THRESHOLD',
|
|
60
|
+
description: 'Active connections threshold',
|
|
61
|
+
default: 300
|
|
62
|
+
|
|
63
|
+
option :waitingreq,
|
|
64
|
+
short: '-w WAITING_REQUESTS_THRESHOLD',
|
|
65
|
+
long: '--waitingreq WAITING_REQUESTS_THRESHOLD',
|
|
66
|
+
description: 'Waiting requests threshold',
|
|
67
|
+
default: 30
|
|
68
|
+
|
|
69
|
+
option :path,
|
|
70
|
+
short: '-q STATUSPATH',
|
|
71
|
+
long: '--statspath STATUSPATH',
|
|
72
|
+
description: 'Path to your stub status module',
|
|
73
|
+
default: 'nginx_status'
|
|
74
|
+
|
|
75
|
+
option :hostheader,
|
|
76
|
+
long: '--hostheader HOSTHEADER',
|
|
77
|
+
description: 'Set the Host header to this string'
|
|
78
|
+
|
|
79
|
+
#
|
|
80
|
+
# Acquire Nginx Status
|
|
81
|
+
#
|
|
82
|
+
def statutor
|
|
83
|
+
found = false
|
|
84
|
+
attempts = 0
|
|
85
|
+
begin
|
|
86
|
+
until found || attempts >= 10
|
|
87
|
+
attempts += 1
|
|
88
|
+
if config[:url]
|
|
89
|
+
uri = URI.parse(config[:url])
|
|
90
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
91
|
+
if uri.scheme == 'https'
|
|
92
|
+
http.use_ssl = true
|
|
93
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
94
|
+
end
|
|
95
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
96
|
+
if config[:hostheader]
|
|
97
|
+
request['Host'] = config[:hostheader]
|
|
98
|
+
end
|
|
99
|
+
response = http.request(request)
|
|
100
|
+
if response.code == '200'
|
|
101
|
+
found = true
|
|
102
|
+
elsif !response.header['location'].nil?
|
|
103
|
+
config[:url] = response.header['location']
|
|
104
|
+
end
|
|
105
|
+
else
|
|
106
|
+
response = Net::HTTP.start(config[:hostname], config[:port]) do |connection|
|
|
107
|
+
request = Net::HTTP::Get.new("/#{config[:path]}")
|
|
108
|
+
request['Host'] = config[:hostheader] if config[:hostheader]
|
|
109
|
+
connection.request(request)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
return response
|
|
113
|
+
end
|
|
114
|
+
rescue StandardError => e
|
|
115
|
+
unknown "Could not fetch Nginx status | #{e.message}"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
# Main function
|
|
121
|
+
#
|
|
122
|
+
def run
|
|
123
|
+
code = statutor
|
|
124
|
+
#### Metrics
|
|
125
|
+
code.body.split(/\r?\n/).each do |line|
|
|
126
|
+
if line =~ /^Active connections:\s+(\d+)/
|
|
127
|
+
connections = line.match(/^Active connections:\s+(\d+)/).to_a
|
|
128
|
+
if connections[1].to_i > config[:activecon].to_i
|
|
129
|
+
warning "Active connections: #{connections[1]}"
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
if line =~ /^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/
|
|
133
|
+
queue = line.match(/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/).to_a
|
|
134
|
+
warning "Waiting requests: #{queue[3]}" if queue[3].to_i > config[:waitingreq].to_i
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
#####
|
|
138
|
+
ok 'Nginx is Alive and healthy' if code.code.to_i == 200
|
|
139
|
+
warning 'Nginx Status endpoint is mis-configured' if code.code.to_i == 301
|
|
140
|
+
critical 'Nginx is Down'
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# nginx-metrics
|
|
6
|
+
#
|
|
7
|
+
# DESCRIPTION:
|
|
8
|
+
# Pull nginx metrics for backends through stub status module
|
|
9
|
+
#
|
|
10
|
+
# OUTPUT:
|
|
11
|
+
# metric data
|
|
12
|
+
#
|
|
13
|
+
# PLATFORMS:
|
|
14
|
+
# Linux
|
|
15
|
+
#
|
|
16
|
+
# DEPENDENCIES:
|
|
17
|
+
# gem: sensu-plugin
|
|
18
|
+
#
|
|
19
|
+
# USAGE:
|
|
20
|
+
# metrics-nginx.rb -h hostname -p port -q status_path
|
|
21
|
+
# metrics-nginx.rb -u http://hostname:port/status_path
|
|
22
|
+
#
|
|
23
|
+
# NOTES:
|
|
24
|
+
#
|
|
25
|
+
# LICENSE:
|
|
26
|
+
# Copyright 2012 Pete Shima <me@peteshima.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 'net/https'
|
|
33
|
+
require 'uri'
|
|
34
|
+
require 'socket'
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Nginx Metrics
|
|
38
|
+
#
|
|
39
|
+
class NginxMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
40
|
+
option :url,
|
|
41
|
+
short: '-u URL',
|
|
42
|
+
long: '--url URL',
|
|
43
|
+
description: 'Full URL to nginx status page, example: https://yoursite.com/nginx_status This ignores ALL other options EXCEPT --scheme'
|
|
44
|
+
|
|
45
|
+
option :hostname,
|
|
46
|
+
short: '-h HOSTNAME',
|
|
47
|
+
long: '--host HOSTNAME',
|
|
48
|
+
description: 'Nginx hostname',
|
|
49
|
+
default: 'localhost'
|
|
50
|
+
|
|
51
|
+
option :port,
|
|
52
|
+
short: '-p PORT',
|
|
53
|
+
long: '--port PORT',
|
|
54
|
+
description: 'Nginx port',
|
|
55
|
+
default: '80'
|
|
56
|
+
|
|
57
|
+
option :path,
|
|
58
|
+
short: '-q STATUSPATH',
|
|
59
|
+
long: '--statspath STATUSPATH',
|
|
60
|
+
description: 'Path to your stub status module',
|
|
61
|
+
default: 'nginx_status'
|
|
62
|
+
|
|
63
|
+
option :hostheader,
|
|
64
|
+
long: '--hostheader HOSTHEADER',
|
|
65
|
+
description: 'Set the Host header to this string'
|
|
66
|
+
option :token,
|
|
67
|
+
long: '--token token',
|
|
68
|
+
description: 'JWT Token'
|
|
69
|
+
|
|
70
|
+
option :scheme,
|
|
71
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
|
72
|
+
short: '-s SCHEME',
|
|
73
|
+
long: '--scheme SCHEME',
|
|
74
|
+
default: "#{Socket.gethostname}.nginx"
|
|
75
|
+
|
|
76
|
+
# Main function
|
|
77
|
+
#
|
|
78
|
+
def run
|
|
79
|
+
found = false
|
|
80
|
+
attempts = 0
|
|
81
|
+
until found || attempts >= 10
|
|
82
|
+
attempts += 1
|
|
83
|
+
if config[:url]
|
|
84
|
+
uri = URI.parse(config[:url])
|
|
85
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
86
|
+
if uri.scheme == 'https'
|
|
87
|
+
http.use_ssl = true
|
|
88
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
89
|
+
end
|
|
90
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
91
|
+
if config[:hostheader]
|
|
92
|
+
request['Host'] = config[:hostheader]
|
|
93
|
+
end
|
|
94
|
+
if config[:token]
|
|
95
|
+
request['Authorization'] = "Bearer #{config[:token]}"
|
|
96
|
+
end
|
|
97
|
+
response = http.request(request)
|
|
98
|
+
else
|
|
99
|
+
response = Net::HTTP.start(config[:hostname], config[:port]) do |connection|
|
|
100
|
+
request = Net::HTTP::Get.new("/#{config[:path]}")
|
|
101
|
+
connection.request(request)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
if response.code == '200'
|
|
105
|
+
found = true
|
|
106
|
+
elsif !response.header['location'].nil?
|
|
107
|
+
config[:url] = response.header['location']
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# #YELLOW
|
|
112
|
+
response.body.split(/\r?\n/).each do |line|
|
|
113
|
+
if line =~ /^Active connections:\s+(\d+)/
|
|
114
|
+
connections = line.match(/^Active connections:\s+(\d+)/).to_a
|
|
115
|
+
output "#{config[:scheme]}.active_connections", connections[1]
|
|
116
|
+
end
|
|
117
|
+
if line =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/
|
|
118
|
+
requests = line.match(/^\s+(\d+)\s+(\d+)\s+(\d+)/).to_a
|
|
119
|
+
output "#{config[:scheme]}.accepts", requests[1]
|
|
120
|
+
output "#{config[:scheme]}.handled", requests[2]
|
|
121
|
+
output "#{config[:scheme]}.requests", requests[3]
|
|
122
|
+
end
|
|
123
|
+
if line =~ /^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/
|
|
124
|
+
queue = line.match(/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/).to_a
|
|
125
|
+
output "#{config[:scheme]}.reading", queue[1]
|
|
126
|
+
output "#{config[:scheme]}.writing", queue[2]
|
|
127
|
+
output "#{config[:scheme]}.waiting", queue[3]
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
ok
|
|
131
|
+
end
|
|
132
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sensu-plugins-nginx-jw
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 3.1.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sensu-Plugins and contributors
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: sensu-plugin
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '4.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '4.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.1'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.1'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: codeclimate-test-reporter
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: github-markup
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '4.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '4.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.10'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.10'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rake
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '13.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '13.0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: redcarpet
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3.2'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '3.2'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rspec
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '3.1'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '3.1'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rubocop
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.81.0
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 0.81.0
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: yard
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: 0.9.11
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 0.9.11
|
|
153
|
+
description: |-
|
|
154
|
+
This plugin provides native nginx instrumentation
|
|
155
|
+
for metrics collection, including: metrics via `stub_status`.
|
|
156
|
+
email: "<sensu-users@googlegroups.com>"
|
|
157
|
+
executables:
|
|
158
|
+
- check-nginx-status.rb
|
|
159
|
+
- metrics-nginx.rb
|
|
160
|
+
extensions: []
|
|
161
|
+
extra_rdoc_files: []
|
|
162
|
+
files:
|
|
163
|
+
- CHANGELOG.md
|
|
164
|
+
- LICENSE
|
|
165
|
+
- README.md
|
|
166
|
+
- bin/check-nginx-status.rb
|
|
167
|
+
- bin/metrics-nginx.rb
|
|
168
|
+
- lib/sensu-plugins-nginx.rb
|
|
169
|
+
- lib/sensu-plugins-nginx/version.rb
|
|
170
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-nginx
|
|
171
|
+
licenses:
|
|
172
|
+
- MIT
|
|
173
|
+
metadata:
|
|
174
|
+
maintainer: "@mattyjones"
|
|
175
|
+
development_status: active
|
|
176
|
+
production_status: unstable - testing recommended
|
|
177
|
+
release_draft: 'false'
|
|
178
|
+
release_prerelease: 'false'
|
|
179
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
|
180
|
+
in /etc/default/sensu
|
|
181
|
+
rdoc_options: []
|
|
182
|
+
require_paths:
|
|
183
|
+
- lib
|
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
|
+
requirements:
|
|
186
|
+
- - ">="
|
|
187
|
+
- !ruby/object:Gem::Version
|
|
188
|
+
version: 2.3.0
|
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
+
requirements:
|
|
191
|
+
- - ">="
|
|
192
|
+
- !ruby/object:Gem::Version
|
|
193
|
+
version: '0'
|
|
194
|
+
requirements: []
|
|
195
|
+
rubygems_version: 3.4.10
|
|
196
|
+
signing_key:
|
|
197
|
+
specification_version: 4
|
|
198
|
+
summary: Sensu plugins for the NGINX server
|
|
199
|
+
test_files: []
|