nagios_analyzer 0.0.2 → 0.0.3

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/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - ruby-head
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - jruby
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in nagios_analyzer.gemspec
4
4
  gemspec
5
+
6
+ # for CI on Travis
7
+ gem 'rake'
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nagios_analyzer (0.0.1)
4
+ nagios_analyzer (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.1.2)
10
+ rake (0.8.7)
10
11
  rspec (2.4.0)
11
12
  rspec-core (~> 2.4.0)
12
13
  rspec-expectations (~> 2.4.0)
@@ -21,4 +22,5 @@ PLATFORMS
21
22
 
22
23
  DEPENDENCIES
23
24
  nagios_analyzer!
25
+ rake
24
26
  rspec
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h1. nagios_analyzer
2
2
 
3
+ "!https://secure.travis-ci.org/jbbarth/nagios_analyzer.png!":http://travis-ci.org/jbbarth/nagios_analyzer
4
+
3
5
  h2. Description
4
6
 
5
7
  nagios_analyzer gem allows you to parse a status.dat file produced by nagios or shinken.
@@ -43,7 +45,7 @@ pp status.items.first[:current_state]
43
45
  status = NagiosAnalyzer::Status.new("/path/to/status.dat", :include_ok => true)
44
46
 
45
47
  # define a personal scope (applied to section string, so look at your status.dat!)
46
- not_acknowleged = lambda{|section| section.include?("problem_has_been_acknowledged=0") }
48
+ not_acknowledged = lambda{|section| section.include?("problem_has_been_acknowledged=0") }
47
49
  status = NagiosAnalyzer::Status.new("/path/to/status.dat", :scope => not_acknowledged)
48
50
 
49
51
  # add more scopes
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ desc 'Default: run specs.'
9
+ task :default => :spec
@@ -34,7 +34,7 @@ module NagiosAnalyzer
34
34
  def sort_array
35
35
  [ (self[:type] == "servicestatus" ? 1 : 0),
36
36
  Status::STATES_ORDER[self[:current_state]].to_i,
37
- self[:host_name],
37
+ self[:host_name].to_s,
38
38
  self[:service_description].to_s ]
39
39
  end
40
40
  end
@@ -36,13 +36,13 @@ module NagiosAnalyzer
36
36
 
37
37
  def host_items
38
38
  @host_items ||= sections.map do |s|
39
- Section.new(s) if s.start_with?("hoststatus") && in_scope?(s)
39
+ Section.new(s) if s =~ /^hoststatus/ && in_scope?(s)
40
40
  end.compact
41
41
  end
42
42
 
43
43
  def service_items
44
44
  @service_items ||= sections.map do |s|
45
- Section.new(s) if s.start_with?("servicestatus") && in_scope?(s)
45
+ Section.new(s) if s =~ /^servicestatus/ && in_scope?(s)
46
46
  end.compact
47
47
  end
48
48
 
@@ -52,13 +52,13 @@ module NagiosAnalyzer
52
52
 
53
53
  def host_problems
54
54
  @host_problems ||= sections.map do |s|
55
- Section.new(s) if s.start_with?("hoststatus") && in_scope?(s) && problem?(s)
55
+ Section.new(s) if s =~ /^hoststatus/ && in_scope?(s) && problem?(s)
56
56
  end.compact
57
57
  end
58
58
 
59
59
  def service_problems
60
60
  @service_problems ||= sections.map do |s|
61
- Section.new(s) if s.start_with?("servicestatus") && in_scope?(s) && problem?(s)
61
+ Section.new(s) if s =~ /^servicestatus/ && in_scope?(s) && problem?(s)
62
62
  end.compact
63
63
  end
64
64
 
@@ -1,3 +1,3 @@
1
1
  module NagiosAnalyzer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/section_spec.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  require File.expand_path('../spec_helper',__FILE__)
2
2
 
3
- describe NagiosAnalyzer::Section do
4
- include NagiosAnalyzer
3
+ #alias NagiosAnalyzer to NA for convenience
4
+ NA = NagiosAnalyzer
5
5
 
6
+ describe NA::Section do
6
7
  before(:each) do
7
8
  file = File.expand_path('../data/status.dat',__FILE__)
8
- status = Status.new(file)
9
+ status = NA::Status.new(file)
9
10
  @section = status.service_items.first
10
11
  end
11
12
 
12
13
  it "returns a hash with keys only" do
13
- @section.should be_a(Section)
14
+ @section.should be_a(NA::Section)
14
15
  @section.keys.map(&:class).uniq.should == [Symbol]
15
16
  end
16
17
 
@@ -26,46 +27,46 @@ describe NagiosAnalyzer::Section do
26
27
 
27
28
  it "provides a :status key to know the status" do
28
29
  @section[:status].should == "WARNING"
29
- Section.new("servicestatus {\ncurrent_state=0\n}")[:status].should == "OK"
30
- Section.new("servicestatus {\ncurrent_state=2\n}")[:status].should == "CRITICAL"
31
- Section.new("servicestatus {\ncurrent_state=3\n}")[:status].should == "UNKNOWN"
32
- Section.new("hoststatus {\ncurrent_state=0\n}")[:status].should == "OK"
33
- Section.new("hoststatus {\ncurrent_state=42\n}")[:status].should == "CRITICAL"
30
+ NA::Section.new("servicestatus {\ncurrent_state=0\n}")[:status].should == "OK"
31
+ NA::Section.new("servicestatus {\ncurrent_state=2\n}")[:status].should == "CRITICAL"
32
+ NA::Section.new("servicestatus {\ncurrent_state=3\n}")[:status].should == "UNKNOWN"
33
+ NA::Section.new("hoststatus {\ncurrent_state=0\n}")[:status].should == "OK"
34
+ NA::Section.new("hoststatus {\ncurrent_state=42\n}")[:status].should == "CRITICAL"
34
35
  end
35
36
 
36
37
  context "#sort" do
37
38
  it "places servicestatus'es after hoststatus'es" do
38
- a = Section.new("servicestatus {\ncurrent_state=0\n}")
39
- b = Section.new("hoststatus {\ncurrent_state=0\n}")
39
+ a = NA::Section.new("servicestatus {\ncurrent_state=0\n}")
40
+ b = NA::Section.new("hoststatus {\ncurrent_state=0\n}")
40
41
  [a,b].sort.should == [b,a]
41
42
  end
42
43
 
43
44
  it "places critical before unknown before warning before pending before dependent before ok" do
44
- host = Section.new("hoststatus {\ncurrent_state=0\n}")
45
- critical = Section.new("servicestatus {\ncurrent_state=2\n}")
46
- unknown = Section.new("servicestatus {\ncurrent_state=3\n}")
47
- warning = Section.new("servicestatus {\ncurrent_state=1\n}")
48
- dependent = Section.new("servicestatus {\ncurrent_state=4\n}")
49
- ok = Section.new("servicestatus {\ncurrent_state=0\n}")
45
+ host = NA::Section.new("hoststatus {\ncurrent_state=0\n}")
46
+ critical = NA::Section.new("servicestatus {\ncurrent_state=2\n}")
47
+ unknown = NA::Section.new("servicestatus {\ncurrent_state=3\n}")
48
+ warning = NA::Section.new("servicestatus {\ncurrent_state=1\n}")
49
+ dependent = NA::Section.new("servicestatus {\ncurrent_state=4\n}")
50
+ ok = NA::Section.new("servicestatus {\ncurrent_state=0\n}")
50
51
  [ok, unknown, dependent, critical, host, warning].sort.should == [host, critical, unknown, warning, dependent, ok]
51
52
  end
52
53
 
53
54
  it "sorts by host_name" do
54
- a = Section.new("hoststatus {\ncurrent_state=0\nhost_name=a\n}")
55
- b = Section.new("hoststatus {\ncurrent_state=0\nhost_name=b\n}")
55
+ a = NA::Section.new("hoststatus {\ncurrent_state=0\nhost_name=a\n}")
56
+ b = NA::Section.new("hoststatus {\ncurrent_state=0\nhost_name=b\n}")
56
57
  [b,a].sort.should == [a,b]
57
58
  end
58
59
 
59
60
  it "sorts by service_description" do
60
- a = Section.new("hoststatus {\ncurrent_state=0\n}")
61
- b = Section.new("servicestatus {\ncurrent_state=0\nservice_description=b\n}")
62
- c = Section.new("servicestatus {\ncurrent_state=0\nservice_description=c\n}")
61
+ a = NA::Section.new("hoststatus {\ncurrent_state=0\n}")
62
+ b = NA::Section.new("servicestatus {\ncurrent_state=0\nservice_description=b\n}")
63
+ c = NA::Section.new("servicestatus {\ncurrent_state=0\nservice_description=c\n}")
63
64
  [c,b,a].sort.should == [a,b,c]
64
65
  end
65
66
 
66
67
  it "has no problem even with missing fields (hostname don't have service_description)" do
67
- a = Section.new("hoststatus {\ncurrent_state=0\n}")
68
- b = Section.new("hoststatus {\ncurrent_state=0\n}")
68
+ a = NA::Section.new("hoststatus {\ncurrent_state=0\n}")
69
+ b = NA::Section.new("hoststatus {\ncurrent_state=0\n}")
69
70
  [a,b].sort.should == [a,b]
70
71
  end
71
72
  end
metadata CHANGED
@@ -1,46 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: nagios_analyzer
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jean-Baptiste Barth
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-05-07 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-22 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &75650760 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :development
32
- version_requirements: *id001
33
- description: Helps you parse a status.dat file produced by nagios or shinken. It aims at being performant for big status.dat files. Take a look at nagios_parser too if you want, looks very cool too !
34
- email:
23
+ prerelease: false
24
+ version_requirements: *75650760
25
+ description: Helps you parse a status.dat file produced by nagios or shinken. It aims
26
+ at being performant for big status.dat files. Take a look at nagios_parser too if
27
+ you want, looks very cool too !
28
+ email:
35
29
  - jeanbaptiste.barth@gmail.com
36
30
  executables: []
37
-
38
31
  extensions: []
39
-
40
32
  extra_rdoc_files: []
41
-
42
- files:
33
+ files:
43
34
  - .gitignore
35
+ - .travis.yml
44
36
  - Gemfile
45
37
  - Gemfile.lock
46
38
  - README.textile
@@ -54,37 +46,34 @@ files:
54
46
  - spec/section_spec.rb
55
47
  - spec/spec_helper.rb
56
48
  - spec/status_spec.rb
57
- has_rdoc: true
58
49
  homepage: http://github.com/jbbarth/nagios_analyzer
59
50
  licenses: []
60
-
61
51
  post_install_message:
62
52
  rdoc_options: []
63
-
64
- require_paths:
53
+ require_paths:
65
54
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
55
+ required_ruby_version: !ruby/object:Gem::Requirement
67
56
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ segments:
72
62
  - 0
73
- version: "0"
74
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ hash: 91061875
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
65
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- segments:
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
80
71
  - 0
81
- version: "0"
72
+ hash: 91061875
82
73
  requirements: []
83
-
84
74
  rubyforge_project: nagios_analyzer
85
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.8.10
86
76
  signing_key:
87
77
  specification_version: 3
88
78
  summary: Parses a nagios/shinken status.dat file
89
79
  test_files: []
90
-