Updating branch refs/heads/master
to 6c48ddb56db7fadbd837417ef753d436e4381d58 (commit)
from 7bf887b3a7dd106b268cfb90da8a2033f582a769 (commit)
commit 6c48ddb56db7fadbd837417ef753d436e4381d58
Author: Florian Rivoal <[email protected]>
Date: Wed Oct 13 09:39:26 2010 +0900
Adjust the memory values to match the free
The free command takes kernel buffers into account, and systemload
didn't. Apply the patch provided in bug 4215 to make them match.
panel-plugin/memswap.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/panel-plugin/memswap.c b/panel-plugin/memswap.c
index 6c25bbd..1a453b1 100644
--- a/panel-plugin/memswap.c
+++ b/panel-plugin/memswap.c
@@ -47,6 +47,7 @@ static char MemInfoBuf[MEMINFOBUFSIZE];
static unsigned long MTotal = 0;
static unsigned long MFree = 0;
+static unsigned long MBuffers = 0;
static unsigned long MCached = 0;
static unsigned long MUsed = 0;
static unsigned long STotal = 0;
@@ -57,8 +58,8 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT,
gulong *MU, gulong *ST,
{
int fd;
size_t n;
- int o_MTotal, o_MFree, o_MCached, o_STotal, o_SFree;
- char *b_MTotal, *b_MFree, *b_MCached, *b_STotal, *b_SFree;
+ int o_MTotal, o_MFree, o_MBuffers, o_MCached, o_STotal, o_SFree;
+ char *b_MTotal, *b_MFree, *b_MBuffers, *b_MCached, *b_STotal, *b_SFree;
if ((fd = open("/proc/meminfo", O_RDONLY)) < 0)
{
@@ -83,6 +84,10 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT,
gulong *MU, gulong *ST,
if (b_MFree)
o_MFree = sscanf(b_MFree + strlen("MemFree"), ": %lu", &MFree);
+ b_MBuffers = strstr(MemInfoBuf, "Buffers");
+ if (b_MBuffers)
+ o_MBuffers = sscanf(b_MBuffers + strlen("Buffers"), ": %lu",
&MBuffers);
+
b_MCached = strstr(MemInfoBuf, "Cached");
if (b_MCached)
o_MCached = sscanf(b_MCached + strlen("Cached"), ": %lu", &MCached);
@@ -95,7 +100,7 @@ gint read_memswap(gulong *mem, gulong *swap, gulong *MT,
gulong *MU, gulong *ST,
if (b_SFree)
o_SFree = sscanf(b_SFree + strlen("SwapFree"), ": %lu", &SFree);
- MFree += MCached;
+ MFree += MCached + MBuffers;
MUsed = MTotal - MFree;
SUsed = STotal - SFree;
*mem = MUsed * 100 / MTotal;
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits