[mrtg] Template problem

Michael Grice grice at binc.net
Sun Jan 19 00:24:25 MET 2003


I am running into some issues with templates. Specifically, it seems as
if running snmpget from within a host template results in a failure
(i.e., no such name error, etc.), then the next interface is commented
out. I have found a workaround, and I'll let you decide if this is a bug
or if I don't understand how the templates are supposed to work.

BTW, I'm running mrtg 2.9.25 on Solaris 8 with perl 5.8.

This template (simplified quite a bit from what I actually use) works
fine:

my ($foo_bar) = snmpget($router_connect, 'sysDescr');

I'm using cfgmaker with the --host-template option and not the
--if-template option.

Results (addresses, etc., munged to protect the guilty):

### Interface 1 >> Descr: 'sc0' | Name: 'sc0' | Ip: '192.168.10.7' |
Eth: '00-05-9a-b0-ff-ff' ###

Target[switch.foo.com_sc0]: #sc0:not_public at switch.foo.com:
SetEnv[switch.foo.com_sc0]: MRTG_INT_IP="192.168.10.7" MRTG_INT_DESCR="sc0"

This template does not:

my ($foo_bar) = snmpget($router_connect,
  '1.3.6.1.9.19.19.19.19.19.19.19.19');

The results:

### Interface 1 >> Descr: 'sc0' | Name: 'sc0' | Ip: '192.168.10.7' | Eth: '00-05-9a-b0-ff-ff' ###
### The following interface is commented out because:
### * got 'Received SNMP response with error code
###       error status: noSuchName
###       index 1 (OID: 1.3.6.1.9.19.19.19.19.19.19.19.19)
###     SNMPv1_Session (remote host:
"switch.foo.com" [1.1.1.1].161)
###                       community: "not_public"
###                      request ID: 1347970036
###                     PDU bufsize: 8000 bytes
###                         timeout: 2s
###                         retries: 5
###                         backoff: 1)' from interface when trying to
query
#
# Target[switch.foo.com_sc0]: #sc0:not_public at switch.foo.com:
# SetEnv[switch.foo.com_sc0]: MRTG_INT_IP="192.168.10.7" MRTG_INT_DESCR="sc0"

Now for the workaround. IsCounterBroken() looks to see if
$SNMP_Session::errmsg is defined and returns an error if it is. If I
change my error template to the following, the interface gets added to
the config file properly:

local $SNMP_Session::errmsg;
my ($foo_bar) = snmpget($router_connect,
'1.3.6.1.9.19.19.19.19.19.19.19.19');

Results:

### Interface 1 >> Descr: 'sc0' | Name: 'sc0' | Ip: '192.168.10.7' | Eth: '00-05-9a-b0-ff-ff' ###

Target[switch.foo.com_sc0]: #sc0:not_public at switch.foo.com:
SetEnv[switch.foo.com_sc0]: MRTG_INT_IP="192.168.10.7" MRTG_INT_DESCR="sc0"

Is this a reasonable workaround? I don't understand the code well enough
(yet) to suggest any changes to cfgmaker (assuming such is necessary)
that won't break something else. Nor have I looked to see if there are
any problems using snmpget or snmpwalk in the interface configuration
is causing any problems (I will later, since I am using snmpget to see
if certain oids are supported for particular interfaces). 

Any other advice on using the templates?
--Michael

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