[mrtg] Dealing with carriage returns and ^M characters returned by $sysdescr

Greg.Volk at edwardjones.com Greg.Volk at edwardjones.com
Wed Aug 3 17:46:48 MEST 2005


I am trying to incorporate the $sysdescr data into my MRTG configs to 
present
more information about a given device such as software version, etc. So 
far
I've been able to do this with non cisco devices (firewalls, proxies, 
filers, etc)
but when I attempt it with cisco IOS based devices, $sysdescr comes back
with a string that contains embedded carriage returns and/or ^M 
characters.

Normally I wouldn't care about these carriage returns and just let the 
HTML
formatting take care of it, but they make they end up making the config 
unusable because MRTG and 14all.cgi think that parts of the $sysdescr 
data
are config file directives which result in "line xxx doesn't make any 
sense" 
errors.

Here's an example:

YLegend[mycisco-cpu]: Percentage CPU load
ShortLegend[mycisco-cpu]: %
Directory[mycisco-cpu]: mycisco
Legend1[mycisco-cpu]: Avg 1 min CPU Utilization in %
Legend2[mycisco-cpu]: Avg 5 min CPU Utilization in %
LegendI[mycisco-cpu]:  CPU Load:
LegendO[mycisco-cpu]:  CPU Load:
WithPeak[mycisco-cpu]: ywm
MaxBytes[mycisco-cpu]: 100
Options[mycisco-cpu]: growright, gauge, nopercent
Unscaled[mycisco-cpu]: dwmy
Title[mycisco-cpu]: mycisco CPU load
Target[mycisco-cpu]: 
1.3.6.1.4.1.9.2.1.57.0&1.3.6.1.4.1.9.2.1.58.0:public at mycisco
PageTop[mycisco-cpu]: <H1>mycisco CPU load</H1>
  <TABLE>
    <TR><TD>System:</TD><TD>mycisco in comp_room</TD></TR>
    <TR><TD>Maintainer:</TD><TD>NS</TD></TR>
    <TR><TD VALIGN="top">Description:</TD><TD>mycisco CPU load<br>Cisco 
^M
Internetwork Operating System Software IOS (tm) c6sup2_rp Software^M
(c6sup2_rp-JSV-M), Version 12.1(22)E1, EARLY DEPLOYMENT RELEASE ^M
SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport ^M
Copyright (c) 1986-2004 by cisco Systems, Inc.</TD></TR>
    <TR><TD>ifType:</TD><TD>N/A</TD></TR>
    <TR><TD>Resource:</TD><TD>CPU.</TD></TR>
  </TABLE>


So MRTG and 14all.cgi get hung up in the Description section. They try 
to intrepret
"Internetwork", "(c6sup2_rp-JSV-M)", "SOFTWARE", and "Copyright" as 
config
directives since they are at the beginning of new lines.

I need to be able to strip out the carriage returns and ^M characters 
so that 
$sysdescr is one contigious line. I did that manually with one config 
and it worked 
fine. Can anyone think of a way to do this? I'd rather not go piping my 
configs
through a bunch of sed ugliness, but if that's the only way around it 
then I'll
entertain the idea. Oddly enough I've only run into the problem with 
cisco IOS devices, 
everything else seems to have a MRTG friendly $sysdescr variable.

I've looked at the bad config files in a hex editor and the hex values 
are
0x0d (carriage return?) and 0x0a (^M character). If I could delete both 
of these
and replace them with space characters that would fix my problem. So 
far I
haven't been able to figure out how to do this in an automated fashion.



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



More information about the mrtg mailing list