summaryrefslogtreecommitdiffstats
path: root/SwapMeter.c
diff options
context:
space:
mode:
authorDavid Zarzycki <dave@znu.io>2021-01-07 08:38:18 -0500
committerBenBE <BenBE@geshi.org>2021-01-11 20:27:47 +0100
commit37e186fd6626e83f51d0267052677355575964d4 (patch)
treec3212ebbc5a948c4ede190defadd8f56e097d45b /SwapMeter.c
parentf4404effa45ce378a8a72f2fff9641c7d7a0cc6f (diff)
Linux: Add SwapCached to the swap meter
According to the Linux kernel documentation, "SwapCached" tracks "memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn't need to be swapped out AGAIN because it is already in the swapfile. This saves I/O)."
Diffstat (limited to 'SwapMeter.c')
-rw-r--r--SwapMeter.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/SwapMeter.c b/SwapMeter.c
index e39cfd9f..81f006ec 100644
--- a/SwapMeter.c
+++ b/SwapMeter.c
@@ -14,7 +14,8 @@ in the source distribution for its full text.
static const int SwapMeter_attributes[] = {
- SWAP
+ SWAP,
+ SWAP_CACHE
};
static void SwapMeter_updateValues(Meter* this, char* buffer, size_t size) {
@@ -38,6 +39,12 @@ static void SwapMeter_display(const Object* cast, RichString* out) {
Meter_humanUnit(buffer, this->values[0], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:");
RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer);
+
+#ifdef HTOP_LINUX
+ Meter_humanUnit(buffer, this->values[1], sizeof(buffer));
+ RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
+ RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer);
+#endif
}
const MeterClass SwapMeter_class = {
@@ -48,7 +55,7 @@ const MeterClass SwapMeter_class = {
},
.updateValues = SwapMeter_updateValues,
.defaultMode = BAR_METERMODE,
- .maxItems = 1,
+ .maxItems = 2,
.total = 100.0,
.attributes = SwapMeter_attributes,
.name = "Swap",

© 2014-2024 Faster IT GmbH | imprint | privacy policy