nagios-splunk 1.0.0 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDYxNjliNjVmMjI2ZTJhM2RiZTYyNWU1MmNiNTU4NzU2ZjhiNTU4NQ==
5
- data.tar.gz: !binary |-
6
- NzhhM2ZjZGE4NjAyYjEwYzczNmY1MzVhMTM5Yjk1ZjkzMmI5ODAxNQ==
2
+ SHA1:
3
+ metadata.gz: 3bb587efb3794782fa89cfd9a82365ad5a8f2df7
4
+ data.tar.gz: 6695dca86a60dc661ba75db67c77cd9d9f110e1a
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- N2FhMWYxMGY0MjI4M2YzNWRjNzBiNjM4ZmI3NzNjMWEzYTBhMWVjOThmYWNl
10
- YzEzYjBmM2NlYTAxYWYzMGRkOTBjY2FhOTgzMjM4NWI5ODRlODQwYmI2ZDVi
11
- Y2MzYWNmZDhiNjViMTUwNDMzZDcwZWQ4YTJiYjcwNDg2NDNkY2U=
12
- data.tar.gz: !binary |-
13
- Njk2YzlhMjliOTI1MzQ5NWNmY2ZjZDMyMzM0MTYzMzc4ZGQ4MTU1OTM3ZDE5
14
- NmJkNDIxZmMwY2ZmMDc1NGEyOWIzMzhkNzUwODZkNzY3ZmE2MzlmMDE5ODQ1
15
- ZTcwYjg1OTQwZmQwNjIyOThjYzQyZTJjNzg1ZWMxOTBmNjVkYWI=
6
+ metadata.gz: 2ae529dbca5d506c8749c6bfed74356e463051e0ac49f8df52af751f9211501625cfc64ca1b92c734c4fb8a530432cdfdb5def42757f126db8d45f63ac7c26cd
7
+ data.tar.gz: 5e3fe4ef0039241cd2d040a92e8846119d67da564b95ab8ab4c285a22ffe3588ac85b5e41c4c7c0fe8c6f6df1fcf5e9c9ab0086fb4bf650fb05204bfe347adf9
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rake/testtask'
2
- require 'rake/gempackagetask'
2
+ require 'rake/packagetask'
3
3
 
4
4
  task :default => :test
5
5
 
@@ -12,9 +12,9 @@ end
12
12
 
13
13
  gem_spec = eval(File.read("nagios-splunk.gemspec"))
14
14
 
15
- Rake::GemPackageTask.new(gem_spec) do |pkg|
16
- pkg.gem_spec = gem_spec
17
- end
15
+ #Rake::PackageTask.new(gem_spec) do |pkg|
16
+ # pkg.spec = gem_spec
17
+ #end
18
18
 
19
19
  desc "remove build files"
20
20
  task :clean do
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
3
5
  require 'nagios/splunk'
4
6
  exit Nagios::Splunk::CLI.new.run
@@ -8,6 +8,7 @@ module Nagios
8
8
  POOL_LIST_URL = "/services/licenser/pools"
9
9
  LICENSE_LIST_URL = "/services/licenser/licenses"
10
10
  LICENSE_LOCALSLAVE_URL = "/services/licenser/localslave"
11
+ CLUSTER_MASTER_INFO_URL = "/services/licenser/localslave"
11
12
 
12
13
  autoload :Check, "nagios/splunk/check"
13
14
  autoload :RestClient, "nagios/splunk/rest_client"
@@ -15,6 +16,7 @@ module Nagios
15
16
  autoload :Exception, "nagios/splunk/exception"
16
17
  autoload :NoPoolsFound, "nagios/splunk/exception"
17
18
  autoload :NoLicensesFound, "nagios/splunk/exception"
19
+ autoload :Splunk, "nagios/splunk/splunk"
18
20
 
19
21
  end
20
22
  end
@@ -63,6 +63,28 @@ module Nagios
63
63
  return [code, message]
64
64
  end
65
65
 
66
+ def cluster_bundle_status
67
+ splunk = Splunk.new(rest_client)
68
+ info = splunk.cluster_master_info
69
+ errors = info.xpath("//s:key[@name='bundle_validation_errors_on_master']//s:item").map { |n| n.text.chomp }
70
+ code = (errors.empty? ? 0 : 1)
71
+ return [code, "Splunk cluster bundle status is #{STATUS[code]} | #{errors.join("\n")}"]
72
+ end
73
+
74
+ def cluster_replication_factor
75
+ splunk = Splunk.new(rest_client)
76
+ info = splunk.cluster_master_generation
77
+ code = info.xpath("//s:key[@name='replication_factor_met']").text.to_i
78
+ return [code == 1 ? 0 : 1, "Splunk cluster replication factor is #{code == 1 ? "met" : "not met"}"]
79
+ end
80
+
81
+ def cluster_search_factor
82
+ splunk = Splunk.new(rest_client)
83
+ info = splunk.cluster_master_generation
84
+ code = info.xpath("//s:key[@name='search_factor_met']").text.to_i
85
+ return [code == 1 ? 0 : 1, "Splunk cluster search factor is #{code == 1 ? "met" : "not met"}"]
86
+ end
87
+
66
88
  private
67
89
 
68
90
  # Compare usage and quota with threshold
@@ -41,6 +41,18 @@ module Nagios
41
41
  :default => 'enterprise',
42
42
  :description => "License Stack ID.")
43
43
 
44
+ option(:replication_factor,
45
+ :long => "--repl-factor",
46
+ :description => "Check if replication factor is met.")
47
+
48
+ option(:search_factor,
49
+ :long => "--search-factor",
50
+ :description => "Check if search factor is met.")
51
+
52
+ option(:cluster_bundle_status,
53
+ :long => "--cluster-bundle-status",
54
+ :description => "Check cluster bundle status.")
55
+
44
56
  def run(argv = ARGV)
45
57
  parse_options(argv)
46
58
 
@@ -48,7 +60,13 @@ module Nagios
48
60
  splunk = Check.new(client)
49
61
 
50
62
  begin
51
- if config[:localslave]
63
+ if config[:replication_factor]
64
+ status, message = splunk.cluster_replication_factor
65
+ elsif config[:search_factor]
66
+ status, message = splunk.cluster_search_factor
67
+ elsif config[:cluster_bundle_status]
68
+ status, message = splunk.cluster_bundle_status
69
+ elsif config[:localslave]
52
70
  status, message = splunk.localslave(config[:warn], config[:crit])
53
71
  elsif config[:pool]
54
72
  status, message = splunk.pool_usage(config[:pool], config[:warn], config[:crit])
@@ -48,10 +48,14 @@ module Nagios
48
48
  # build HTTP connection
49
49
  # @return [Net::HTTP]
50
50
  def client
51
- @client ||= Net::HTTP.new(@host, @port)
52
- @client.use_ssl = @use_ssl
53
- @client.set_debug_output $stderr if debug
54
- @client
51
+ @client ||=
52
+ begin
53
+ http = Net::HTTP.new(@host, @port)
54
+ http.use_ssl = @use_ssl
55
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?
56
+ http.set_debug_output $stderr if debug
57
+ http
58
+ end
55
59
  end
56
60
 
57
61
  def debug
@@ -0,0 +1,23 @@
1
+ module Nagios
2
+ module Splunk
3
+ class Splunk
4
+
5
+ attr_accessor :client
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def cluster_master_info
12
+ response = @client.get("/services/cluster/master/info")
13
+ Nokogiri::Slop(response.body) if response.code.to_i == 200
14
+ end
15
+
16
+ def cluster_master_generation
17
+ response = @client.get("/services/cluster/master/generation")
18
+ Nokogiri::Slop(response.body) if response.code.to_i == 200
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "nagios-splunk"
5
- s.version = "1.0.0"
5
+ s.version = "1.1.3"
6
6
  s.authors = 'Max Horbul'
7
7
  s.email = ["max@gorbul.net"]
8
8
  s.homepage = "https://github.com/mhorbul/nagios-splunk"
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios-splunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Horbul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Splunk monitoring in Nagios
@@ -74,16 +74,17 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - README
78
- - Rakefile
79
77
  - bin/check_splunk
80
- - lib/nagios/splunk.rb
81
78
  - lib/nagios/splunk/check.rb
82
79
  - lib/nagios/splunk/cli.rb
83
80
  - lib/nagios/splunk/exception.rb
84
81
  - lib/nagios/splunk/rest_client.rb
85
- - nagios-splunk.gemspec
82
+ - lib/nagios/splunk/splunk.rb
83
+ - lib/nagios/splunk.rb
86
84
  - test/test_helper.rb
85
+ - README
86
+ - Rakefile
87
+ - nagios-splunk.gemspec
87
88
  homepage: https://github.com/mhorbul/nagios-splunk
88
89
  licenses: []
89
90
  metadata: {}
@@ -93,17 +94,17 @@ require_paths:
93
94
  - lib
94
95
  required_ruby_version: !ruby/object:Gem::Requirement
95
96
  requirements:
96
- - - ! '>='
97
+ - - '>='
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  requirements:
101
- - - ! '>='
102
+ - - '>='
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
106
  rubyforge_project: nagios-splunk
106
- rubygems_version: 2.2.1
107
+ rubygems_version: 2.0.14
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Nagios Splunk plugin