From 5965e6b75271960b2a068d37cafb2d76d79b78ac Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Sun, 29 Sep 2024 11:18:28 +0300 Subject: Superkaramba: add GB format strings to memory sensor Added variants: %fm(b)g %um(b)g %fsg %usg %tmg %tsg Signed-off-by: Mavridis Philippe --- superkaramba/src/memsensor.cpp | 55 ++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/superkaramba/src/memsensor.cpp b/superkaramba/src/memsensor.cpp index 3223b0b..d3ee39b 100644 --- a/superkaramba/src/memsensor.cpp +++ b/superkaramba/src/memsensor.cpp @@ -288,7 +288,7 @@ void MemSensor::readValues() } #define SUB_FORMAT_STR(fstring, value) \ - format.replace(TQRegExp(#fstring, false), TQString::number((int)(value))); + format.replace(TQRegExp(#fstring, false), TQString::number((int)(value))) void MemSensor::update() { @@ -322,24 +322,32 @@ void MemSensor::update() format = "%um"; } - SUB_FORMAT_STR(%fmbp, (totalMem - usedMemNoBuffers) * 100.0 / totalMem) - SUB_FORMAT_STR(%fmb, (totalMem - usedMemNoBuffers) / 1024.0 + 0.5) - SUB_FORMAT_STR(%fmp, (totalMem - usedMem) * 100.0 / totalMem) - SUB_FORMAT_STR(%fm, (totalMem - usedMem) / 1024.0 + 0.5) - - SUB_FORMAT_STR(%umbp, usedMemNoBuffers * 100.0 / totalMem) - SUB_FORMAT_STR(%umb, usedMemNoBuffers / 1024.0 + 0.5) - SUB_FORMAT_STR(%ump, usedMem * 100.0 / totalMem) - SUB_FORMAT_STR(%um, usedMem / 1024.0 + 0.5) - - SUB_FORMAT_STR(%tm, totalMem / 1024.0 + 0.5) - - SUB_FORMAT_STR(%fsp, (totalSwap - usedSwap) * 100.0 / totalSwap) - SUB_FORMAT_STR(%fs, (totalSwap - usedSwap) / 1024.0 + 0.5) - SUB_FORMAT_STR(%usp, usedSwap * 100.0 / totalSwap) - SUB_FORMAT_STR(%us, usedSwap / 1024.0 + 0.5) - - SUB_FORMAT_STR(%ts, totalSwap / 1024.0 + 0.5) + SUB_FORMAT_STR(%fmbp, (totalMem - usedMemNoBuffers) * 100.0 / totalMem); + SUB_FORMAT_STR(%fmbg, (totalMem - usedMemNoBuffers) / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%fmb, (totalMem - usedMemNoBuffers) / 1024.0 + 0.5); + SUB_FORMAT_STR(%fmp, (totalMem - usedMem) * 100.0 / totalMem); + SUB_FORMAT_STR(%fmg, (totalMem - usedMem) / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%fm, (totalMem - usedMem) / 1024.0 + 0.5); + + SUB_FORMAT_STR(%umbp, usedMemNoBuffers * 100.0 / totalMem); + SUB_FORMAT_STR(%umbg, usedMemNoBuffers / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%umb, usedMemNoBuffers / 1024.0 + 0.5); + SUB_FORMAT_STR(%ump, usedMem * 100.0 / totalMem); + SUB_FORMAT_STR(%umg, usedMem / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%um, usedMem / 1024.0 + 0.5); + + SUB_FORMAT_STR(%tmg, totalMem / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%tm, totalMem / 1024.0 + 0.5); + + SUB_FORMAT_STR(%fsp, (totalSwap - usedSwap) * 100.0 / totalSwap); + SUB_FORMAT_STR(%fsg, (totalSwap - usedSwap) / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%fs, (totalSwap - usedSwap) / 1024.0 + 0.5); + SUB_FORMAT_STR(%usp, usedSwap * 100.0 / totalSwap); + SUB_FORMAT_STR(%usg, usedSwap / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%us, usedSwap / 1024.0 + 0.5); + + SUB_FORMAT_STR(%tsg, totalSwap / 1024.0 / 1024.0 + 1); + SUB_FORMAT_STR(%ts, totalSwap / 1024.0 + 0.5); meter->setValue(format); ++it; @@ -365,18 +373,19 @@ void MemSensor::setMaxValue( SensorParams *sp ) { f = "%um"; } - else if (f.endsWith("p")) { meter->setMax(100); } - else if (f == "%fm" || f == "%um" || f == "%fmb" || f == "%umb") { meter->setMax(getMemTotal() / 1024); } - - else if (f == "%fs" || f == "%us") + else if (f == "%fmg" || f == "%umg" || f == "%fmbg" || f == "%umbg") + { + meter->setMax(getMemTotal() / 1024 / 1024); + } + else if (f == "%fs" || f == "%us" || f == "%fsg" || f == "%usg") { meter->setMax(getSwapTotal() / 1024); } -- cgit v1.2.1