MRTG::Config

MRTG::Config is a Perl module for parsing MRTG configuration files.
Download

MRTG::Config Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Stephen R. Scaffidi
  • Publisher web site:
  • http://search.cpan.org/~sscaffidi/MRTG-Config-0.04/lib/MRTG/Config.pm

MRTG::Config Tags


MRTG::Config Description

MRTG::Config is a Perl module for parsing MRTG configuration files. MRTG::Config is a Perl module for parsing MRTG configuration files.WARNINGThis module, while reliable right now, is still in ALPHA stages of development... The API/methods may change. Behaviors of methods will almost certainly change. The internal structure of data will change, as will many other things.I will try to always release 'working' versions, but anyone who expects their code that uses this module to continue working shouldn't... until I remove this warning.SYNOPSISEver have the need to parse an MRTG config file? I have. I needed to parse lots and lots of them. Using the functions built-in to MRTG_lib was too slow, too complex, and used too much RAM and CPU time for my poor web server to handle - and the data structures MRTG_lib built were way more complex than I needed.MRTG::Config can load and parse MRTG and MRTG-style confiuguration files very quickly, and the parsed directives, targets and values can be located, extracted, and manipulated through an OO interface.This module is intended to focus on correctly parsing the format of an MRTG configuration, regardless of whether or not the directives and values, etc. are valid for MRTG. I am using both the parsing behavior of MRTG_lib's readcfg() function and the description of the format on the MRTG website as my guidelines on how to correctly parse these configuration files. I am still a short way off that goal, but this module is currently being used in a production environment with great success!PLEA FOR MERCYI plan on adding to this documentation and making it better organized soon, but I'm willing to answer questions directly in the mean time. Also, this is my first module, written in a hurry to appease some disgruntled engineers. I do plan on continuing to improve it, so any input, positive or negative is certainly welcome!USAGE EXAMPLE use MRTG::Config; my $cfgFile = 'mrtg.cfg'; my $persist_file = 'mrtg.cfg.db'; my $mrtgCfg = new MRTG::Config; $mrtgCfg->loadparse($cfgFile); # Want to store the parsed data for use later or by # another program? $mrtgCfg->persist_file($persist_file); $mrtgCfg->persist(1); foreach my $tgtName (@{$mrtgCfg->targets()}) { my $tgtCfg = $mrtgCfg->target($tgtName); # Let's assume every target has a Title. print $tgtCfg->{title} . "n"; } # globals() has some, um, interesting things you # should know. Please read about it below... my $globalCfg = $mrtgCfg->globals(); # Let's assume WorkDir is set. print $globalCfg->{workdir} . "n"; Requirements: · Perl


MRTG::Config Related Software