markri/nagparser

Nagios configuration parser

0.1 2015-02-01 12:05 UTC

This package is not auto-updated.

Last update: 2024-04-27 13:10:47 UTC


README

Nagios Config Parser a simple parser written in PHP that parses Nagios config files (.cfg) into PHP objects, All definitions available in Nagios Nagios doc are read into PHP objects with getters for all options (easiness of autocompletion).

Currently it doesnt parse relations between definitions (yet).

Installation

Install with composer. See Packagist for versions and constraints. Or use your own PSR-0 compliant autoloader

Usage example

A little code example to fetch all service definitions from config

<?php

include 'vendor/autoload.php';

$parser = new NagParser\Parser('/usr/local/nagios/etc');
$parser->parse();

$checkServices = $parser->getServiceDefinitions();

// ... Whatever you want to with found definitions

Reason for existence

I wanted easy Nagios CFG editing, without repeated configs. So I came up with this parser to read all available services in order to create auto-generated servicegroups. This way I'm sure that no service will be left uncategorized, and would surely be in one of my servicegroups.