sensu-plugins-ubiquiti 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a324381378e54512fc11ca6227f8c0bb2090b8fc
4
+ data.tar.gz: 92899680eabfd54dd7f5f2f0ff8befb7af933877
5
+ SHA512:
6
+ metadata.gz: 6c3c0cef0303cade1a0507ee53d0038360b8c0fd94e03203f4300c1680870567ee81cf5b63edeb9103decadbb388adf29e92375c638205a65a99f85bd5a8e8ec
7
+ data.tar.gz: b9dc05d0dd51804d406faf16ba5d68e64dc89ffc74d3fd77e28e35d5cc81de45f385869e6e7e053f80ed5070dbccbfbbc1e3218ddf156bc022482b736f68980b
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## Unreleased
7
+
8
+ 0.0.1 - 08-24-2015
9
+ ### Added
10
+ - initial release of this sensu plugin repo
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,22 @@
1
+ ## Sensu-Plugins-ubiquiti
2
+ [ ![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-ubiquiti.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-ubiquiti)
3
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-ubiquiti.svg)](http://badge.fury.io/rb/sensu-plugins-ubiquiti)
4
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ubiquiti/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ubiquiti)
5
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ubiquiti/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ubiquiti)
6
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-ubiquiti.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-ubiquiti)
7
+ [ ![Codeship Status](https://codeship.com/projects/3031d890-2e9c-0133-9eef-3a2a4d3529b0/status?branch=master)](https://codeship.com/projects/99157)
8
+ ## Functionality
9
+
10
+ **metrics-unifi.rb**
11
+
12
+ Polls metrics from Ubiquiti Networks Unifi wireless controllers
13
+
14
+ ## Files
15
+ * bin/metrics-unifi.rb
16
+ * bin/unifi-get-stats.py
17
+
18
+ ## Installation
19
+
20
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
21
+
22
+ ## Notes
@@ -0,0 +1,79 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metrics-unifi.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin collects metrics from a Unifi wireless controller
7
+ #
8
+ # OUTPUT:
9
+ # metric data
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ #
17
+ # USAGE:
18
+ # metrics-unifi.rb -c unifi.int.mycompany.co -i /dir/containing/unifi-get-stats/binary/ -u admin -p unifipassword
19
+ #
20
+ # NOTES:
21
+ #
22
+ #
23
+ # LICENSE:
24
+ # Copyright Eric Heydrick <eheydrick@gmail.com>
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/metric/cli'
30
+ require 'open3'
31
+ require 'socket'
32
+ require 'json'
33
+
34
+ # Collect unifi metrics
35
+ class UnifiMetrics < Sensu::Plugin::Metric::CLI::Graphite
36
+ option :scheme,
37
+ description: 'Metric naming scheme, text to prepend to metric',
38
+ short: '-s SCHEME',
39
+ long: '--scheme SCHEME',
40
+ default: "#{Socket.gethostname}.unifi"
41
+
42
+ option :controller,
43
+ description: 'Unifi AP controller hostname',
44
+ short: '-c HOSTNAME',
45
+ long: '--controller HOSTNAME',
46
+ default: 'unifi'
47
+
48
+ option :username,
49
+ description: 'Username',
50
+ short: '-u USERNAME',
51
+ long: '--username USERNAME',
52
+ default: 'admin'
53
+
54
+ option :password,
55
+ description: 'Password',
56
+ short: '-p PASSWORD',
57
+ long: '--password PASSWORD',
58
+ required: true
59
+
60
+ option :path,
61
+ description: 'Path to unifi-get-stats.py',
62
+ short: '-i PATH',
63
+ default: '/usr/local/bin'
64
+
65
+ def unifi_stats
66
+ unknown "Could not find #{config[:path]}/unifi-get-stats.py" unless File.exist?("#{config[:path]}/unifi-get-stats.py")
67
+ stdout, result = Open3.capture2("#{config[:path]}/unifi-get-stats.py -c #{config[:controller]} -u #{config[:username]} -p #{config[:password]}")
68
+ unknown 'Unable to get Unifi AP stats' unless result.success?
69
+ stdout
70
+ end
71
+
72
+ def run
73
+ stats = JSON.parse(unifi_stats)
74
+ stats.each do |metric, value|
75
+ output "#{config[:scheme]}.#{metric}", value
76
+ end
77
+ ok
78
+ end
79
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Get stats from a Unifi AP controller using the API
4
+ #
5
+ # Requires the unifi python module
6
+ #
7
+
8
+ import argparse
9
+ import json
10
+
11
+ from unifi.controller import Controller
12
+
13
+ parser = argparse.ArgumentParser()
14
+ parser.add_argument('-c', '--controller', default='unifi', help='the controller address (default "unifi")')
15
+ parser.add_argument('-u', '--username', default='admin', help='the controller username (default("admin")')
16
+ parser.add_argument('-p', '--password', default='', help='the controller password')
17
+ parser.add_argument('-b', '--port', default='8443', help='the controller port (default "8443")')
18
+ parser.add_argument('-v', '--version', default='v2', help='the controller base version (default "v2")')
19
+ parser.add_argument('-s', '--siteid', default='default', help='the site ID, UniFi >=3.x only (default "default")')
20
+ args = parser.parse_args()
21
+
22
+ c = Controller(args.controller, args.username, args.password, args.port, args.version, args.siteid)
23
+
24
+ aps = c.get_aps()
25
+
26
+ total = guests = users = 0
27
+
28
+ for ap in aps:
29
+ total += ap['num_sta']
30
+ guests += ap['guest-num_sta']
31
+ users += ap['user-num_sta']
32
+
33
+ stats = {'total': total, 'guests': guests, 'users': users}
34
+
35
+ print json.dumps(stats)
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-ubiquiti/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsUbiquiti
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-ubiquiti
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_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
28
+ UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
29
+ JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
30
+ 8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
+ HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
+ -----END CERTIFICATE-----
33
+ date: 2015-08-27 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sensu-plugin
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.2.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.2.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.7'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.7'
63
+ - !ruby/object:Gem::Dependency
64
+ name: codeclimate-test-reporter
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.4'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.4'
77
+ - !ruby/object:Gem::Dependency
78
+ name: github-markup
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.3'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.3'
91
+ - !ruby/object:Gem::Dependency
92
+ name: pry
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.10'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.10'
105
+ - !ruby/object:Gem::Dependency
106
+ name: rake
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '10.0'
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '10.0'
119
+ - !ruby/object:Gem::Dependency
120
+ name: redcarpet
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '3.2'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.2'
133
+ - !ruby/object:Gem::Dependency
134
+ name: rspec
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.1'
140
+ type: :development
141
+ prerelease: false
142
+ version_requirements: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '3.1'
147
+ - !ruby/object:Gem::Dependency
148
+ name: rubocop
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - '='
152
+ - !ruby/object:Gem::Version
153
+ version: 0.32.1
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '='
159
+ - !ruby/object:Gem::Version
160
+ version: 0.32.1
161
+ - !ruby/object:Gem::Dependency
162
+ name: yard
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.8'
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0.8'
175
+ description: Sensu plugins for Ubiquiti network equipment
176
+ email: "<sensu-users@googlegroubiquiti.com>"
177
+ executables:
178
+ - metrics-unifi.rb
179
+ extensions: []
180
+ extra_rdoc_files: []
181
+ files:
182
+ - CHANGELOG.md
183
+ - LICENSE
184
+ - README.md
185
+ - bin/metrics-unifi.rb
186
+ - bin/unifi-get-stats.py
187
+ - lib/sensu-plugins-ubiquiti.rb
188
+ - lib/sensu-plugins-ubiquiti/version.rb
189
+ homepage: https://github.com/sensu-plugins/sensu-plugins-ubiquiti
190
+ licenses:
191
+ - MIT
192
+ metadata:
193
+ maintainer: "@tas50"
194
+ development_status: active
195
+ production_status: unstable - testing recommended
196
+ release_draft: 'false'
197
+ release_prerelease: 'false'
198
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
199
+ in /etc/default/sensu
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: 1.9.3
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ requirements: []
214
+ rubyforge_project:
215
+ rubygems_version: 2.4.8
216
+ signing_key:
217
+ specification_version: 4
218
+ summary: Sensu plugins for Ubiquiti network equipment
219
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ jd�m�so�ҥK�t"F�1�� 7n#��<�7y�ֿ�HtG����2W4�n �. J�m7Ě��3>�P�+�������T��ϛ(?`�xp�Ũ ����6G+�Ū��M0��%�뭢f�a�T���"��퟇!���tCQ���'Y���EL�T}�ˑۮ赙!*ɞ�uTO+��pDi�E�H��C��"-�w�����)-\9���(6��F�����~P�`�`�٩ޅ:]"�Y��� d@Y�,_/�U|���C�