Config file parsing/reporting

Dan Rich drich at employees.org
Thu Mar 13 01:14:20 CET 2003


Dan Rich said:

> Does anyone have any tools for parsing the config files?  I am almost looking
> for a reporting/summary tool that will let me say things like "list all of the
> monitored hosts", or more importantly at this point "what are all of the
> services and who gets paged/e-mail when each one goes down"?

Ah, the joys of answering my own e-mail..... :)

Since I didn't hear from anyone, I've started to roll my own perl module for
handing this.  At the moment, I've got the following methods, and I wanted to
see if anyone had any other things they would find useful.

new            - return a reference to a config hash
param(string)  - return the value of a parameter for a host,service,etc.
                 (with no args returns a list of the parameters for the
                  host,svc, etc.)

The following return a ref to the specified service, host, contact, etc.
(needed for param above).  Leaving off the parameter(s) will return a list of
all of that item (i.e. host() will return a list of hosts).
    service(host_name|hostgroup_name, service_description)
    host(host_name)
    hostgroup(hostgroup_name)
    timeperiod(timeperiod_name)
    contact(contact_name)
    contactgroup(contactgroup_name)
    command(command_name)


So, with the above, you could do something like:
    $junk=NagiosCfg::new;
    print $junk->service("ns.somedomain.com","DNS")->param("contact_groups");
Or, even more exciting (for my purposes):
    print
$junk->contactgroups($junk->service("ns.somedomain.com","DNS")->param("contact_groups"))->param("members");


-- 
Dan Rich <drich at employees.org> |   http://www.employees.org/~drich/
                               |  "Step up to red alert!"  "Are you sure, sir?
                               |   It means changing the bulb in the sign..."
                               |          - Red Dwarf (BBC)



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list