sensu-plugins-github 0.0.5 → 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.tar.gz.sig +0 -0
- data/CHANGELOG.md +24 -2
- data/README.md +5 -3
- data/bin/check-github-rate-limit.rb +98 -0
- data/lib/sensu-plugins-github/version.rb +2 -2
- metadata +33 -31
- metadata.gz.sig +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b9945073e5d20947fc066c43eaf72dc0a6fa583
|
4
|
+
data.tar.gz: 814b97411b40fd7fd1f19b2431ee83c920ad1d05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8f8ab8ea9e795a7a46caed92827402846dbbbad51d6133287062ad8f3b4d746fc344b04706e743b67a8a43282ac111a21e9f5853cac63754d787957254fca1
|
7
|
+
data.tar.gz: 16a7be73168efe7943f9fd1484e7271b1e9ce58630c1fd1589214b02669aa37225b6781f8a4777f6124b5876ed367017dff5cffd1d7cdf404539121183109484
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
-
## Unreleased
|
6
|
+
## Unreleased[unreleased]
|
7
|
+
|
8
|
+
## [1.0.0] - 2015-08-14
|
9
|
+
### Added
|
10
|
+
- check-github-rate-limit.rb for checking the rate limit of a user
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- updated documentation urls
|
14
|
+
- general gem cleanup
|
15
|
+
- changed the name of *github-repo-metrics* to *metrics-github-repo* to keep with convention
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- set binstubs to only be created for Ruby binaries
|
7
19
|
|
8
20
|
## [0.0.5] - 2015-07-14
|
9
21
|
### Changed
|
@@ -15,7 +27,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
15
27
|
## [0.0.4] - 2015-06-02
|
16
28
|
|
17
29
|
### Added
|
18
|
-
- check-user-2fa.rb
|
30
|
+
- check-user-2fa.rb
|
19
31
|
- Check to alert upon org users that do not have 2FA enabled
|
20
32
|
|
21
33
|
### Fixed
|
@@ -24,3 +36,13 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
24
36
|
### Changed
|
25
37
|
- removed cruft from /lib
|
26
38
|
|
39
|
+
## [0.0.3] - 2015-04-02
|
40
|
+
## [0.0.2] - 2015-02-12
|
41
|
+
## [0.0.1] - 2015-02-11
|
42
|
+
|
43
|
+
[unreleased]: https://github.com/sensu-plugins/sensu-plugins-github/compare/1.0.0...HEAD
|
44
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-github/compare/0.0.5...1.0.0
|
45
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-github/compare/0.0.4...0.0.5
|
46
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-github/compare/0.0.3...0.0.4
|
47
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-github/compare/0.0.2...0.0.3
|
48
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-github/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -14,14 +14,16 @@
|
|
14
14
|
Interacts with Github API to generate metrics about repo.
|
15
15
|
|
16
16
|
## Files
|
17
|
-
* bin/github-
|
17
|
+
* bin/check-github-rate-limit.rb
|
18
|
+
* bin/check-user-2fa.rb
|
19
|
+
* bin/metrics-github-repo.rb
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
Your github token must be placed in *~/.ssh/git_token*, you should not be
|
23
|
+
Your github token must be placed in *~/.ssh/git_token*, you should not be entering secure items on the commandline.
|
22
24
|
|
23
25
|
## Installation
|
24
26
|
|
25
|
-
[Installation and Setup](
|
27
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
26
28
|
|
27
29
|
## Notes
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-github-rate-llimit.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Interacts with Github API to check the rate limit of a user.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# All
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
# gem: rest-client
|
16
|
+
# gem: json
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2015 Yieldbot, devops@yieldbot.com
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'rest-client'
|
32
|
+
require 'json'
|
33
|
+
|
34
|
+
class CheckUser2FA < Sensu::Plugin::Check::CLI
|
35
|
+
option :api,
|
36
|
+
short: '-a URL',
|
37
|
+
long: '--api URL',
|
38
|
+
description: 'Github API URL'
|
39
|
+
|
40
|
+
option :token,
|
41
|
+
short: '-t TOKEN',
|
42
|
+
long: '--token TOKEN',
|
43
|
+
description: 'Github OAuth Token'
|
44
|
+
|
45
|
+
option :org,
|
46
|
+
short: '-o ORG',
|
47
|
+
long: '--org ORG',
|
48
|
+
description: 'Github Org',
|
49
|
+
required: true
|
50
|
+
|
51
|
+
option :crit_threshold,
|
52
|
+
short: '-c THRESHOLD',
|
53
|
+
long: '--critical THRESHOLD',
|
54
|
+
description: 'GH API request threshold',
|
55
|
+
required: true
|
56
|
+
|
57
|
+
def api_request(resource, api, token)
|
58
|
+
endpoint = api + resource
|
59
|
+
request = RestClient::Resource.new(endpoint, timeout: 30)
|
60
|
+
headers = {}
|
61
|
+
headers[:Authorization] = "token #{token}"
|
62
|
+
JSON.parse(request.get(headers))
|
63
|
+
rescue RestClient::ResourceNotFound
|
64
|
+
warning "Resource not found (or not accessible): #{resource}"
|
65
|
+
rescue Errno::ECONNREFUSED
|
66
|
+
warning 'Connection refused'
|
67
|
+
rescue RestClient::RequestFailed => e
|
68
|
+
warning "Request failed: #{e.inspect}"
|
69
|
+
rescue RestClient::RequestTimeout
|
70
|
+
warning 'Connection timed out'
|
71
|
+
rescue RestClient::Unauthorized
|
72
|
+
warning 'Missing or incorrect Github API credentials'
|
73
|
+
rescue JSON::ParserError
|
74
|
+
warning 'Github API returned invalid JSON'
|
75
|
+
end
|
76
|
+
|
77
|
+
def run
|
78
|
+
# Set the token from the commandline or read it in from a file. Preference
|
79
|
+
# is given towards the later and at some point it may be enforced.
|
80
|
+
token = config[:token] || SensuPluginsGithub::Auth.acquire_git_token
|
81
|
+
|
82
|
+
# This is the default url and will be fine for most people,
|
83
|
+
# github enterprise customers will have a url based upon the org name and
|
84
|
+
# will need to set it at the commandline.
|
85
|
+
api_url = config[:api] || 'https://api.github.com'
|
86
|
+
|
87
|
+
data = api_request('/rate_limit', api_url, token)
|
88
|
+
|
89
|
+
rate_val = 5000 - data['resources']['core']['remaining'].to_i
|
90
|
+
crit_val = config[:crit_threshold].to_i
|
91
|
+
|
92
|
+
if rate_val > 0
|
93
|
+
critical("GH api requests are above #{crit_val} for the last hour") if crit_val > rate_val
|
94
|
+
end
|
95
|
+
|
96
|
+
ok
|
97
|
+
end
|
98
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-github
|
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-08-15 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rest-client
|
@@ -61,61 +61,61 @@ dependencies:
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 1.2.0
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
64
|
+
name: bundler
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '1.7'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '1.7'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
78
|
+
name: codeclimate-test-reporter
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.
|
83
|
+
version: '0.4'
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: '0.4'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
92
|
+
name: github-markup
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '3
|
97
|
+
version: '1.3'
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '3
|
104
|
+
version: '1.3'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
106
|
+
name: pry
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '0.10'
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
118
|
+
version: '0.10'
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: rake
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,72 +131,74 @@ dependencies:
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '10.0'
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
|
-
name:
|
134
|
+
name: redcarpet
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
139
|
+
version: '3.2'
|
140
140
|
type: :development
|
141
141
|
prerelease: false
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
146
|
+
version: '3.2'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
|
-
name:
|
148
|
+
name: rubocop
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
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
|
-
name:
|
162
|
+
name: rspec
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
167
|
+
version: '3.1'
|
168
168
|
type: :development
|
169
169
|
prerelease: false
|
170
170
|
version_requirements: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: '
|
174
|
+
version: '3.1'
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
|
-
name:
|
176
|
+
name: yard
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
179
|
- - "~>"
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: '0.
|
181
|
+
version: '0.8'
|
182
182
|
type: :development
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
186
|
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version: '0.
|
188
|
+
version: '0.8'
|
189
189
|
description: Sensu plugins for Github
|
190
190
|
email: "<sensu-users@googlegroups.com>"
|
191
191
|
executables:
|
192
192
|
- github-repo-metrics.rb
|
193
193
|
- check-user-2fa.rb
|
194
|
+
- check-github-rate-limit.rb
|
194
195
|
extensions: []
|
195
196
|
extra_rdoc_files: []
|
196
197
|
files:
|
197
198
|
- CHANGELOG.md
|
198
199
|
- LICENSE
|
199
200
|
- README.md
|
201
|
+
- bin/check-github-rate-limit.rb
|
200
202
|
- bin/check-user-2fa.rb
|
201
203
|
- bin/github-repo-metrics.rb
|
202
204
|
- lib/sensu-plugins-github.rb
|
@@ -228,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
230
|
version: '0'
|
229
231
|
requirements: []
|
230
232
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.4.
|
233
|
+
rubygems_version: 2.4.8
|
232
234
|
signing_key:
|
233
235
|
specification_version: 4
|
234
236
|
summary: Sensu plugins for Github
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
��K���(Sx�#3�@��m
|
1
|
+
�!��r�[�8�U�!�Z���.OɎѵ�*������W\��9>Z�Ѯ��������c0/�w˨�b��`ձ�[���=�6��o�X=�m6����`[��K�P
|
2
|
+
jc�Eoc�w��3�v��ʠ������Ax���1���c=�Vk��i���]��k��s��J��d��Z�팧,���A�Y���n����Tun2O�s-?z�"�s��hx���i2�h�V��
|