Perl module for parsing Nagios configs?

Bryan Liles lilesb at ijet.com
Mon Oct 21 22:23:02 CEST 2002


Nice script.  I prefer cfg_dir, coulda posted a diff, but I reformatted
your code :)

    my @xod_dirs = ();

    foreach my $line (@cfg_file) {
	if ($line =~ /^xodtemplate_config_file=/) {
	    push(@xod_files, (split(/=/, $line))[1]);
	}

	if ($line =~ /^cfg_file=/) {
	    push(@xod_files, (split(/=/, $line))[1]);
	}

	if ($line =~ /^cfg_dir=/) {
	    push(@xod_dirs, (split(/=/, $line))[1]);
	}
    }
    
    foreach my $dir (@cfg_file) {
	opendir(DIR, $dir) or die "unable to open $dir: $!";
	while (defined(my $file = readdir(DIR))) {
	    next if $file =~ /^\.\.?$/;
	    if ($file =~ /cfg$/) {
		push (@xod_files, $file);
	    }
	}
    }

On Mon, 2002-10-21 at 15:55, Chet Luther wrote:
> It's me again,
>     I was in a bit of a hurry, so I went ahead and put together the Perl
> config file parsing module mentioned below.  I'm attaching it to this
> message in case anyone else out there has a use for it.  The documentation
> is in POD format in the module.
> 
> Chet Luther
> chet at rcn.com
> 
> 
> > Group,
> >     Before I go to the trouble of writing a Perl config file parser for
> > Nagios, I thought I'd check to see if anyone else already has one they'd
> be
> > willing to send my way.  Something that can take multiple files and parse
> > then into a single data structure would be preferrable.  If I don't get
> > anything, I'll be sure to share my module with anyone who wants it.
-- 
Bryan Liles <lilesb at ijet.com>



-------------------------------------------------------
This sf.net emial is sponsored by: Influence the future 
of  Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ad.doubleclick.net/clk;4699841;7576298;k?http://www.sun.com/javavote




More information about the Users mailing list