summaryrefslogtreecommitdiffstats
path: root/zfs
diff options
context:
space:
mode:
authorRoss Williams <ross@ross-williams.net>2019-07-07 02:37:02 +0000
committerRoss Williams <ross@ross-williams.net>2019-07-07 22:57:15 -0400
commit070fe90461182743fabb029415fc1bc59be14f3f (patch)
treec1ce5424b6676e2b81ae568f748f3eb5dbea09ea /zfs
parenta93edde1a21e533472b5d443002032260b5bd066 (diff)
ZFS arcstats for Linux
If no pools are imported (ARC size == 0) or the ZFS module is not in the kernel (/proc/spl/kstat/zfs/arcstats does not exist), then the Meter reports "Unavailable".
Diffstat (limited to 'zfs')
-rw-r--r--zfs/ZfsArcMeter.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c
index e12c46e2..ebd80992 100644
--- a/zfs/ZfsArcMeter.c
+++ b/zfs/ZfsArcMeter.c
@@ -41,27 +41,32 @@ static void ZfsArcMeter_display(Object* cast, RichString* out) {
char buffer[50];
Meter* this = (Meter*)cast;
- RichString_write(out, CRT_colors[METER_TEXT], ":");
- Meter_humanUnit(buffer, this->total, 50);
- RichString_append(out, CRT_colors[METER_VALUE], buffer);
- Meter_humanUnit(buffer, this->values[5], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " Used:");
- RichString_append(out, CRT_colors[METER_VALUE], buffer);
- Meter_humanUnit(buffer, this->values[0], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " MFU:");
- RichString_append(out, CRT_colors[ZFS_MFU], buffer);
- Meter_humanUnit(buffer, this->values[1], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " MRU:");
- RichString_append(out, CRT_colors[ZFS_MRU], buffer);
- Meter_humanUnit(buffer, this->values[2], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " Anon:");
- RichString_append(out, CRT_colors[ZFS_ANON], buffer);
- Meter_humanUnit(buffer, this->values[3], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " Hdr:");
- RichString_append(out, CRT_colors[ZFS_HEADER], buffer);
- Meter_humanUnit(buffer, this->values[4], 50);
- RichString_append(out, CRT_colors[METER_TEXT], " Oth:");
- RichString_append(out, CRT_colors[ZFS_OTHER], buffer);
+ if (this->values[5] > 0) {
+ RichString_write(out, CRT_colors[METER_TEXT], ":");
+ Meter_humanUnit(buffer, this->total, 50);
+ RichString_append(out, CRT_colors[METER_VALUE], buffer);
+ Meter_humanUnit(buffer, this->values[5], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " Used:");
+ RichString_append(out, CRT_colors[METER_VALUE], buffer);
+ Meter_humanUnit(buffer, this->values[0], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " MFU:");
+ RichString_append(out, CRT_colors[ZFS_MFU], buffer);
+ Meter_humanUnit(buffer, this->values[1], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " MRU:");
+ RichString_append(out, CRT_colors[ZFS_MRU], buffer);
+ Meter_humanUnit(buffer, this->values[2], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " Anon:");
+ RichString_append(out, CRT_colors[ZFS_ANON], buffer);
+ Meter_humanUnit(buffer, this->values[3], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " Hdr:");
+ RichString_append(out, CRT_colors[ZFS_HEADER], buffer);
+ Meter_humanUnit(buffer, this->values[4], 50);
+ RichString_append(out, CRT_colors[METER_TEXT], " Oth:");
+ RichString_append(out, CRT_colors[ZFS_OTHER], buffer);
+ } else {
+ RichString_write(out, CRT_colors[METER_TEXT], " ");
+ RichString_append(out, CRT_colors[FAILED_SEARCH], "Unavailable");
+ }
}
MeterClass ZfsArcMeter_class = {

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