View Single Post
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#52
Originally Posted by sixwheeledbeast View Post
The easiest way is to post the code.
Can't get lost in translation then.
BTW thanks.

Code:
...snip...
#Get Swap size from /proc/swaps
swapsize=$(awk '{if ($1=="'"/dev/$disk"'") print $3}' /proc/swaps)
#Divide by 1024 to get swap size in megabytes
swapsizembytes=$(($swapsize/1024))
...snip...
Here it is okay to divide by 1024
I spoke about getting number of blocks from /proc/diskstats. Each block is 512 bytes.
You have to divide by 2 to get kB.
And then of course by 2048 to get MB.
Code:
[B]umbytes=$(($ublocks/2048))
And forget about bytes and kbytes here.

To make it bullet proof:
Code:
echo $ublocks ublocks
#Multiply blocks by 512 to get used bytes
#ubytes=$(($ublocks*512))
#Calculate used bytes into Kb, Mb and Gb
echo $ubytes ubytes
#ukbytes=$(($ubytes/1024))
##ukbytes=$(($ublocks/2))
##umbytes=$(($ukbytes/1024))
umbytes=$(($ublocks/2048))
#ugbytes=$(($ubytes/1024/1024/1024))
ugbytes=$(($umbytes/1024))
And of course rely only on umbytes from this line on in your code (needs review which I did not do ).

Originally Posted by sixwheeledbeast View Post
I use my device heavily during work and only use my 800MB swap space in 4 days. It's possible due to "Swappolube" VM settings too.
I also use swappolube with (almost) default settings.

Originally Posted by sixwheeledbeast View Post
When/If someone gets to xyz uptime and it fails then this is a bug. No? I hate bugs however slight
Yes.
But it is unrealistic to think anyone will ever reach TB swap usage on N900, or? (remember the 2k date time problem? )
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature

Last edited by peterleinchen; 2013-01-26 at 13:52.
 

The Following User Says Thank You to peterleinchen For This Useful Post: