nagios_parser 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - rbx-2.0
6
+ - jruby
data/CHANGES.md CHANGED
@@ -1,11 +1,14 @@
1
- nagios_parser - ChangeLog
2
- =========================
1
+ nagios\_parser - ChangeLog
2
+ ==========================
3
3
 
4
- # 1.2.1
4
+ # 1.2.2 (2011-10-22)
5
+ * Unbreak on Ruby 1.9.x.
6
+
7
+ # 1.2.1 (2011-06-22)
5
8
  * Apply original diff from Mitsuru to strip comments.
6
9
  This catches more inline comments.
7
10
 
8
- # 1.2.0
11
+ # 1.2.0 (2011-06-20)
9
12
  * Add NagiosParser::Resource parser to parse Nagios resource
10
13
  macro files.
11
14
  * Add NagiosParser::Config parser to parse the Nagios main
@@ -13,9 +16,9 @@ nagios_parser - ChangeLog
13
16
  * Ignore inline comments starting with ';' in the object
14
17
  configuration files.
15
18
 
16
- # 1.1.0
19
+ # 1.1.0 (2011-01-09)
17
20
  * Remove hardcoded status types to make the parser less strict.
18
21
  * More Nagios 2.x/3.x status types. (mariussturm)
19
22
 
20
- # 1.0.0
23
+ # 1.0.0 (2010-12-16)
21
24
  * Initial release
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Nagios Parser
2
2
  =============
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/bernd/nagios_parser.png)](http://travis-ci.org/bernd/nagios\_parser])
5
+
4
6
  # Description
5
7
 
6
8
  The `nagios_parser` gem provides a parser for the Nagios `status.dat`
data/Rakefile CHANGED
@@ -3,6 +3,8 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rspec/core/rake_task'
5
5
 
6
+ task :default => :spec
7
+
6
8
  RSpec::Core::RakeTask.new do |t|
7
9
  t.rcov = false
8
10
  end
@@ -32,6 +32,7 @@ def create_token(string)
32
32
  when scanner.scan(/#[^\n]*/)
33
33
  # ignore comments
34
34
  when scanner.scan(/.*;[^\n]*/)
35
+ # ignore inline comments
35
36
  r = scanner.matched.sub(/(.*);[^\n]*/, '\1')
36
37
  scanner.string = r + scanner.rest
37
38
  scanner.reset
@@ -51,7 +52,7 @@ def create_token(string)
51
52
  result << [:VALUE, match.to_i]
52
53
  when (inside and match = scanner.scan(/[^\n\}]+/))
53
54
  # Make sure to ignore inline comments starting with ';'.
54
- result << [:VALUE, match.first.gsub(/\s+$/, '')]
55
+ result << [:VALUE, match.gsub(/\s+$/, '')]
55
56
  else
56
57
  raise "Can't tokenize <#{scanner.peek(10)}>"
57
58
  end
@@ -50,6 +50,7 @@ def create_token(string)
50
50
  when scanner.scan(/#[^\n]*/)
51
51
  # ignore comments
52
52
  when scanner.scan(/.*;[^\n]*/)
53
+ # ignore inline comments
53
54
  r = scanner.matched.sub(/(.*);[^\n]*/, '\1')
54
55
  scanner.string = r + scanner.rest
55
56
  scanner.reset
@@ -69,7 +70,7 @@ def create_token(string)
69
70
  result << [:VALUE, match.to_i]
70
71
  when (inside and match = scanner.scan(/[^\n\}]+/))
71
72
  # Make sure to ignore inline comments starting with ';'.
72
- result << [:VALUE, match.first.gsub(/\s+$/, '')]
73
+ result << [:VALUE, match.gsub(/\s+$/, '')]
73
74
  else
74
75
  raise "Can't tokenize <#{scanner.peek(10)}>"
75
76
  end
@@ -1,3 +1,3 @@
1
1
  module NagiosParser
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'nagios_parser/object/parser'
3
+
4
+ describe "Github issues" do
5
+ describe "#3" do
6
+ it "can parse the user provided object config" do
7
+ object = <<-__OBJ
8
+ define host{
9
+ use switch
10
+ host_name Foo-ibb
11
+ alias Foo iBootBar
12
+ address 10.3.1.20
13
+ hostgroups iboots,Foo
14
+ parents Foo-modem
15
+ }
16
+ __OBJ
17
+
18
+ out = NagiosParser::Object::Parser.parse(object)
19
+ host = out['host'].first
20
+ host['use'].should == 'switch'
21
+ host['host_name'].should == 'Foo-ibb'
22
+ host['alias'].should == 'Foo iBootBar'
23
+ host['address'].should == '10.3.1.20'
24
+ host['hostgroups'].should == 'iboots,Foo'
25
+ host['parents'].should == 'Foo-modem'
26
+ end
27
+ end
28
+ end
@@ -24,6 +24,11 @@ describe NagiosParser::Status::Parser do
24
24
  }
25
25
  info { version=3.2.0 }
26
26
 
27
+ servicestatus {
28
+ service_description=POP3S
29
+ plugin_output=POP OK - 0.062 second response time on port 995 [+OK Dovecot ready. <123.456@example.com>]
30
+ }
31
+
27
32
  programstatus {
28
33
  last_command_check=1291408262
29
34
  global_service_event_handler=
@@ -43,6 +48,11 @@ describe NagiosParser::Status::Parser do
43
48
  [:OPEN, nil],
44
49
  [:KEY, 'version'], [:VALUE, '3.2.0'],
45
50
  [:CLOSE, nil],
51
+ [:TYPE, 'servicestatus'],
52
+ [:OPEN, nil],
53
+ [:KEY, 'service_description'], [:VALUE, 'POP3S'],
54
+ [:KEY, 'plugin_output'], [:VALUE, 'POP OK - 0.062 second response time on port 995 [+OK Dovecot ready. <123.456@example.com>]'],
55
+ [:CLOSE, nil],
46
56
  [:TYPE, 'programstatus'],
47
57
  [:OPEN, nil],
48
58
  [:KEY, 'last_command_check'], [:VALUE, 1291408262],
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernd Ahlers
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-21 00:00:00 Z
18
+ date: 2011-10-22 00:00:00 +02:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rake
@@ -70,6 +71,7 @@ extra_rdoc_files: []
70
71
 
71
72
  files:
72
73
  - .gitignore
74
+ - .travis.yml
73
75
  - CHANGES.md
74
76
  - Gemfile
75
77
  - LICENSE
@@ -86,11 +88,13 @@ files:
86
88
  - lib/nagios_parser/status/parser.y
87
89
  - lib/nagios_parser/version.rb
88
90
  - nagios_parser.gemspec
91
+ - spec/github_issues_spec.rb
89
92
  - spec/nagios_parser/config/parser_spec.rb
90
93
  - spec/nagios_parser/object/parser_spec.rb
91
94
  - spec/nagios_parser/resource/parser_spec.rb
92
95
  - spec/nagios_parser/status/parser_spec.rb
93
96
  - spec/spec_helper.rb
97
+ has_rdoc: true
94
98
  homepage: http://rubygems.org/gems/nagios_parser
95
99
  licenses: []
96
100
 
@@ -120,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
124
  requirements: []
121
125
 
122
126
  rubyforge_project:
123
- rubygems_version: 1.8.5
127
+ rubygems_version: 1.5.2
124
128
  signing_key:
125
129
  specification_version: 3
126
130
  summary: parser lib for parsing Nagios status and config files