Bug 138696

Summary: network sensor doesn't work if the interface name doesn't have leading whitespace
Product: superkaramba Reporter: Evan Teran <eteran>
Component: generalAssignee: Ryan Nickell <p0z3r>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: lamarque
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

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