Blame doc/mrtglib.txt

Packit 667938
MRTGLIB(1)                           mrtg                           MRTGLIB(1)
Packit 667938
Packit 667938
Packit 667938
Packit 667938
N?NA?AM?ME?E
Packit 667938
       MRTG_lib.pm - Library for MRTG and support scripts
Packit 667938
Packit 667938
S?SY?YN?NO?OP?PS?SI?IS?S
Packit 667938
        use MRTG_lib;
Packit 667938
        my ($configfile, @target_names, %globalcfg, %targetcfg);
Packit 667938
        readcfg($configfile, \@target_names, \%globalcfg, \%targetcfg);
Packit 667938
        my (@parsed_targets);
Packit 667938
        cfgcheck(\@target_names, \%globalcfg, \%targetcfg, \@parsed_targets);
Packit 667938
Packit 667938
D?DE?ES?SC?CR?RI?IP?PT?TI?IO?ON?N
Packit 667938
       MRTG_lib is part of MRTG, the Multi Router Traffic Grapher. It was
Packit 667938
       separated from MRTG to allow other programs to easily use the same
Packit 667938
       config files. The main part of MRTG_lib is the config file parser but
Packit 667938
       some other funcions are there too.
Packit 667938
Packit 667938
       $MRTG_lib::OS
Packit 667938
           Type of OS: WIN, UNIX, VMS
Packit 667938
Packit 667938
       $MRTG_lib::SL
Packit 667938
           _?S_?l_?a_?s_?h in the current OS.
Packit 667938
Packit 667938
       $MRTG_lib::PS
Packit 667938
           Path separator in PATH variable
Packit 667938
Packit 667938
       "readcfg"
Packit 667938
           "readcfg($file, \@targets, \%globalcfg, \%targetcfg [, $prefix,
Packit 667938
           \%extrules])"
Packit 667938
Packit 667938
           Reads a config file, parses it and fills some arrays and hashes.
Packit 667938
           The mandatory arguments are: the name of the config file, a ref to
Packit 667938
           an array which will be filled with a list of the target names, a
Packit 667938
           hashref for the global configuration, a hashref for the target
Packit 667938
           configuration.
Packit 667938
Packit 667938
           The configuration file syntax is:
Packit 667938
Packit 667938
            globaloption: value
Packit 667938
            targetoption[targetname]: value
Packit 667938
            aprefix*extglobal: value
Packit 667938
            aprefix*exttarget[target2]: value
Packit 667938
Packit 667938
           E.g.
Packit 667938
Packit 667938
            workdir: /var/stat/mrtg
Packit 667938
            target[router1]: 2:public@router1.local.net
Packit 667938
            14all*columns: 2
Packit 667938
Packit 667938
           The global config hash has the structure
Packit 667938
Packit 667938
            $globalcfg{configoption} = 'value'
Packit 667938
Packit 667938
           The target config hash has the structure
Packit 667938
Packit 667938
            $targetcfg{configoption}{targetname} = 'value'
Packit 667938
Packit 667938
           See mrtg-reference for more information about the MRTG
Packit 667938
           configuration syntax.
Packit 667938
Packit 667938
           "readcfg" can take two additional arguments to extend the config
Packit 667938
           file syntax. This allows programs to put their configuration into
Packit 667938
           the mrtg config file. The fifth argument is the prefix of the
Packit 667938
           extension, the sixth argument is a hash with the checkrules for
Packit 667938
           these extension settings. E.g. if the prefix is "14all" "readcfg"
Packit 667938
           will check config lines that begin with "14all*", i.e. all lines
Packit 667938
           like
Packit 667938
Packit 667938
            14all*columns: 2
Packit 667938
            14all*graphsize[target3]: 500 200
Packit 667938
Packit 667938
           against the rules in %extrules. The format of this hash is:
Packit 667938
Packit 667938
            $extrules{option} = [sub{$_[0] =~ m/^\d+$/}, sub{"Error message for $_[0]"}]
Packit 667938
                i.e.
Packit 667938
            $extrules{option}[0] -> a test expression
Packit 667938
            $extrules{option}[1] -> error message if test fails
Packit 667938
Packit 667938
           The first part of the array is a perl expression to test the value
Packit 667938
           of the option. The test can access this value in the variable
Packit 667938
           "$arg". The second part of the array is an error message to display
Packit 667938
           when the test fails. The failed value can be integrated by using
Packit 667938
           the variable "$arg".
Packit 667938
Packit 667938
           Config settings with an different prefix than the one given in the
Packit 667938
           "readcfg" call are not checked but inserted into _?%_?g_?l_?o_?b_?a_?l_?c_?f_?g and
Packit 667938
           _?%_?t_?a_?r_?g_?e_?t_?c_?f_?g.  Prefixed settings keep their prefix in the config
Packit 667938
           hashes:
Packit 667938
Packit 667938
            $targetcfg{'14all*graphsize'}{'target3'} = '500 200'
Packit 667938
Packit 667938
       "cfgcheck"
Packit 667938
           "cfgcheck(\@target_names, \%globalcfg, \%targetcfg,
Packit 667938
           \@parsed_targets)"
Packit 667938
Packit 667938
           Checks the configuration read by "readcfg". Checks the values in
Packit 667938
           the config for syntactical and/or semantical errors. Sets defaults
Packit 667938
           for some options.  Parses the "target[...]" options and filles the
Packit 667938
           array @parsed_targets ready for mrtg functions.
Packit 667938
Packit 667938
           The first three arguments are the same as for "readcfg". The fourth
Packit 667938
           argument is an arrayref which will be filled with the parsed target
Packit 667938
           defs.
Packit 667938
Packit 667938
           "cfgcheck" converts the values of target settings _?o_?p_?t_?i_?o_?n_?s, e.g.
Packit 667938
Packit 667938
            options[router1]: bits, growright
Packit 667938
Packit 667938
           to a hash:
Packit 667938
Packit 667938
            $targetcfg{'option'}{'bits'}{'router1'} = 1
Packit 667938
            $targetcfg{'option'}{'growright'}{'router1'} = 1
Packit 667938
Packit 667938
           This is not done by "readcfg" so if you don't use "cfgcheck" you
Packit 667938
           have to check the scalar variable _?$_?t_?a_?r_?g_?e_?t_?c_?f_?g_?{_?'_?o_?p_?t_?i_?o_?n_?'_?}_?{_?'_?r_?o_?u_?t_?e_?r_?1_?'_?}
Packit 667938
           (MRTG allows options to be separated by space or ',').
Packit 667938
Packit 667938
       "ensureSL"
Packit 667938
           "ensureSL(\$pathname)"
Packit 667938
Packit 667938
           Checks that the _?p_?a_?t_?h_?n_?a_?m_?e does not contain double path separators
Packit 667938
           and ends with a path separator. It uses $MRTG_lib::SL as path
Packit 667938
           separator which will be / or \ depending on the OS.
Packit 667938
Packit 667938
       "log2rrd"
Packit 667938
           "log2rrd ($router,\%globalcfg,\%targetcfg)"
Packit 667938
Packit 667938
           Convert log file to rrd format. Needs rrdtool.
Packit 667938
Packit 667938
       "datestr"
Packit 667938
           "datestr(time)"
Packit 667938
Packit 667938
           Returns the time given in the argument as a nicely formated date
Packit 667938
           string.  The argument has to be in UNIX time format (seconds since
Packit 667938
           1970-1-1).
Packit 667938
Packit 667938
       "timestamp"
Packit 667938
           "timestamp()"
Packit 667938
Packit 667938
           Return a string representing the current time.
Packit 667938
Packit 667938
       "setup_loghandlers"
Packit 667938
           "setup_loghandlers(filename)"
Packit 667938
Packit 667938
           Install signalhandlers for __DIE__ and __WARN__ making the errors
Packit 667938
           go the the specified destination. If filename is 'eventlog' mrtg
Packit 667938
           will log to the windows event logger.
Packit 667938
Packit 667938
       "expistr"
Packit 667938
           "expistr(time)"
Packit 667938
Packit 667938
           Returns the time given in the argument formatted suitable for HTTP
Packit 667938
           Expire-Headers.
Packit 667938
Packit 667938
       "create_pid"
Packit 667938
           "create_pid()"
Packit 667938
Packit 667938
           Creates a pid file for the mrtg daemon
Packit 667938
Packit 667938
       "demonize_me"
Packit 667938
           "demonize_me()"
Packit 667938
Packit 667938
           Puts the running program into background, detaching it from the
Packit 667938
           terminal.
Packit 667938
Packit 667938
       "populatecache"
Packit 667938
           "populatecache(\%confcache, $host, $reread, $snmpoptshash)"
Packit 667938
Packit 667938
           Reads the SNMP variables _?i_?f_?D_?e_?s_?c_?r, _?i_?p_?A_?d_?E_?n_?t_?I_?f_?I_?n_?d_?e_?x, _?i_?f_?P_?h_?y_?s_?A_?d_?d_?r_?e_?s_?s,
Packit 667938
           _?i_?f_?N_?a_?m_?e from the _?h_?o_?s_?t and stores the values in _?%_?c_?o_?n_?f_?c_?a_?c_?h_?e as
Packit 667938
           follows:
Packit 667938
Packit 667938
            $confcache{$host}{'Descr'}{ifDescr}{oid} = (ifDescr or 'Dup')
Packit 667938
            $confcache{$host}{'IP'}{ipAdEntIfIndex}{oid} = (ipAdEntIfIndex or 'Dup')
Packit 667938
            $confcache{$host}{'Eth'}{ifPhysAddress}{oid} = (ifPhysAddress or 'Dup')
Packit 667938
            $confcache{$host}{'Name'}{ifName}{oid} = (ifName or 'Dup')
Packit 667938
            $confcache{$host}{'Type'}{ifType}{oid} = (ifType or 'Dup')
Packit 667938
Packit 667938
           The value (at the right side of =) is 'Dup' if a value was
Packit 667938
           retrieved muliple times, the retrieved value else.
Packit 667938
Packit 667938
       "readconfcache"
Packit 667938
           "my $confcache = readconfcache($file)"
Packit 667938
Packit 667938
           Preload the confcache from a file.
Packit 667938
Packit 667938
       "readfromconfcache"
Packit 667938
           "writeconfcache($confcache,$file)"
Packit 667938
Packit 667938
           Store the current confcache into a file.
Packit 667938
Packit 667938
       "writeconfcache"
Packit 667938
           "writeconfcache($confcache,$file)"
Packit 667938
Packit 667938
           Store the current confcache into a file.
Packit 667938
Packit 667938
       "storeincache"
Packit 667938
           "storeincache($confcache,$host,$method,$key,$value)"
Packit 667938
Packit 667938
       "readfromcache"
Packit 667938
           "readfromcache($confcache,$host,$method,$key)"
Packit 667938
Packit 667938
       "clearfromcache"
Packit 667938
           "clearfromcache($confcache,$host)"
Packit 667938
Packit 667938
       "debug"
Packit 667938
           "debug($type, $message)"
Packit 667938
Packit 667938
           Prints the _?m_?e_?s_?s_?a_?g_?e on STDERR if debugging is enabled for type _?t_?y_?p_?e.
Packit 667938
           A debug type is enabled if _?t_?y_?p_?e is in array @main::DEBUG.
Packit 667938
Packit 667938
A?AU?UT?TH?HO?OR?RS?S
Packit 667938
       Rainer Bawidamann <Rainer.Bawidamann@rz.uni-ulm.de>
Packit 667938
Packit 667938
       (This Manpage)
Packit 667938
Packit 667938
Packit 667938
Packit 667938
2.17.7                            2018-07-13                        MRTGLIB(1)