Bug 138696 - network sensor doesn't work if the interface name doesn't have leading whitespace
Summary: network sensor doesn't work if the interface name doesn't have leading whites...
Status: RESOLVED UNMAINTAINED
Alias: None
Product: superkaramba
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Ryan Nickell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-12 01:02 UTC by Evan Teran
Modified: 2011-02-28 09:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evan Teran 2006-12-12 01:02:43 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages
Compiler:          gcc 4.1.1 
OS:                Linux

network sensor doesn't work if the interface name doesn't have leading whitespace. Basically line 115 in networksensor.cpp has a small flaw in it which prevents the "in/out" from properly being read.

As you can see form the regular expression:

QRegExp rx( "\\W+"+device+":(\\d+)(?:\\D+\\d+){7}\\D+(\\d+)", false);

it is expecting at least one whitespace character, however for longer device names, there isn't a leading whitespace.

changing the line to this seems to fix it:

QRegExp rx( "\\W*"+device+":(\\d+)(?:\\D+\\d+){7}\\D+(\\d+)", false);

which basically changes it from "1 or more whitespace" to "0 or more whitespace", i think this is more appropriate.

Also, I feel that on Linux builds should attempt to use the sys file system to get this information as it is broken up in a manner which is trivial to parse:

the directory:

/sys/class/net/<device>/ has several files describing just about everything needed about a given interface, and /sys/class/net/<device>/statistics has several files which have all the necessary stats on an individual basis (no need to parse, just read the file).

Evan Teran