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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24ea0535f42625ae71bad8899063a8e1a89e139e
4
- data.tar.gz: 742966426f75029da44ed800b4d4ebf409951781
3
+ metadata.gz: 4b9945073e5d20947fc066c43eaf72dc0a6fa583
4
+ data.tar.gz: 814b97411b40fd7fd1f19b2431ee83c920ad1d05
5
5
  SHA512:
6
- metadata.gz: c4dcc0e4c2e2b34e153d17ce49d31361cf2274ccaa2346b59228c262973ff8c4b5981d200d10f991642e20fd4f48d7ca06b0b7b72d6337b23586508518de77ec
7
- data.tar.gz: ca4c20dd4f919de0378b60f24fcba3825b49d81986e1b8840188c4cfe23c433aad163f0c0c67a58f13939b3a2e9dcb6c80c9ca08eb2b538d30c01e58b6b959b2
6
+ metadata.gz: 3e8f8ab8ea9e795a7a46caed92827402846dbbbad51d6133287062ad8f3b4d746fc344b04706e743b67a8a43282ac111a21e9f5853cac63754d787957254fca1
7
+ data.tar.gz: 16a7be73168efe7943f9fd1484e7271b1e9ce58630c1fd1589214b02669aa37225b6781f8a4777f6124b5876ed367017dff5cffd1d7cdf404539121183109484
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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][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-repo-metrics.rb
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 entring secure items on the commandline. The plugin will continue to be backwards compatible for a period but the ability to specify the token on the commandline will be removed in the **0.1.0** release.
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](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
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
@@ -2,9 +2,9 @@ require 'json'
2
2
 
3
3
  module SensuPluginsGithub
4
4
  module Version
5
- MAJOR = 0
5
+ MAJOR = 1
6
6
  MINOR = 0
7
- PATCH = 5
7
+ PATCH = 0
8
8
 
9
9
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
10
10
  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.5
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-07-14 00:00:00.000000000 Z
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: codeclimate-test-reporter
64
+ name: bundler
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.4'
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: '0.4'
76
+ version: '1.7'
77
77
  - !ruby/object:Gem::Dependency
78
- name: rubocop
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.32.1
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.32.1
90
+ version: '0.4'
91
91
  - !ruby/object:Gem::Dependency
92
- name: rspec
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.1'
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.1'
104
+ version: '1.3'
105
105
  - !ruby/object:Gem::Dependency
106
- name: bundler
106
+ name: pry
107
107
  requirement: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '1.7'
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: '1.7'
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: github-markup
134
+ name: redcarpet
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '1.3'
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: '1.3'
146
+ version: '3.2'
147
147
  - !ruby/object:Gem::Dependency
148
- name: redcarpet
148
+ name: rubocop
149
149
  requirement: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - "~>"
151
+ - - '='
152
152
  - !ruby/object:Gem::Version
153
- version: '3.2'
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: '3.2'
160
+ version: 0.32.1
161
161
  - !ruby/object:Gem::Dependency
162
- name: yard
162
+ name: rspec
163
163
  requirement: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '0.8'
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: '0.8'
174
+ version: '3.1'
175
175
  - !ruby/object:Gem::Dependency
176
- name: pry
176
+ name: yard
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: '0.10'
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.10'
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.6
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
- ^����ɥ�r���6;i���8��m3��wo9�eL�����
2
- rkz>�t7
3
- ��K���(Sx�#3�@��m
1
+ �!��r�[�8�U�!�Z���.OɎѵ�*������W\��9>Z�Ѯ��������c 0/�w˨� b��`ձ�[���=�6��o �X=�m6����`[��K�P
2
+ jcEocw��3�v��ʠ������Ax���1���c=�Vk��i���]��k��s��J��d��Z�팧,���A�Y���n����Tun2O�s-?z�"�s��hx���i2�h�V��