megaraid-collectd 0.5.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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in megaraid-collectd.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Pierre-Yves Ritschard
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,23 @@
1
+ # Megaraid::Collectd
2
+
3
+ Simple gem which provides a long-running process
4
+ to help collectd graph megaraid status.
5
+
6
+ This relies on the command `megaclisas-status` being
7
+ available
8
+
9
+ ## Installation
10
+
11
+ Install it yourself as:
12
+
13
+ $ gem install megaraid-collectd
14
+
15
+ ## Usage
16
+
17
+ Drop the following in your collectd configuration:
18
+
19
+ ```
20
+ <Plugin exec>
21
+ Exec "root:root" "megaraid-collectd.rb"
22
+ </Plugin>
23
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../../lib', __FILE__)
3
+ $:.unshift(lib) unless $:.include?(lib)
4
+
5
+ require 'rubygems'
6
+ require 'megaraid-collectd'
7
+
8
+ checker = Megaraid::Collectd::Check.new
9
+ checker.run
@@ -0,0 +1,5 @@
1
+ module Megaraid
2
+ module Collectd
3
+ VERSION = "0.5.0"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ require "megaraid-collectd/version"
2
+
3
+ module Megaraid
4
+ module Collectd
5
+ DEFAULT_INTERVAL = 900 # poll every 15 minute by default
6
+ DEFAULT_HOSTNAME = `hostname`.chomp
7
+ class Check
8
+ def initialize hostname=nil, interval=nil
9
+ @hostname = hostname || DEFAULT_HOSTNAME
10
+ @interval = interval || DEFAULT_INTERVAL
11
+ @interval = interval.to_i
12
+ end
13
+
14
+ def run
15
+ while true
16
+ init_stamp = Time.now.to_i
17
+ if `megaclisas-status --nagios` =~ /^RAID ([a-zA-Z]+) - Arrays: OK:(\d+) Bad:(\d+) - Disks: OK:(\d+) Bad:(\d+)/
18
+ array_ok = $2
19
+ array_bad = $3
20
+ disk_ok = $4
21
+ disk_bad = $5
22
+
23
+ puts "PUTVAL \"#{@hostname}/megaraid/gauge-array_ok\" interval=#{interval} N:#{array_ok}"
24
+ puts "PUTVAL \"#{@hostname}/megaraid/gauge-array_bad\" interval=#{interval} N:#{array_bad}"
25
+ puts "PUTVAL \"#{hostname}/megaraid/gauge-disk_ok\" interval=#{interval} N:#{disk_ok}"
26
+ puts "PUTVAL \"#{hostname}/megaraid/gauge-disk_bad\" interval=#{interval} N:#{disk_bad}"
27
+ end
28
+ end_stamp = Time.now.to_i
29
+
30
+ waitfor = @interval - (end_stamp - init_stamp)
31
+ sleep waitfor if waitfor > 0
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'megaraid-collectd/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "megaraid-collectd"
8
+ gem.version = Megaraid::Collectd::VERSION
9
+ gem.authors = ["Pierre-Yves Ritschard"]
10
+ gem.email = ["prd@exoscale.ch"]
11
+ gem.description = %q{collectd exec module to watch megaraid status}
12
+ gem.summary = %q{graph megaraid status}
13
+ gem.homepage = "https://github.com/exoscale/megaraid-collectd"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: megaraid-collectd
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
+ platform: ruby
12
+ authors:
13
+ - Pierre-Yves Ritschard
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-12-11 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: collectd exec module to watch megaraid status
22
+ email:
23
+ - prd@exoscale.ch
24
+ executables:
25
+ - megaraid-collectd.rb
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE.txt
34
+ - README.md
35
+ - Rakefile
36
+ - bin/megaraid-collectd.rb
37
+ - lib/megaraid-collectd.rb
38
+ - lib/megaraid-collectd/version.rb
39
+ - megaraid-collectd.gemspec
40
+ homepage: https://github.com/exoscale/megaraid-collectd
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.24
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: graph megaraid status
73
+ test_files: []
74
+