summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-09-29 11:18:28 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-09-30 13:53:39 +0300
commit5965e6b75271960b2a068d37cafb2d76d79b78ac (patch)
treedc055c18da4a443d8c3c05aded00f33ef888f676
parent1f70d8fa2f268d26374a8c138648fc75edbd73dd (diff)
downloadtdeutils-5965e6b75271960b2a068d37cafb2d76d79b78ac.tar.gz
tdeutils-5965e6b75271960b2a068d37cafb2d76d79b78ac.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>
-rw-r--r--superkaramba/src/memsensor.cpp55
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);
}