in All availableThis forumThis topic
Author Message
Zucca
Veteran

Joined: 14 Jun 2007
Posts: 1290
Location: KUUSANKOSKI, Finland

Posted: Wed Jul 16, 2008 8:45 pm    Post subject: conky: how to overcome 32-bit data limit

All you who use Conky as your system monitor, here's a very short guide how to overcome 32-bit integer limitation with data transfers.

Introduction (Skip if you know what's 32-bit data limit)
From wikipedia:
 Quote: In computer architecture, 32-bit integers, memory addresses, or other data units are those that are at most 32 bits (4 octets) wide. Also, 32-bit CPU and ALU architectures are those that are based on registers, address buses, or data buses of that size. 32-bit is also a term given to a generation of computers in which 32-bit processors were the norm. The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295 or −2,147,483,648 through 2,147,483,647 using two's complement encoding. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory. The external address and data buses are often wider than 32 bits but both of these are stored and manipulated internally in the processor as 32-bit quantities. For example, the Pentium Pro processor is a 32-bit machine, but the external address bus is 36 bits wide, and the external data bus is 64 bits wide.

That is the reason why for example in ifconfig the data transfer seems to start from zero after reaching about 4 gigabytes.
Here's a little presentation what's the difference between 32- and 64-bit architectures in this cituation:
 Code: ~ \$ calc C-style arbitrary precision calculator (version 2.12.1.5) Calc is open software. For license details type:  help copyright [Type "exit" to exit, or "help" for help.] ; 2^32         4294967296 ; 2^64         18446744073709551616 ; 2^32/1024/1024         4096 ; 2^64/1024/1024         17592186044416 ; exit

As you can see. Lines containing /1024/1024 at the end divide the resulting bytes to megabytes. Now.. if you have 64-bit computer - don't waste your time here. It will take ages to reach 17592186044416 megabytes (16777216 terabytes!!!) with current consumer targeted speeds. If you have 32-bit computer there's the 4096 megabyte (4Gb) limit. Here's how you can overcome that limit in Conky.

Bang a gong, let's get it on

You need to install it:
 Code: emerge vnstat

Then (as root) add one of your network interfaces to be monitored:
 Code: vnstat -u -i eth0
(replace eth0 with the network interface you want to be monitored)

Then I STRONGLY suggest you to edit the /etc/cron.hourly/vnstat and uncomment the lines there (instructions are inside the file).
NOTE: If you transfer much data you might want to vnstat update it's database more frequently than just once in a hour.
From 'man vnstat':
 Quote: RESTRICTIONS Updates needs to be executed at least as often as it is possible for the interface to generate enough traffic to wrap the kernel interface traffic counter. Otherwise it is possible that some traffic won't be seen. This isn't an issue for 64 bit kernels but at least one update every hour is always required in order to provide proper input. With 32 bit kernels the maximum time between two updates depends on how fast the interface can transfer 4 GB. Calculated theoretical times are: 10 Mbit: 54 minutes 100 Mbit: 5 minutes 1000 Mbit: 30 seconds However, for 1000 Mbit interfaces updating once every minute is usually a working solution. Estimated traffic values are likely to be somewhat inaccurate if daily traffic is low because only the MB counter is used to calculate the estimate.

Now all you need is a small code to add into your ~/.conkyrc (below the line where 'TEXT' reads) in the place where you want conky to show data transfers.
Here's two examples:
In megabytes use:
 Code: Tx: \${execi 60 vnstat --dumpdb | sed -e '/^totaltx;/!d' -e 's/^.*;//'}MiB | Rx: \${execi 60 vnstat --dumpdb | sed -e '/^totalrx;/!d' -e 's/^.*;//'}MiB

In gigabytes you have to use a bit more complex code (I belive there are many more simple ways to do this):
 Code: Tx: \${execi 60 ( echo "scale=1" && vnstat --dumpdb | sed -e '/^totaltx;/!d' -e 's/^.*;\(.*\)\$/\1\/1024/' ) | bc}GiB | Rx: \${execi 60 ( echo "scale=1" && vnstat --dumpdb | sed -e '/^totalrx;/!d' -e 's/^.*;\(.*\)\$/\1\/1024/' ) | bc}GiB

Note that I used 60 second interval here, so this won't bother your cpu too much. ;)

And finally: All the improvement's are welcome. :)
_________________
..: Zucca :..

 Code: ERROR: '--failure' is not an option. Aborting...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT Page 1 of 1

 Jump to: Select a forum Assistance----------------News & AnnouncementsFrequently Asked QuestionsInstalling GentooMultimediaDesktop EnvironmentsNetworking & SecurityKernel & HardwarePortage & ProgrammingGamers & PlayersOther Things GentooUnsupported Software Discussion & Documentation----------------Documentation, Tips & TricksGentoo ChatGentoo Forums FeedbackOff the WallDuplicate Threads International Gentoo Users----------------中文 (Chinese)DutchFinnishFrenchDeutsches Forum (German)  Diskussionsforum  Deutsche DokumentationGreekForum italiano (Italian)  Forum di discussione italiano  Risorse italiane (documentazione e tools)Polskie forum (Polish)  Instalacja i sprzęt  Polish OTWPortuguese  Documentação, Ferramentas e DicasRussianScandinavianSpanishOther Languages Architectures & Platforms----------------Gentoo on AMD64Gentoo on ARMGentoo on PPCGentoo on SparcGentoo on Alternative ArchitecturesGentoo for Mac OS X (Portage for Mac OS X)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum