Date: Sat, 6 Sep 2003 16:48:08 +0200 From: Alexander Leidinger <Alexander@Leidinger.net> To: gnome@freebsd.org Subject: I've played around with gdesklets (patch included for interested parties) Message-ID: <20030906164808.3cd86d76.Alexander@Leidinger.net>
next in thread | raw e-mail | index | archive | help
Hi, I've played a little bit around, but I have no time to proceed further... Here's a patch for those which want to get useful numbers out of Psi's Network-0.1.4 tarball... at least it should spit out useful numbers, the Font<something> desklet is missing, so I wasn't able to fully test it. ---snip--- --- /home/netchild/.gdesklets/Sensors/Network/__init__.py.orig Sat Sep 6 16:03:47 2003 +++ /home/netchild/.gdesklets/Sensors/Network/__init__.py Sat Sep 6 16:45:26 2003 @@ -18,7 +18,7 @@ class Network(Sensor): - def __init__(self, interface = "eth0", interval = "1000"): + def __init__(self, interface = "lo0", interval = "1000"): global _; _ = i18n.Translator("memory-sensor") @@ -45,7 +45,7 @@ self._add_thread(self.__command_thread) - fd = open("/proc/net/dev", "r") + fd = os.popen("ifconfig -a | grep mtu", "r") data = fd.read() fd.close() data = data.splitlines() @@ -60,7 +60,7 @@ continue def __get_net_ip(self,device) : - fd = open("/proc/net/arp", "r") + fd = popen("ifconfig " + device, "r") data = fd.read() fd.close() lines = data.splitlines() @@ -69,24 +69,22 @@ l = l.strip() fields = l.split() - if fields[5]==device: - return fields[0] + if fields[0]=="inet": + return fields[1] return "(no ip for this interface)" def __get_net_in_out(self,device) : - fd = open("/proc/net/dev", "r") + fd = popen("netstat -b -I " + device + " | grep Link", "r") data = fd.read() fd.close() lines = data.splitlines() for l in lines[:]: l = l.strip() - l = l.replace(":"," ") fields = l.split() - if fields[0]==device: - return int(fields[1]),int(fields[9]) + return int(fields[6]),int(fields[8]) print "device not found" return 0,0 ---snip--- Bye, Alexander. -- Secret hacker rule #11: hackers read manuals. http://www.Leidinger.net Alexander @ Leidinger.net GPG fingerprint = C518 BC70 E67F 143F BE91 3365 79E2 9C60 B006 3FE7
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030906164808.3cd86d76.Alexander>