sensu-plugins-graylog 0.1.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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDJlMWM0ODRkODYxOWJmMDlmNjdjYmZjMTgzZGI0NmMwNmQ4YjlmZQ==
5
+ data.tar.gz: !binary |-
6
+ NjRhZDZlNDViZmYyNzZjNDdhNzRlNzUyOTY1ODE3NmY3ZDA0MTk4Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YWQ1MDQ3YWEwMjkwNDdkYzlhNzNlZGVhNWZmMDIyY2U0Njc1YjEyZWY4ZWIy
10
+ NjRjYjI3ZTdiMGYwZDllNjYxNjJmYzEyZDkxZTk5MThiZTNiOWZjZjk3NTA3
11
+ ODY3OTBhZjA4OTIyY2Q3ZDY3ZWYzMGFkMTIwYWZiOGNmM2UzNzk=
12
+ data.tar.gz: !binary |-
13
+ MThlMmY1Yjg3MWRmODg5NjY2NDE2ZDRjNDBmMjA1YTZkODU2ZDczZTQzN2Iz
14
+ ZDU0Yjk2YWU5YmI0MzA5ODhjYThkZjdjODUzNGU3MWIzOTE2YjQ2MzgyYWYw
15
+ NmU4MTQ5ZmYwYTJkOTc0ZDNmNjU2MWNhMDY1Zjk3NTY1ZWQxNjI=
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
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.1.0] - 2016-01-29
9
+ ### Added
10
+ - add new checks for graylog buffers and kafka journal
11
+ - add ruby wrappers for python checks
12
+
13
+ ## [0.0.2] - 2015-07-14
14
+ ### Changed
15
+ - updated sensu-plugin gem to 1.2.0
16
+
17
+ ## 0.0.1 - 2015-06-27
18
+ ### Added
19
+ - initial release
20
+
21
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-graylog/compare/0.1.0...HEAD
22
+ [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-graylog/compare/0.0.2...0.1.0
23
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-graylog/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,22 @@
1
+ ## Sensu-Plugins-graylog
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-graylog.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-graylog)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-graylog.svg)](http://badge.fury.io/rb/sensu-plugins-graylog)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graylog/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graylog)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graylog/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graylog)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-graylog.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-graylog)
8
+
9
+ ## Functionality
10
+
11
+ ## Files
12
+ * bin/check-graylog2-alive.rb
13
+ * bin/check-graylog-buffers.py
14
+ * bin/metrics-graylog.py
15
+
16
+ ## Usage
17
+
18
+ ## Installation
19
+
20
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
21
+
22
+ ## Notes
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env python
2
+
3
+ import urllib2
4
+ import json
5
+ import sys
6
+ import getopt
7
+ import socket
8
+
9
+ def main(argv):
10
+ host = socket.getfqdn()
11
+ user = "graylog2"
12
+ password = "mypass"
13
+ port = "12900"
14
+ warnThreshold = 80.0
15
+ critThreshold = 90.0
16
+ try:
17
+ opts, args = getopt.getopt(argv, "h:u:p:P:w:c:", ["host=","user=","pass=","port=", "warn=", "crit="])
18
+ except getopt.GetoptError:
19
+ print 'flag error'
20
+ sys.exit(2)
21
+ for opt, arg in opts:
22
+ if opt in ("-h", "--host"):
23
+ host = arg
24
+ elif opt in ("-u", "--user"):
25
+ user = arg
26
+ elif opt in ("-p", "--pass"):
27
+ password = arg
28
+ elif opt in ("-P", "--port"):
29
+ port = arg
30
+ elif opt in ("-w", "--warn"):
31
+ warnThreshold = float(arg)
32
+ elif opt in ("-c", "--crit"):
33
+ critThreshold = float(arg)
34
+
35
+ # do stuff
36
+ passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
37
+ passman.add_password(None, 'http://'+ host + ':' + port + '/system/buffers', user, password)
38
+ authhandler = urllib2.HTTPBasicAuthHandler(passman)
39
+ opener = urllib2.build_opener(authhandler)
40
+ urllib2.install_opener(opener)
41
+
42
+ pagehandle = urllib2.urlopen('http://'+ host + ':' + port + '/system/buffers')
43
+ data = json.load(pagehandle)
44
+
45
+ if data['buffers']['process']['utilization_percent'] >= warnThreshold:
46
+ print 'WARNING: process buffer utilization is %.2f%%, threshold is %.2f%%' % (data['buffers']['process']['utilization_percent'], warnThreshold)
47
+ sys.exit(1)
48
+ elif data['buffers']['process']['utilization_percent'] >= critThreshold:
49
+ print 'CRITICAL: process buffer utilization is %.2f%%, threshold is %.2f%%' % (data['buffers']['process']['utilization_percent'], critThreshold)
50
+ sys.exit(2)
51
+ else:
52
+ print 'OK: process buffer utilization is %.2f%%' % data['buffers']['process']['utilization_percent']
53
+ sys.exit(0)
54
+
55
+ if __name__ == "__main__":
56
+ main(sys.argv[1:])
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bin_dir = File.expand_path(File.dirname(__FILE__))
4
+ shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.py')
5
+
6
+ exec shell_script_path, *ARGV
@@ -0,0 +1,98 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ # check-graylog2-alive.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks the the status of the Graylog2 Server using the
7
+ # REST API normally available on port 12900
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: json
18
+ # gem: rest-client
19
+ #
20
+ # USAGE:
21
+ # ./check-graylog2-alive.rb -u admin -p 12345
22
+ #
23
+ # NOTES:
24
+ # This plugin requires a username and password with permission to access
25
+ # the /system API call in the Graylog2 server. A basic non-admin, reader
26
+ # only account will do.
27
+ #
28
+ # LICENSE:
29
+ # Adam Ashley <aashley@adamashley.name>
30
+ # Swift Networks
31
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
32
+ # for details.
33
+ #
34
+
35
+ require 'sensu-plugin/check/cli'
36
+ require 'json'
37
+ require 'rest-client'
38
+
39
+ class CheckGraylog2Alive < Sensu::Plugin::Check::CLI
40
+ option :host,
41
+ description: 'Graylog2 host',
42
+ short: '-h',
43
+ long: '--host HOST',
44
+ default: 'localhost'
45
+
46
+ option :username,
47
+ description: 'Graylog2 username',
48
+ short: '-u',
49
+ long: '--username USERNAME',
50
+ default: 'admin',
51
+ required: true
52
+
53
+ option :password,
54
+ description: 'Graylog2 password',
55
+ short: '-p',
56
+ long: '--password PASSWORD',
57
+ required: true
58
+
59
+ option :port,
60
+ description: 'RabbitMQ API port',
61
+ short: '-P',
62
+ long: '--port PORT',
63
+ default: '12900'
64
+
65
+ def run
66
+ res = vhost_alive?
67
+
68
+ if res['status'] == 'ok'
69
+ ok res['message']
70
+ elsif res['status'] == 'critical'
71
+ critical res['message']
72
+ else
73
+ unknown res['message']
74
+ end
75
+ end
76
+
77
+ def vhost_alive?
78
+ host = config[:host]
79
+ port = config[:port]
80
+ username = config[:username]
81
+ password = config[:password]
82
+
83
+ begin
84
+ resource = RestClient::Resource.new "http://#{host}:#{port}/system", username, password
85
+ # Attempt to parse response (just to trigger parse exception)
86
+ response = JSON.parse(resource.get)
87
+ if response['lifecycle'] == 'running' && response['is_processing'] && response['lb_status'] == 'alive'
88
+ { 'status' => 'ok', 'message' => 'Graylog2 server is alive' }
89
+ else
90
+ { 'status' => 'critical', 'message' => 'Graylog2 server is online but not processing' }
91
+ end
92
+ rescue Errno::ECONNREFUSED => e
93
+ { 'status' => 'critical', 'message' => e.message }
94
+ rescue => e
95
+ { 'status' => 'unknown', 'message' => e.message }
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/python
2
+
3
+ import urllib2
4
+ import json
5
+ import sys
6
+ import getopt
7
+ import socket
8
+ import time
9
+
10
+ def main(argv):
11
+ host = socket.getfqdn()
12
+ user = "graylog2"
13
+ password = "mypass"
14
+ port = "12900"
15
+ try:
16
+ opts, args = getopt.getopt(argv, "h:u:p:P:", ["host=","user=","pass=","port="])
17
+ except getopt.GetoptError:
18
+ print 'flag error'
19
+ sys.exit(2)
20
+ for opt, arg in opts:
21
+ if opt in ("-h", "--host"):
22
+ host = arg
23
+ elif opt in ("-u", "--user"):
24
+ user = arg
25
+ elif opt in ("-p", "--pass"):
26
+ password = arg
27
+ elif opt in ("-P", "--port"):
28
+ port = arg
29
+
30
+ # do stuff
31
+ passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
32
+ passman.add_password(None, 'http://'+ host + ':' + port + '/system/metrics', user, password)
33
+ authhandler = urllib2.HTTPBasicAuthHandler(passman)
34
+ opener = urllib2.build_opener(authhandler)
35
+ urllib2.install_opener(opener)
36
+
37
+ pagehandle = urllib2.urlopen('http://'+ host + ':' + port + '/system/metrics')
38
+ data = json.load(pagehandle)
39
+
40
+ print 'graylog.%s.graylog.kafkajournal.uncommittedMessages %d %d\n' % (host, data['gauges']['org.graylog2.shared.journal.KafkaJournal.uncommittedMessages']['value'], int(time.time()))
41
+ print 'graylog.%s.graylog.kafkajournal.unflushedMessages %d %d\n' % (host, data['gauges']['org.graylog2.shared.journal.KafkaJournal.unflushedMessages']['value'], int(time.time()))
42
+ sys.exit(0)
43
+
44
+ if __name__ == "__main__":
45
+ main(sys.argv[1:])
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bin_dir = File.expand_path(File.dirname(__FILE__))
4
+ shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.py')
5
+
6
+ exec shell_script_path, *ARGV
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-graylog/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsGraylog
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-graylog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-26 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: 1.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github-markup
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '0.37'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.37'
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: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: redcarpet
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '3.2'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '3.2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ description: Sensu graylog plugins
168
+ email: <sensu-users@googlegroups.com>
169
+ executables:
170
+ - check-graylog-buffers.rb
171
+ - check-graylog2-alive.rb
172
+ - metrics-graylog.rb
173
+ extensions: []
174
+ extra_rdoc_files: []
175
+ files:
176
+ - CHANGELOG.md
177
+ - LICENSE
178
+ - README.md
179
+ - bin/check-graylog-buffers.py
180
+ - bin/check-graylog-buffers.rb
181
+ - bin/check-graylog2-alive.rb
182
+ - bin/metrics-graylog.py
183
+ - bin/metrics-graylog.rb
184
+ - lib/sensu-plugins-graylog.rb
185
+ - lib/sensu-plugins-graylog/version.rb
186
+ homepage: https://github.com/sensu-plugins/sensu-plugins-graylog
187
+ licenses:
188
+ - MIT
189
+ metadata:
190
+ maintainer: sensu-plugin
191
+ development_status: active
192
+ production_status: unstable - testing recommended
193
+ release_draft: 'false'
194
+ release_prerelease: 'false'
195
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
196
+ in /etc/default/sensu
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ! '>='
203
+ - !ruby/object:Gem::Version
204
+ version: 1.9.3
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.4.5
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: Sensu plugins for graylog
216
+ test_files: []