[mrtg] Graphing by interfacename - Case insensitive?

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Mon Mar 26 18:00:55 CEST 2018


>> > Hi All
>> >
>> > I have a googled, and read through various forums, and have had little
>> > luck.
>> >
>> > Im currently using the graph by interface name to graph some dynamic
>> > interfaces. it works brilliantly.
>> >
>> > However, my biggest problem at the moment is that sometimes the users
>> > change the case of the interface name, and then it stops graphing.
>> >
>> > Is there any way to make this case insensitive?
>>
>> That's probably just a matter of changing a regular expression.
>>
>> But....
>>
>> If your users can change interface names, what's there to stop them from
>> changing the name in something other than just a difference in case ?

> Its their username, so its kinda fixed :-)

Ack.

If at all possible, I would fix that problem. For instance by modifying a
login routine to make the submitted name lower case, or compare case
sensitive against their existing name and refuse other spellings.

A user will then have one name instead of many. This may be beneficial for
log files (also consider compression), other processes, and last but not
least MRTG won't have a problem anymore.

Normalizing the username in this way should not be a problem. If you
already have two different users "username" and "UserName", then they can
login using the other's id, so then your problems are much bigger than
just MRTG and you should really focus on the login, not on MRTG.

So, given the fact that normalizing the name is not problematic, but
normalizing it in the login process is impossible, then the next option is
to normalize it in the mrtg or cfgmaker source.

Again, each user will have just one name, no matter what input he gives at
login. I chose all lower case but of course you can implement it
differently if so desired.


If you really need to work around this problem on the MRTG side, it
probably involves source hacking.

It has been too long ago since I've been hacking the source, so I can only
offer some general suggestions.

cfgmaker will query the device and find those usernames (as interface
names). MRTG will query those names and forward it to rateup or rrdtool to
keep track of the data.

First of all: find out where the problem really is. Some userName logs in
as UserName and a week later as Username, cfgmaker will find those new
names and MRTG creates new logfiles.

What happens if you query the device always with all lower case?  So even
if UsErNaMe logs in, can you snmpget data on interface username ?

If so, the easiest is to hack cfgmaker and let it make interface names
lower case. After that, each user has only one name (at the MRTG side this
time) and MRTG won't have a problem anymore.


If that's not working, then you will have to modify mrtg.pl so that it
will send a sanitized version of the name to rateup or rrdtool.  You will
need to keep the original name to talk to the device, and write the data
to it's normalized form.

In other words, users Username, userName and UserName will all result in
interface name "username" as far as data storage is concerned, but will
still use the original form "Username" etc. to query your device.

Again, each user has only one name as far as MRTG is concerned.

check functions readtargets() and getcurrent() in mrtg.pl

pseudo code:
1: query device $deviceName interface $ifName
2: retrieve old data from lowercase($ifName)
3: write new data to lowercase($ifName)

1 will get data for interface UserName from your device
2,3 will use file username.log or username.rrd


HTH
Alex




More information about the mrtg mailing list