Nagios config parser in Perl
Stanley.Hopcroft at Dest.gov.au
Stanley.Hopcroft at Dest.gov.au
Wed May 31 07:17:59 CEST 2006
Dear Sir,
I am writing to thank you for your letter and say
>Message: 13
>Date: Tue, 30 May 2006 16:47:02 +0200
>From: Marc Haber <mh+nagios-users at zugschlus.de>
>To: nagios-users at lists.sourceforge.net
>Subject: [Nagios-users] Parsing a Nagios 2 configuration file from perl
>
>Hi,
>
>I'd like to have a list of all host_name directives in host
>definitions in a nagios 2 template style configuration in a
>perl script.
>
>Did anybody already write a nagios 2 configuration file parser in perl?
>
Yep. There's a (prob since I haven't used it) good one on CPAN in the
Nagios name space (search Nagios should find it) written by a Perl
luminary Al Tobey.
You need the Build module to get it installed.
There is also a rough-as-guts one that I use that is sometimes useful.
If you want to be the guinea pig ..
Here's an example of it in 'action'.
[sh1517 at acisf011 sh1517]$ perl -MNagios::Config -e
'$x=Nagios::Config->new("/etc/nagios/nagios.cfg"); @x=$x->grep("hosts",
q[$host_name =~ /mt[ab]sw21/i]); $x->pprint("hosts", \@x)'
define host{
host_name MTBSW210
address 10.0.254.149
alias 14 MORT BUILDING
contact_groups
datacomms-admins,premier_support_group
notification_period 24x7
parents MTASW200,BRUSW200
use generic-host
}
define host{
host_name MTASW210
address 10.0.254.169
alias 16 MORT BUILDING
contact_groups
datacomms-admins,premier_support_group
notification_period 24x7
parents MTASW200,BRUSW200
use generic-host
}
extracting stuff.
I actually use it (for some definition of 'use') for batch adds. But it
is rough ...
>Greetings
>Marc
caveat computer.
Yours sincerely.
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
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