mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Support ZFS ARC stats on FreeBSD
New meter displays same ARC stats as FreeBSD top(1). Can be extended to other platforms that support ZFS. Pulling kstat.zfs.misc.arcstats.c_max as the meter total, so the meter has a meaningful value to work up to. The Text meter displays, first, the maximum ARC size (Meter.total), then second, the total ARC used, using the difference between Meter.maxItems and Meter.curItems to "hide" the used value from the Bar and Graph drawing functions by using an index in Meter.values[] that is beyond curItems - 1, but less than maxItems - 1.
This commit is contained in:
@ -53,6 +53,12 @@ typedef struct FreeBSDProcessList_ {
|
||||
unsigned long long int memFree;
|
||||
unsigned long long int memZfsArc;
|
||||
|
||||
unsigned long long int zfsArcMax;
|
||||
unsigned long long int zfsArcMFU;
|
||||
unsigned long long int zfsArcMRU;
|
||||
unsigned long long int zFsArcAnon;
|
||||
unsigned long long int zFsArcHeader;
|
||||
unsigned long long int zFsArcOther;
|
||||
|
||||
CPUData* cpus;
|
||||
|
||||
@ -81,6 +87,12 @@ static int MIB_vm_stats_vm_v_free_count[4];
|
||||
static int MIB_vfs_bufspace[2];
|
||||
|
||||
static int MIB_kstat_zfs_misc_arcstats_size[5];
|
||||
static int MIB_vfs_zfs_arc_max[3];
|
||||
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_kern_cp_time[2];
|
||||
static int MIB_kern_cp_times[2];
|
||||
@ -123,6 +135,16 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
||||
NULL, 0) == 0 && fpl->memZfsArc != 0) {
|
||||
len = 5; sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len);
|
||||
fpl->zfsArcEnabled = 1;
|
||||
|
||||
len = 3;
|
||||
sysctlnametomib("vfs.zfs.arc_max", MIB_vfs_zfs_arc_max, &len);
|
||||
|
||||
len = 5;
|
||||
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);
|
||||
} else {
|
||||
fpl->zfsArcEnabled = 0;
|
||||
}
|
||||
@ -323,8 +345,30 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
||||
fpl->memZfsArc /= 1024;
|
||||
fpl->memWire -= fpl->memZfsArc;
|
||||
pl->cachedMem += fpl->memZfsArc;
|
||||
// maybe when we learn how to make custom memory meter
|
||||
// we could do custom arc breakdown?
|
||||
|
||||
len = sizeof(fpl->zfsArcMax);
|
||||
sysctl(MIB_vfs_zfs_arc_max, 3, &(fpl->zfsArcMax), &len , NULL, 0);
|
||||
fpl->zfsArcMax /= 1024;
|
||||
|
||||
len = sizeof(fpl->zfsArcMFU);
|
||||
sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(fpl->zfsArcMFU), &len , NULL, 0);
|
||||
fpl->zfsArcMFU /= 1024;
|
||||
|
||||
len = sizeof(fpl->zfsArcMRU);
|
||||
sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(fpl->zfsArcMRU), &len , NULL, 0);
|
||||
fpl->zfsArcMRU /= 1024;
|
||||
|
||||
len = sizeof(fpl->zfsArcAnon);
|
||||
sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(fpl->zfsArcAnon), &len , NULL, 0);
|
||||
fpl->zfsArcAnon /= 1024;
|
||||
|
||||
len = sizeof(fpl->zfsArcHeader);
|
||||
sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(fpl->zfsArcHeader), &len , NULL, 0);
|
||||
fpl->zfsArcHeader /= 1024;
|
||||
|
||||
len = sizeof(fpl->zfsArcOther);
|
||||
sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(fpl->zfsArcOther), &len , NULL, 0);
|
||||
fpl->zfsArcOther /= 1024;
|
||||
}
|
||||
|
||||
pl->usedMem = fpl->memActive + fpl->memWire;
|
||||
|
@ -42,6 +42,12 @@ typedef struct FreeBSDProcessList_ {
|
||||
unsigned long long int memFree;
|
||||
unsigned long long int memZfsArc;
|
||||
|
||||
unsigned long long int zfsArcMax;
|
||||
unsigned long long int zfsArcMFU;
|
||||
unsigned long long int zfsArcMRU;
|
||||
unsigned long long int zfsArcAnon;
|
||||
unsigned long long int zfsArcHeader;
|
||||
unsigned long long int zfsArcOther;
|
||||
|
||||
CPUData* cpus;
|
||||
|
||||
|
@ -15,6 +15,7 @@ in the source distribution for its full text.
|
||||
#include "UptimeMeter.h"
|
||||
#include "ClockMeter.h"
|
||||
#include "HostnameMeter.h"
|
||||
#include "zfs/ZfsArcMeter.h"
|
||||
#include "FreeBSDProcess.h"
|
||||
#include "FreeBSDProcessList.h"
|
||||
|
||||
@ -104,6 +105,7 @@ MeterClass* Platform_meterTypes[] = {
|
||||
&LeftCPUs2Meter_class,
|
||||
&RightCPUs2Meter_class,
|
||||
&BlankMeter_class,
|
||||
&ZfsArcMeter_class,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -197,6 +199,23 @@ void Platform_setSwapValues(Meter* this) {
|
||||
this->values[0] = pl->usedSwap;
|
||||
}
|
||||
|
||||
void Platform_setZfsArcValues(Meter* this) {
|
||||
FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
|
||||
|
||||
this->total = fpl->zfsArcMax;
|
||||
this->values[0] = fpl->zfsArcMFU;
|
||||
this->values[1] = fpl->zfsArcMRU;
|
||||
this->values[2] = fpl->zfsArcAnon;
|
||||
this->values[3] = fpl->zfsArcHeader;
|
||||
this->values[4] = fpl->zfsArcOther;
|
||||
|
||||
// "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] = fpl->memZfsArc;
|
||||
}
|
||||
|
||||
void Platform_setTasksValues(Meter* this) {
|
||||
// TODO
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ void Platform_setMemoryValues(Meter* this);
|
||||
|
||||
void Platform_setSwapValues(Meter* this);
|
||||
|
||||
void Platform_setZfsArcValues(Meter* this);
|
||||
|
||||
void Platform_setTasksValues(Meter* this);
|
||||
|
||||
char* Platform_getProcessEnv(pid_t pid);
|
||||
|
Reference in New Issue
Block a user