[mrtg] Re: req: help with templates and filters

Tim Sheets TSheets at illinois.net
Tue Aug 19 04:17:03 MEST 2003


Hello again,

Well, what I lack in programming skills, I make up in persistence! :-)

I figured out what I was doing wrong (basic logic problem).

I changed '--if-filter=($default_iftype && ($if_type!=134 || $if_type!=166))'
to '--if-filter=($default_iftype && $if_type!=134 && $if_type!=166)' and that took care fo the if-filter (it must not have worked by itself like I initially thought).

The if-template fix was basically the same.

Oh well, hopefully someone else will find this useful in the archives.

Tim


-----Original Message-----
From:	Tim Sheets
Sent:	Mon 8/18/2003 8:26 PM
To:	mrtg at list.ee.ethz.ch
Cc:	
Subject:	[mrtg] req: help with templates and filters
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;

ECHO

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

$target_lines .= <<ECHO;

Target[$target_name]: 1.3.6.1.4.1.9.2.1.57.0&1.3.6.1.4.1.9.2.1.58.0:$router_connect
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
Legend2[$target_name]:
Legend3[$target_name]: Average 5 minute CPU Utilization
Legend4[$target_name]:
LegendI[$target_name]: &nbsp;CPU Load:
LegendO[$target_name]:
PageTop[$target_name]: <H1> $router_name CPU Utilization</H1>
   <TABLE>
     <TR><TD>System:</TD><TD>$sysname in $html_syslocation</TD></TR>
     <TR><TD>Maintainer:</TD><TD>$html_syscontact</TD></TR>
   </TABLE>
 <BR>
ECHO


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!!

Tim

--
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





--
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