From 070fe90461182743fabb029415fc1bc59be14f3f Mon Sep 17 00:00:00 2001 From: Ross Williams Date: Sun, 7 Jul 2019 02:37:02 +0000 Subject: 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". --- zfs/ZfsArcMeter.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'zfs') 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 = { -- cgit v1.2.3