™.. .IX Title "MRTGLIB 1" MRTGLIB - Online Linux Manual PageSection : 1
Updated : 2008-05-16
Source : 2.16.2
Note : mrtg

NAMEMRTG_lib.pm − Library for MRTG and support scripts

SYNOPSIS.IX Header "SYNOPSIS" ​ use MRTG_lib; ​ my ($configfile, @target_names, %globalcfg, %targetcfg); ​ readcfg($configfile, \@target_names, \%globalcfg, \%targetcfg); ​ my (@parsed_targets); ​ cfgcheck(\@target_names, \%globalcfg, \%targetcfg, \@parsed_targets);

DESCRIPTION.IX Header "DESCRIPTION" MRTG_lib is part of MRTG, the Multi Router Traffic Grapher. It was separated from MRTG to allow other programs to easily use the same config files. The main part of MRTG_lib is the config file parser but some other funcions are there too. $MRTG_lib::OS .IX Item "$MRTG_lib::OS" Type of OS: WIN, UNIX, VMS $MRTG_lib::SL .IX Item "$MRTG_lib::SL"Slash in the current OS. $MRTG_lib::PS .IX Item "$MRTG_lib::PS" Path separator in PATH variable readcfg .IX Item "readcfg"\*(C`readcfg($file, \e@targets, \e%globalcfg, \e%targetcfg [, $prefix, \e%extrules])\*(C'\fR Reads a config file, parses it and fills some arrays and hashes. The mandatory arguments are: the name of the config file, a ref to an array which will be filled with a list of the target names, a hashref for the global configuration, a hashref for the target configuration. The configuration file syntax is: ​ globaloption: value ​ targetoption[targetname]: value ​ aprefix*extglobal: value ​ aprefix*exttarget[target2]: value E.g. ​ workdir: /var/stat/mrtg ​ target[router1]: 2:public@router1.local.net ​ 14all*columns: 2 The global config hash has the structure ​ $globalcfg{configoption} = 'value' The target config hash has the structure ​ $targetcfg{configoption}{targetname} = 'value' See mrtg-reference for more information about the MRTG configuration syntax. \*(C`readcfg\*(C'\fR can take two additional arguments to extend the config file syntax. This allows programs to put their configuration into the mrtg config file. The fifth argument is the prefix of the extension, the sixth argument is a hash with the checkrules for these extension settings. E.g. if the prefix is 14all \*(C`readcfg\*(C'\fR will check config lines that begin with ​14all*, i.e. all lines like ​ 14all*columns: 2 ​ 14all*graphsize[target3]: 500 200 against the rules in %extrules. The format of this hash is: ​ $extrules{option} = [sub{$_[0] =~ m/^\d+$/}, sub{"Error message for $_[0]"}] ​ i.e. ​ $extrules{option}[0]> a test expression ​ $extrules{option}[1]> error message if test fails The first part of the array is a perl expression to test the value of the option. The test can access this value in the variable $arg. The second part of the array is an error message to display when the test fails. The failed value can be integrated by using the variable $arg. Config settings with an different prefix than the one given in the \*(C`readcfg\*(C'\fR call are not checked but inserted into %globalcfg and %targetcfg. Prefixed settings keep their prefix in the config hashes: ​ $targetcfg{'14all*graphsize'}{'target3'} = '500 200' cfgcheck .IX Item "cfgcheck"\*(C`cfgcheck(\e@target_names, \e%globalcfg, \e%targetcfg, \e@parsed_targets)\*(C'\fR Checks the configuration read by \*(C`readcfg\*(C'\fR. Checks the values in the config for syntactical and/or semantical errors. Sets defaults for some options. Parses the target[...] options and filles the array @parsed_targets ready for mrtg functions. The first three arguments are the same as for \*(C`readcfg\*(C'\fR. The fourth argument is an arrayref which will be filled with the parsed target defs. \*(C`cfgcheck\*(C'\fR converts the values of target settings \fIoptions\fR, e.g. ​ options[router1]: bits, growright to a hash: ​ $targetcfg{'option'}{'bits'}{'router1'} = 1 ​ $targetcfg{'option'}{'growright'}{'router1'} = 1 This is not done by \*(C`readcfg\*(C'\fR so if you don't use \f(CW\*(C`cfgcheck\*(C'\fR you have to check the scalar variable $targetcfg{'option'}{'router1'} (MRTG allows options to be separated by space or ','). ensureSL .IX Item "ensureSL"\*(C`ensureSL(\e$pathname)\*(C'\fR Checks that the pathname does not contain double path separators and ends with a path separator. It uses $MRTG_lib::SL as path separator which will be / or \ depending on the OS. log2rrd .IX Item "log2rrd"\*(C`log2rrd ($router,\e%globalcfg,\e%targetcfg)\*(C'\fR Convert log file to rrd format. Needs rrdtool. datestr .IX Item "datestr"\*(C`datestr(time)\*(C'\fR Returns the time given in the argument as a nicely formated date string. The argument has to be in UNIX time format (seconds since 1970−1−1). timestamp .IX Item "timestamp"\*(C`timestamp()\*(C'\fR Return a string representing the current time. setup_loghandlers .IX Item "setup_loghandlers"\*(C`setup_loghandlers(filename)\*(C'\fR Install signalhandlers for _ _DIE_ _ and _ _WARN_ _ making the errors go the the specified destination. If filename is 'eventlog' mrtg will log to the windows event logger. expistr .IX Item "expistr"\*(C`expistr(time)\*(C'\fR Returns the time given in the argument formatted suitable for HTTP Expire−Headers. create_pid .IX Item "create_pid"\*(C`create_pid()\*(C'\fR Creates a pid file for the mrtg daemon demonize_me .IX Item "demonize_me"\*(C`demonize_me()\*(C'\fR Puts the running program into background, detaching it from the terminal. populatecache .IX Item "populatecache"\*(C`populatecache(\e%confcache, $host, $reread, $snmpoptshash)\*(C'\fR Reads the SNMP variables ifDescr, ipAdEntIfIndex, ifPhysAddress, ifName from the host and stores the values in %confcache as follows: ​ $confcache{$host}{'Descr'}{ifDescr}{oid} = (ifDescr or 'Dup') ​ $confcache{$host}{'IP'}{ipAdEntIfIndex}{oid} = (ipAdEntIfIndex or 'Dup') ​ $confcache{$host}{'Eth'}{ifPhysAddress}{oid} = (ifPhysAddress or 'Dup') ​ $confcache{$host}{'Name'}{ifName}{oid} = (ifName or 'Dup') ​ $confcache{$host}{'Type'}{ifType}{oid} = (ifType or 'Dup') The value (at the right side of =) is 'Dup' if a value was retrieved muliple times, the retrieved value else. readconfcache .IX Item "readconfcache"\*(C`my $confcache = readconfcache($file)\*(C'\fR Preload the confcache from a file. readfromconfcache .IX Item "readfromconfcache"\*(C`writeconfcache($confcache,$file)\*(C'\fR Store the current confcache into a file. writeconfcache .IX Item "writeconfcache"\*(C`writeconfcache($confcache,$file)\*(C'\fR Store the current confcache into a file. storeincache .IX Item "storeincache"\*(C`storeincache($confcache,$host,$method,$key,$value)\*(C'\fR readfromcache .IX Item "readfromcache"\*(C`readfromcache($confcache,$host,$method,$key)\*(C'\fR clearfromcache .IX Item "clearfromcache"\*(C`clearfromcache($confcache,$host)\*(C'\fR debug .IX Item "debug"\*(C`debug($type, $message)\*(C'\fR Prints the message on STDERR if debugging is enabled for type type. A debug type is enabled if type is in array @main::DEBUG.

AUTHORS.IX Header "AUTHORS" Rainer Bawidamann <Rainer.Bawidamann@rz.uni−ulm.de> (This Manpage)
0
Johanes Gumabo
Data Size   :   31,208 byte
man-mrtglib.1Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 201,429
Visitor ID   :     :  
Visitor IP   :   3.138.134.149   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|mrtglib.1|44/45|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|mrtglib.1|44/45|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|mrtglib.1|49|br══─}─══|'br══─}─══ )         (htmlprn|149|mrtglib.1|49|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|mrtglib.1|55/56|\nF|.if \nF ══─{─══. de IX )         (rof_unit_scale_px|41|mrtglib.1|55/56|F|.if \nF ══─{─══. de IX )         (rof_if|19|mrtglib.1|55/56|\nF|.if \nF ══─{─══. de IX )         (htmlprn|149|mrtglib.1|55/56|.if \nF ══─{─══. de IX|.if \nF ══─{─══. de IX )         (rof_escape_sequence|91|mrtglib.1|57|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (parse_manual_page_|249|mrtglib.1|61|══─}─══|.══─}─══ )         (htmlprn|149|mrtglib.1|61|.══─}─══ |.══─}─══ )         (parse_manual_page_|249|mrtglib.1|131|IX|.IX Title "MRTGLIB 1" )         (parse_manual_page_|249|mrtglib.1|136|IX|.IX Header "SYNOPSIS" )         (parse_manual_page_|249|mrtglib.1|145|IX|.IX Header "DESCRIPTION" )         (parse_manual_page_|249|mrtglib.1|152|IX|.IX Item "$MRTG_lib::OS" )         (parse_manual_page_|249|mrtglib.1|156|IX|.IX Item "$MRTG_lib::SL" )         (parse_manual_page_|249|mrtglib.1|160|IX|.IX Item "$MRTG_lib::PS" )         (parse_manual_page_|249|mrtglib.1|164|IX|.IX Item "readcfg" )         (rof_escape_sequence|91|mrtglib.1|165|\*(C`readcfg($file, \e@targets, \e%globalcfg, \e%targetcfg [, $prefix, \e%extrules])\*(C'\fR |\&\f(CW\*(C`readcfg($file, \e@targets, \e%globalcfg, \e%targetcfg [, $prefix, \e%extrules])\*(C'\fR )         (rof_escape_sequence|91|mrtglib.1|203|\*(C`readcfg\*(C'\fR can take two additional arguments to extend the config file |\&\f(CW\*(C`readcfg\*(C'\fR can take two additional arguments to extend the config file )         (rof_escape_sequence|91|mrtglib.1|207|\*(C`readcfg\*(C'\fR will check config lines that begin with |prefix is \*(L"14all\*(R" \f(CW\*(C`readcfg\*(C'\fR will check config lines that begin with )         (rof_escape_sequence|91|mrtglib.1|229|\*(C`readcfg\*(C'\fR |Config settings with an different prefix than the one given in the \f(CW\*(C`readcfg\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|238|IX|.IX Item "cfgcheck" )         (rof_escape_sequence|91|mrtglib.1|239|\*(C`cfgcheck(\e@target_names, \e%globalcfg, \e%targetcfg, \e@parsed_targets)\*(C'\fR |\&\f(CW\*(C`cfgcheck(\e@target_names, \e%globalcfg, \e%targetcfg, \e@parsed_targets)\*(C'\fR )         (rof_escape_sequence|91|mrtglib.1|241|\*(C`readcfg\*(C'\fR. Checks the values in the config |Checks the configuration read by \f(CW\*(C`readcfg\*(C'\fR. Checks the values in the config )         (rof_escape_sequence|91|mrtglib.1|246|\*(C`readcfg\*(C'\fR. The fourth argument |The first three arguments are the same as for \f(CW\*(C`readcfg\*(C'\fR. The fourth argument )         (rof_escape_sequence|91|mrtglib.1|249|\*(C`cfgcheck\*(C'\fR converts the values of target settings \fIoptions\fR, e.g. |\&\f(CW\*(C`cfgcheck\*(C'\fR converts the values of target settings \fIoptions\fR, e.g. )         (rof_escape_sequence|91|mrtglib.1|262|\*(C`readcfg\*(C'\fR so if you don't use \f(CW\*(C`cfgcheck\*(C'\fR you have to |This is not done by \f(CW\*(C`readcfg\*(C'\fR so if you don't use \f(CW\*(C`cfgcheck\*(C'\fR you have to )         (parse_manual_page_|249|mrtglib.1|267|IX|.IX Item "ensureSL" )         (rof_escape_sequence|91|mrtglib.1|268|\*(C`ensureSL(\e$pathname)\*(C'\fR |\&\f(CW\*(C`ensureSL(\e$pathname)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|275|IX|.IX Item "log2rrd" )         (rof_escape_sequence|91|mrtglib.1|276|\*(C`log2rrd ($router,\e%globalcfg,\e%targetcfg)\*(C'\fR |\&\f(CW\*(C`log2rrd ($router,\e%globalcfg,\e%targetcfg)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|281|IX|.IX Item "datestr" )         (rof_escape_sequence|91|mrtglib.1|282|\*(C`datestr(time)\*(C'\fR |\&\f(CW\*(C`datestr(time)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|288|IX|.IX Item "timestamp" )         (rof_escape_sequence|91|mrtglib.1|289|\*(C`timestamp()\*(C'\fR |\&\f(CW\*(C`timestamp()\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|294|IX|.IX Item "setup_loghandlers" )         (rof_escape_sequence|91|mrtglib.1|295|\*(C`setup_loghandlers(filename)\*(C'\fR |\&\f(CW\*(C`setup_loghandlers(filename)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|302|IX|.IX Item "expistr" )         (rof_escape_sequence|91|mrtglib.1|303|\*(C`expistr(time)\*(C'\fR |\&\f(CW\*(C`expistr(time)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|309|IX|.IX Item "create_pid" )         (rof_escape_sequence|91|mrtglib.1|310|\*(C`create_pid()\*(C'\fR |\&\f(CW\*(C`create_pid()\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|315|IX|.IX Item "demonize_me" )         (rof_escape_sequence|91|mrtglib.1|316|\*(C`demonize_me()\*(C'\fR |\&\f(CW\*(C`demonize_me()\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|321|IX|.IX Item "populatecache" )         (rof_escape_sequence|91|mrtglib.1|322|\*(C`populatecache(\e%confcache, $host, $reread, $snmpoptshash)\*(C'\fR |\&\f(CW\*(C`populatecache(\e%confcache, $host, $reread, $snmpoptshash)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|339|IX|.IX Item "readconfcache" )         (rof_escape_sequence|91|mrtglib.1|340|\*(C`my $confcache = readconfcache($file)\*(C'\fR |\&\f(CW\*(C`my $confcache = readconfcache($file)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|345|IX|.IX Item "readfromconfcache" )         (rof_escape_sequence|91|mrtglib.1|346|\*(C`writeconfcache($confcache,$file)\*(C'\fR |\&\f(CW\*(C`writeconfcache($confcache,$file)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|351|IX|.IX Item "writeconfcache" )         (rof_escape_sequence|91|mrtglib.1|352|\*(C`writeconfcache($confcache,$file)\*(C'\fR |\&\f(CW\*(C`writeconfcache($confcache,$file)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|357|IX|.IX Item "storeincache" )         (rof_escape_sequence|91|mrtglib.1|358|\*(C`storeincache($confcache,$host,$method,$key,$value)\*(C'\fR |\&\f(CW\*(C`storeincache($confcache,$host,$method,$key,$value)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|361|IX|.IX Item "readfromcache" )         (rof_escape_sequence|91|mrtglib.1|362|\*(C`readfromcache($confcache,$host,$method,$key)\*(C'\fR |\&\f(CW\*(C`readfromcache($confcache,$host,$method,$key)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|365|IX|.IX Item "clearfromcache" )         (rof_escape_sequence|91|mrtglib.1|366|\*(C`clearfromcache($confcache,$host)\*(C'\fR |\&\f(CW\*(C`clearfromcache($confcache,$host)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|369|IX|.IX Item "debug" )         (rof_escape_sequence|91|mrtglib.1|370|\*(C`debug($type, $message)\*(C'\fR |\&\f(CW\*(C`debug($type, $message)\*(C'\fR )         (parse_manual_page_|249|mrtglib.1|375|IX|.IX Header "AUTHORS" )