0.01
No release in over 3 years
Low commit activity in last 3 years
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 !
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

nagios_analyzer

Description

nagios_analyzer gem allows you to parse a status.dat file produced by nagios or shinken.

It’s similar to nagios_parser in some way, but has different goals:

  • the parser doesn’t rely on 3rd party library nor standard parser like ‘racc’, I want to keep the code very simple to read and maintain ;
  • the parser supports defining scopes, which are processed on the raw file for performance concern, ruby objects being instanciated lately when necessary : on my conf (85hosts/700services), spawning a ruby object for each section makes the script at least 10 times slower (0.25s => >3s). Most of the time, you’ll only want to access a subset of your services or hosts, so it’s ok.

Since nagios_parser looks very cool too, you should try both and keep the best one for you.

Installation

gem install nagios_analyzer

Usage

require 'nagios_analyzer'
require 'pp'

status = NagiosAnalyzer::Status.new("/path/to/status.dat")

# get services items
pp status.service_items

# get host items
pp status.host_items

# all items ?
pp status.items

# only problems, services or hosts
pp status.service_problems
pp status.host_problems

# in fact, each item contains the section
# and can be accessed as a Hash
pp status.items.first[:current_state]

# or directly
pp status.items.first.current_state

# get all sections, even those where status is OK
status = NagiosAnalyzer::Status.new("/path/to/status.dat", :include_ok => true)

# define a personal scope (applied to section string, so look at your status.dat!)
not_acknowledged = lambda{|section| section.include?("problem_has_been_acknowledged=0") }
status = NagiosAnalyzer::Status.new("/path/to/status.dat", :scope => not_acknowledged)

# add more scopes
status.scopes << lambda{|s| s.include?("notifications_enabled=1") } #no notifications
status.scopes << lambda{|s| s.start_with?("hoststatus") } #only host statuses

# reset cached results (if you changed scopes!)
status.reset_cache!

License

This gem is distributed under the MIT license, see LICENSE file for more details.