Icon Rufen Sie uns an
+49 441.309197-69 +49 441.309197-69
 
EN

Parsing Nagios files with Ruby

Posted by Bernd Ahlers on Friday, December 17, 2010

I just released a Ruby library to parse Nagios status files as well as Nagios object definitions.

Inspired by a recent talk of my co-worker Holger on parser and lexer, I started to rewrite my clunky regex based parser for Nagios status files that I wrote some time ago. Since the status parser works pretty well, I added a second parser to parse Nagios object definition files.

The parsers are written by applying the Racc parser generator for Ruby. Racc should be familiar for people who know yacc . Code that is using Racc needs the Racc runtime library, which is included in the Ruby standard lib since Ruby 1.8.×.

You can find the source code on GitHub . The README includes an example on how to use the library.

Use the gem command to install it on your machine.

# gem install nagios_parser

Please let me know if you find any problems or if you think that something is missing or not working well.

I’m going to use the parser for an upcoming project which I’ll probably announce here as well. So stay tuned! :)