README.md in nagios_parser-1.1.0 vs README.md in nagios_parser-1.2.0

- old
+ new

@@ -6,10 +6,12 @@ The `nagios_parser` gem provides a parser for the Nagios `status.dat` files and a parser for the Nagios object definition files. * NagiosParser::Status::Parser * NagiosParser::Object::Parser +* NagiosParser::Config::Parser +* NagiosParser::Resource::Parser Both parsers return plain hashes and arrays. There are no special Nagios objects or something like that. That means you can create your own wrapping objects or use the simple data structure directly. @@ -98,10 +100,46 @@ "host"=> [{"address"=>"10.0.0.1", "host_name"=>"server1", "alias"=>"server1.example.com"}]} +## Config Parser + + require 'nagios_parser/config/parser' + require 'pp' + + config = <<-CONFIG + log_file=/var/log/nagios3/nagios.log + status_update_interval=10 + CONFIG + + data = NagiosParser::Config::Parser.parse(config) + pp data + +This will print a data structure that looks like this. + + {"log_file"=>"/var/log/nagios3/nagios.log", + "status_update_interval"=>10} + +## Resource macro parser + + require 'nagios_parser/resource/parser' + require 'pp' + + resource = <<-RESOURCE + $USER1$=/usr/lib/nagios/plugins + $USER10$=mysqluser + RESOURCE + + data = NagiosParser::Resource::Parser.parse(resource) + pp data + +This will print a data structure that looks like this. + + {"$USER10$"=>"mysqluser", + "$USER1$"=>"/usr/lib/nagios/plugins"} + # Development The parsers are based on the racc parser generator. racc is needed at runtime, but that should be no problem since it's included in the Ruby standard library. @@ -109,9 +147,11 @@ To modify the parsers you have to modify the `.y` files and regenerate the Ruby files afterwards. There are two rake tasks to help with that. * `rake parser::status` * `rake parser::object` +* `rake parser::config` +* `rake parser::resource` The bundler gem is used to handle the development dependencies. Run `bundle install` to install them. Please let me know if you have any questions or if you run into any