aboutsummaryrefslogtreecommitdiffstats
path: root/zfs
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
committerDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
commitf3147ea2d1598914c2db53e8cfb34c8ff81e2ff4 (patch)
tree3ee82b2af2ab3d38b6e4b07f3994516aac72f742 /zfs
parentdf568a576f7b44ac5a2b9b7222c7f39d9932f626 (diff)
downloaddebian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.gz
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.bz2
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.zip
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'zfs')
-rw-r--r--zfs/ZfsArcMeter.c104
-rw-r--r--zfs/ZfsArcMeter.h22
-rw-r--r--zfs/ZfsArcStats.c24
-rw-r--r--zfs/ZfsArcStats.h27
-rw-r--r--zfs/ZfsCompressedArcMeter.c86
-rw-r--r--zfs/ZfsCompressedArcMeter.h22
-rw-r--r--zfs/openzfs_sysctl.c99
-rw-r--r--zfs/openzfs_sysctl.h18
8 files changed, 402 insertions, 0 deletions
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c
new file mode 100644
index 0000000..8042555
--- /dev/null
+++ b/zfs/ZfsArcMeter.c
@@ -0,0 +1,104 @@
+/*
+htop - ZfsArcMeter.c
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "ZfsArcMeter.h"
+#include "ZfsArcStats.h"
+
+#include "CRT.h"
+#include "Platform.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/param.h>
+#include <assert.h>
+
+/*{
+#include "ZfsArcStats.h"
+
+#include "Meter.h"
+}*/
+
+int ZfsArcMeter_attributes[] = {
+ ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER
+};
+
+void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+ this->total = stats->max;
+ this->values[0] = stats->MFU;
+ this->values[1] = stats->MRU;
+ this->values[2] = stats->anon;
+ this->values[3] = stats->header;
+ this->values[4] = stats->other;
+
+ // "Hide" the last value so it can
+ // only be accessed by index and is not
+ // displayed by the Bar or Graph style
+ Meter_setItems(this, 5);
+ this->values[5] = stats->size;
+}
+
+static void ZfsArcMeter_updateValues(Meter* this, char* buffer, int size) {
+ int written;
+ Platform_setZfsArcValues(this);
+
+ written = Meter_humanUnit(buffer, this->values[5], size);
+ buffer += written;
+ if ((size -= written) > 0) {
+ *buffer++ = '/';
+ size--;
+ Meter_humanUnit(buffer, this->total, size);
+ }
+}
+
+static void ZfsArcMeter_display(Object* cast, RichString* out) {
+ char buffer[50];
+ Meter* this = (Meter*)cast;
+
+ 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 = {
+ .super = {
+ .extends = Class(Meter),
+ .delete = Meter_delete,
+ .display = ZfsArcMeter_display,
+ },
+ .updateValues = ZfsArcMeter_updateValues,
+ .defaultMode = TEXT_METERMODE,
+ .maxItems = 6,
+ .total = 100.0,
+ .attributes = ZfsArcMeter_attributes,
+ .name = "ZFSARC",
+ .uiName = "ZFS ARC",
+ .caption = "ARC"
+};
diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h
new file mode 100644
index 0000000..f2e322f
--- /dev/null
+++ b/zfs/ZfsArcMeter.h
@@ -0,0 +1,22 @@
+/* Do not edit this file. It was automatically generated. */
+
+#ifndef HEADER_ZfsArcMeter
+#define HEADER_ZfsArcMeter
+/*
+htop - ZfsArcMeter.h
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "ZfsArcStats.h"
+
+#include "Meter.h"
+
+extern int ZfsArcMeter_attributes[];
+
+extern void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats);
+
+extern MeterClass ZfsArcMeter_class;
+
+#endif
diff --git a/zfs/ZfsArcStats.c b/zfs/ZfsArcStats.c
new file mode 100644
index 0000000..bfed07d
--- /dev/null
+++ b/zfs/ZfsArcStats.c
@@ -0,0 +1,24 @@
+/*
+htop - ZfsArcStats.c
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+/*{
+typedef struct ZfsArcStats_ {
+ int enabled;
+ int isCompressed;
+ unsigned long long int max;
+ unsigned long long int size;
+ unsigned long long int MFU;
+ unsigned long long int MRU;
+ unsigned long long int anon;
+ unsigned long long int header;
+ unsigned long long int other;
+ unsigned long long int compressed;
+ unsigned long long int uncompressed;
+} ZfsArcStats;
+}*/
+
+static int make_iso_compilers_happy __attribute__((unused));
diff --git a/zfs/ZfsArcStats.h b/zfs/ZfsArcStats.h
new file mode 100644
index 0000000..9368ba9
--- /dev/null
+++ b/zfs/ZfsArcStats.h
@@ -0,0 +1,27 @@
+/* Do not edit this file. It was automatically generated. */
+
+#ifndef HEADER_ZfsArcStats
+#define HEADER_ZfsArcStats
+/*
+htop - ZfsArcStats.h
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+typedef struct ZfsArcStats_ {
+ int enabled;
+ int isCompressed;
+ unsigned long long int max;
+ unsigned long long int size;
+ unsigned long long int MFU;
+ unsigned long long int MRU;
+ unsigned long long int anon;
+ unsigned long long int header;
+ unsigned long long int other;
+ unsigned long long int compressed;
+ unsigned long long int uncompressed;
+} ZfsArcStats;
+
+
+#endif
diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c
new file mode 100644
index 0000000..ac3944d
--- /dev/null
+++ b/zfs/ZfsCompressedArcMeter.c
@@ -0,0 +1,86 @@
+/*
+htop - ZfsCompressedArcMeter.c
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "ZfsCompressedArcMeter.h"
+#include "ZfsArcStats.h"
+
+#include "CRT.h"
+#include "Platform.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/param.h>
+#include <assert.h>
+
+/*{
+#include "ZfsArcStats.h"
+
+#include "Meter.h"
+}*/
+
+int ZfsCompressedArcMeter_attributes[] = {
+ ZFS_COMPRESSED
+};
+
+void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+ if ( stats->isCompressed ) {
+ this->total = stats->uncompressed;
+ this->values[0] = stats->compressed;
+ } else {
+ // For uncompressed ARC, report 1:1 ratio
+ this->total = stats->size;
+ this->values[0] = stats->size;
+ }
+}
+
+static void ZfsCompressedArcMeter_printRatioString(Meter* this, char* buffer, int size) {
+ xSnprintf(buffer, size, "%.2f:1", this->total/this->values[0]);
+}
+
+static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, int size) {
+ Platform_setZfsCompressedArcValues(this);
+
+ ZfsCompressedArcMeter_printRatioString(this, buffer, size);
+}
+
+static void ZfsCompressedArcMeter_display(Object* cast, RichString* out) {
+ char buffer[50];
+ Meter* this = (Meter*)cast;
+
+ if (this->values[0] > 0) {
+ Meter_humanUnit(buffer, this->total, 50);
+ RichString_append(out, CRT_colors[METER_VALUE], buffer);
+ RichString_append(out, CRT_colors[METER_TEXT], " Uncompressed, ");
+ Meter_humanUnit(buffer, this->values[0], 50);
+ RichString_append(out, CRT_colors[METER_VALUE], buffer);
+ RichString_append(out, CRT_colors[METER_TEXT], " Compressed, ");
+ ZfsCompressedArcMeter_printRatioString(this, buffer, 50);
+ RichString_append(out, CRT_colors[METER_VALUE], buffer);
+ RichString_append(out, CRT_colors[METER_TEXT], " Ratio");
+ } else {
+ RichString_write(out, CRT_colors[METER_TEXT], " ");
+ RichString_append(out, CRT_colors[FAILED_SEARCH], "Compression Unavailable");
+ }
+}
+
+MeterClass ZfsCompressedArcMeter_class = {
+ .super = {
+ .extends = Class(Meter),
+ .delete = Meter_delete,
+ .display = ZfsCompressedArcMeter_display,
+ },
+ .updateValues = ZfsCompressedArcMeter_updateValues,
+ .defaultMode = TEXT_METERMODE,
+ .maxItems = 1,
+ .total = 100.0,
+ .attributes = ZfsCompressedArcMeter_attributes,
+ .name = "ZFSCARC",
+ .uiName = "ZFS CARC",
+ .description = "ZFS CARC: Compressed ARC statistics",
+ .caption = "ARC: "
+};
diff --git a/zfs/ZfsCompressedArcMeter.h b/zfs/ZfsCompressedArcMeter.h
new file mode 100644
index 0000000..5afcc99
--- /dev/null
+++ b/zfs/ZfsCompressedArcMeter.h
@@ -0,0 +1,22 @@
+/* Do not edit this file. It was automatically generated. */
+
+#ifndef HEADER_ZfsCompressedArcMeter
+#define HEADER_ZfsCompressedArcMeter
+/*
+htop - ZfsCompressedArcMeter.h
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "ZfsArcStats.h"
+
+#include "Meter.h"
+
+extern int ZfsCompressedArcMeter_attributes[];
+
+void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats);
+
+extern MeterClass ZfsCompressedArcMeter_class;
+
+#endif
diff --git a/zfs/openzfs_sysctl.c b/zfs/openzfs_sysctl.c
new file mode 100644
index 0000000..c1ab223
--- /dev/null
+++ b/zfs/openzfs_sysctl.c
@@ -0,0 +1,99 @@
+/*
+htop - zfs/openzfs_sysctl.c
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "zfs/openzfs_sysctl.h"
+#include "zfs/ZfsArcStats.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+static int MIB_kstat_zfs_misc_arcstats_size[5];
+static int MIB_kstat_zfs_misc_arcstats_c_max[5];
+static int MIB_kstat_zfs_misc_arcstats_mfu_size[5];
+static int MIB_kstat_zfs_misc_arcstats_mru_size[5];
+static int MIB_kstat_zfs_misc_arcstats_anon_size[5];
+static int MIB_kstat_zfs_misc_arcstats_hdr_size[5];
+static int MIB_kstat_zfs_misc_arcstats_other_size[5];
+static int MIB_kstat_zfs_misc_arcstats_compressed_size[5];
+static int MIB_kstat_zfs_misc_arcstats_uncompressed_size[5];
+
+/*{
+#include "zfs/ZfsArcStats.h"
+}*/
+
+void openzfs_sysctl_init(ZfsArcStats *stats) {
+ size_t len;
+ unsigned long long int arcSize;
+
+ len = sizeof(arcSize);
+ if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arcSize, &len,
+ NULL, 0) == 0 && arcSize != 0) {
+ stats->enabled = 1;
+ len = 5; sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len);
+
+ sysctlnametomib("kstat.zfs.misc.arcstats.c_max", MIB_kstat_zfs_misc_arcstats_c_max, &len);
+ sysctlnametomib("kstat.zfs.misc.arcstats.mfu_size", MIB_kstat_zfs_misc_arcstats_mfu_size, &len);
+ sysctlnametomib("kstat.zfs.misc.arcstats.mru_size", MIB_kstat_zfs_misc_arcstats_mru_size, &len);
+ sysctlnametomib("kstat.zfs.misc.arcstats.anon_size", MIB_kstat_zfs_misc_arcstats_anon_size, &len);
+ sysctlnametomib("kstat.zfs.misc.arcstats.hdr_size", MIB_kstat_zfs_misc_arcstats_hdr_size, &len);
+ sysctlnametomib("kstat.zfs.misc.arcstats.other_size", MIB_kstat_zfs_misc_arcstats_other_size, &len);
+ if (sysctlnametomib("kstat.zfs.misc.arcstats.compressed_size", MIB_kstat_zfs_misc_arcstats_compressed_size, &len) == 0) {
+ stats->isCompressed = 1;
+ sysctlnametomib("kstat.zfs.misc.arcstats.uncompressed_size", MIB_kstat_zfs_misc_arcstats_uncompressed_size, &len);
+ } else {
+ stats->isCompressed = 0;
+ }
+ } else {
+ stats->enabled = 0;
+ }
+}
+
+void openzfs_sysctl_updateArcStats(ZfsArcStats *stats) {
+ size_t len;
+
+ if (stats->enabled) {
+ len = sizeof(stats->size);
+ sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(stats->size), &len , NULL, 0);
+ stats->size /= 1024;
+
+ len = sizeof(stats->max);
+ sysctl(MIB_kstat_zfs_misc_arcstats_c_max, 5, &(stats->max), &len , NULL, 0);
+ stats->max /= 1024;
+
+ len = sizeof(stats->MFU);
+ sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(stats->MFU), &len , NULL, 0);
+ stats->MFU /= 1024;
+
+ len = sizeof(stats->MRU);
+ sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(stats->MRU), &len , NULL, 0);
+ stats->MRU /= 1024;
+
+ len = sizeof(stats->anon);
+ sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(stats->anon), &len , NULL, 0);
+ stats->anon /= 1024;
+
+ len = sizeof(stats->header);
+ sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(stats->header), &len , NULL, 0);
+ stats->header /= 1024;
+
+ len = sizeof(stats->other);
+ sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(stats->other), &len , NULL, 0);
+ stats->other /= 1024;
+
+ if (stats->isCompressed) {
+ len = sizeof(stats->compressed);
+ sysctl(MIB_kstat_zfs_misc_arcstats_compressed_size, 5, &(stats->compressed), &len , NULL, 0);
+ stats->compressed /= 1024;
+
+ len = sizeof(stats->uncompressed);
+ sysctl(MIB_kstat_zfs_misc_arcstats_uncompressed_size, 5, &(stats->uncompressed), &len , NULL, 0);
+ stats->uncompressed /= 1024;
+ }
+ }
+}
diff --git a/zfs/openzfs_sysctl.h b/zfs/openzfs_sysctl.h
new file mode 100644
index 0000000..6e44ac3
--- /dev/null
+++ b/zfs/openzfs_sysctl.h
@@ -0,0 +1,18 @@
+/* Do not edit this file. It was automatically generated. */
+
+#ifndef HEADER_openzfs_sysctl
+#define HEADER_openzfs_sysctl
+/*
+htop - zfs/openzfs_sysctl.h
+(C) 2014 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "zfs/ZfsArcStats.h"
+
+void openzfs_sysctl_init(ZfsArcStats *stats);
+
+void openzfs_sysctl_updateArcStats(ZfsArcStats *stats);
+
+#endif

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