[mrtg] req: help with templates and filters

Tim Sheets TSheets at illinois.net
Tue Aug 19 03:26:40 MEST 2003

Hello all,

I have been using MRTG for several years, and tried quite a few things with it, and find myself venturing into new territory once again.  Today I decided to try out using host-templates and if-filters.

I can get either one of these to work, but not together.  Then, I tried to use an if-template instead of the if-filter (not sure I had the if-filter working).

Here is the command line I used for the if-filter and host-template:

cfgmaker --global "Options[_]: growright,Bits" \
--global "WithPeak[_]: wmy" \
--global "Directory[_]: mycore" \
--ifref=descr \
--ifdesc=alias \
--host-template=test-template \
'--if-filter=($default_iftype && ($if_type!=134 || $if_type!=166))' \
--snmp-options=:::::2 \
--output mycore-test.cfg \
secret at myrouter.net

Here is the template file I am using:

$head_lines .= <<ECHO;


my $target_name = $router_name . "-cpu";

$target_lines .= <<ECHO;

YLegend[$target_name]: CPU Utilization
ShortLegend[$target_name]: %
MaxBytes[$target_name]: 100
WithPeak[$target_name]: wmy
Options[$target_name]: nopercent, gauge, unknaszero, growright
Unscaled[$target_name]: dwmy
Title[$target_name]: $router_name CPU Utilization
Colours[$target_name]: GREEN#00eb0c,BLUE#1000ff,BLUE#1000ff,VIOLET#ff00ff
Legend1[$target_name]: Average 1 minute CPU Utilization
Legend3[$target_name]: Average 5 minute CPU Utilization
LegendI[$target_name]: &nbsp;CPU Load:
PageTop[$target_name]: <H1> $router_name CPU Utilization</H1>
     <TR><TD>System:</TD><TD>$sysname in $html_syslocation</TD></TR>

In this scenario, the template works, but the if-filter seems to be ignored (but if I leave out the host-template, the if-filter does work).

So, that's when I replaced the if-filter reference with an if-template.  Here is what I was trying:

if($if_type_num!=134 || $if_type_num!=166) {
   $target_lines = $default_target_lines;

Basically, I want the interface types of 134 and 166 to be commented out.  I had also tried keeping in the $default_iftype with an '&&' like on the command line, but didn't see a reference to that in the if-filter section of the manual.

I am running this on a RedHat 7.3 box with MRTG 2.9.28.

If anyone could help out with what I am doing wrong, I would greatly appreciate it!!


Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the mrtg mailing list