diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2024-09-29 11:18:28 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2024-10-02 21:36:51 +0300 |
commit | 2c4a3e7f855038e1e66022aad41462793ac79215 (patch) | |
tree | f7d4c3f8ac79ad7934a107bc198685aa8fea8e5b | |
parent | 6b7d5441cc35740ac25ebf77c8e0193db95a0fa1 (diff) | |
download | tdeutils-2c4a3e7f855038e1e66022aad41462793ac79215.tar.gz tdeutils-2c4a3e7f855038e1e66022aad41462793ac79215.zip |
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 <mavridisf@gmail.com>
(cherry picked from commit 5965e6b75271960b2a068d37cafb2d76d79b78ac)
-rw-r--r-- | superkaramba/src/memsensor.cpp | 55 |
1 files 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); } |