[mrtg] ifOperStatus and if-template problem

Jakub M burakozol at gmail.com
Thu Nov 13 11:35:15 CET 2008


Hello,

I have a small problem with generating proper cfg file. I want to
monitor a link status for my devices. I have made a template for
cfgmaker, but when I run mrtg with a generated cfg, I don't get any
results (no values on charts)

I run cfgmaker like this:

cfgmaker --show-op-down --global "WorkDir:
/home/user/Scripts/bunch/out/" --global "Options[_]: growright, gauge"
--if-template=link.template public at 192.168.xxx.xxx > mrtg.cfg



When I do normal snmpwalk, I get

IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.3 = INTEGER: down(2)
IF-MIB::ifOperStatus.4 = INTEGER: up(1)
...

My template file looks like this:

---------------------------------------------------------------------------------------------------------

if(not $problem_lines)
 {
   $target_lines .= <<ECHO;

WorkDir: /home/user/Scripts/bunch/out/

Target[$target_name]: ifOperStatus:$if_ref:$router_connect
SetEnv[$target_name]: MRTG_INT_IP="$if_ip" MRTG_INT_DESCR="$if_snmp_descr"
ECHO

   #~ if ($directory_name) {
       #~ $target_lines .= "Directory[$target_name]: $directory_name\n";
   #~ }

   $target_lines .= <<ECHO;
MaxBytes[$target_name]: 3
Unscaled[$target_name]: ymwd
Title[$target_name]: $html_desc_prefix$html_if_title_desc -- $sysname
PageTop[$target_name]: <h1>$html_desc_prefix$html_if_title_desc -- $sysname</h1>
                <div id="sysdetails">
                        <table>
                                <tr>
                                        <td>System:</td>
                                        <td>$sysname in $html_syslocation</td>
                                </tr>
                                <tr>
                                        <td>Maintainer:</td>
                                        <td>$html_syscontact</td>
                                </tr>
                                <tr>
                                        <td>Description:</td>
                                        <td>$html_if_description</td>
                                </tr>
                                <tr>
                                        <td>ifType:</td>
                                        <td>$html_if_type_desc
($if_type_num)</td>
                                </tr>
                                <tr>
                                        <td>ifName:</td>
                                        <td>$html_if_snmp_name</td>
                                </tr>
ECHO

   $target_lines .= <<ECHO if defined $if_port_name;
                                <tr>
                                        <td>Port Name:</td>
                                        <td>$if_port_name</td>
                                </tr>
ECHO

   #~ $target_lines .= <<ECHO if defined $if_pp_port_name;
                                #~ <tr>
                                        #~ <td>Port Name:</td>
                                        #~ <td>$if_pp_port_name</td>
                                #~ </tr>
#~ ECHO

   $target_lines .= <<ECHO;
                                <tr>
                                        <td>Max Speed:</td>
                                        <td>$if_speed_str</td>
                                </tr>
ECHO

   $target_lines .= <<ECHO if $if_ip;
                                <tr>
                                        <td>Ip:</td>
                                        <td>$if_ip ($if_dns_name)</td>
                                </tr>
ECHO

   $target_lines .= <<ECHO;
                        </table>
                </div>
ECHO
} else {
	$head_lines="";
	$problem_lines="";
	$target_lines="";
	$separator_lines="";
}

---------------------------------------------------------------------------------------------------------



More information about the mrtg mailing list