aboutsummaryrefslogtreecommitdiffstats
path: root/solaris
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 /solaris
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 'solaris')
-rw-r--r--solaris/Battery.c1
-rw-r--r--solaris/Platform.c33
-rw-r--r--solaris/Platform.h6
-rw-r--r--solaris/SolarisCRT.c2
-rw-r--r--solaris/SolarisProcess.c2
-rw-r--r--solaris/SolarisProcessList.c78
-rw-r--r--solaris/SolarisProcessList.h7
7 files changed, 102 insertions, 27 deletions
diff --git a/solaris/Battery.c b/solaris/Battery.c
index 6d6e94b..080cf54 100644
--- a/solaris/Battery.c
+++ b/solaris/Battery.c
@@ -5,4 +5,3 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
*level = -1;
*isOnAC = AC_ERROR;
}
-
diff --git a/solaris/Platform.c b/solaris/Platform.c
index a29fcb4..092f450 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -17,6 +17,8 @@ in the source distribution for its full text.
#include "ClockMeter.h"
#include "HostnameMeter.h"
#include "UptimeMeter.h"
+#include "zfs/ZfsArcMeter.h"
+#include "zfs/ZfsCompressedArcMeter.h"
#include "SolarisProcess.h"
#include "SolarisProcessList.h"
@@ -48,7 +50,7 @@ typedef struct var kvar_t;
typedef struct envAccum_ {
size_t capacity;
size_t size;
- size_t bytes;
+ size_t bytes;
char *env;
} envAccum;
@@ -122,6 +124,8 @@ MeterClass* Platform_meterTypes[] = {
&RightCPUsMeter_class,
&LeftCPUs2Meter_class,
&RightCPUs2Meter_class,
+ &ZfsArcMeter_class,
+ &ZfsCompressedArcMeter_class,
&BlankMeter_class,
NULL
};
@@ -136,7 +140,7 @@ extern char Process_pidFormat[20];
int Platform_getUptime() {
int boot_time = 0;
- int curr_time = time(NULL);
+ int curr_time = time(NULL);
struct utmpx * ent;
while (( ent = getutxent() )) {
@@ -170,7 +174,7 @@ int Platform_getMaxPid() {
vproc = ksvar->v_proc;
}
if (kc != NULL) { kstat_close(kc); }
- return vproc;
+ return vproc;
}
double Platform_setCPUValues(Meter* this, int cpu) {
@@ -203,6 +207,9 @@ double Platform_setCPUValues(Meter* this, int cpu) {
percent = CLAMP(percent, 0.0, 100.0);
if (isnan(percent)) percent = 0.0;
+
+ v[CPU_METER_FREQUENCY] = -1;
+
return percent;
}
@@ -220,10 +227,22 @@ void Platform_setSwapValues(Meter* this) {
this->values[0] = pl->usedSwap;
}
+void Platform_setZfsArcValues(Meter* this) {
+ SolarisProcessList* spl = (SolarisProcessList*) this->pl;
+
+ ZfsArcMeter_readStats(this, &(spl->zfs));
+}
+
+void Platform_setZfsCompressedArcValues(Meter* this) {
+ SolarisProcessList* spl = (SolarisProcessList*) this->pl;
+
+ ZfsCompressedArcMeter_readStats(this, &(spl->zfs));
+}
+
static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr_t addr, const char *str) {
envAccum *accump = accum;
(void) Phandle;
- (void) addr;
+ (void) addr;
size_t thissz = strlen(str);
if ((thissz + 2) > (accump->capacity - accump->size))
accump->env = xRealloc(accump->env, accump->capacity *= 2);
@@ -232,7 +251,7 @@ static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr
strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size));
strncpy( accump->env + accump->size + thissz + 1, "\n", 1);
accump->size = accump->size + thissz + 1;
- return 0;
+ return 0;
}
char* Platform_getProcessEnv(pid_t pid) {
@@ -240,7 +259,7 @@ char* Platform_getProcessEnv(pid_t pid) {
pid_t realpid = pid / 1024;
int graberr;
struct ps_prochandle *Phandle;
-
+
if ((Phandle = Pgrab(realpid,PGRAB_RDONLY,&graberr)) == NULL)
return "Unable to read process environment.";
@@ -248,7 +267,7 @@ char* Platform_getProcessEnv(pid_t pid) {
envBuilder.size = 0;
envBuilder.env = xMalloc(envBuilder.capacity);
- (void) Penv_iter(Phandle,Platform_buildenv,&envBuilder);
+ (void) Penv_iter(Phandle,Platform_buildenv,&envBuilder);
Prelease(Phandle, 0);
diff --git a/solaris/Platform.h b/solaris/Platform.h
index f961b91..dd1962d 100644
--- a/solaris/Platform.h
+++ b/solaris/Platform.h
@@ -27,7 +27,7 @@ typedef struct var kvar_t;
typedef struct envAccum_ {
size_t capacity;
size_t size;
- size_t bytes;
+ size_t bytes;
char *env;
} envAccum;
@@ -60,6 +60,10 @@ void Platform_setMemoryValues(Meter* this);
void Platform_setSwapValues(Meter* this);
+void Platform_setZfsArcValues(Meter* this);
+
+void Platform_setZfsCompressedArcValues(Meter* this);
+
char* Platform_getProcessEnv(pid_t pid);
#endif
diff --git a/solaris/SolarisCRT.c b/solaris/SolarisCRT.c
index d7f8f52..13e82d7 100644
--- a/solaris/SolarisCRT.c
+++ b/solaris/SolarisCRT.c
@@ -17,7 +17,7 @@ in the source distribution for its full text.
void CRT_handleSIGSEGV(int sgn) {
(void) sgn;
CRT_done();
- fprintf(stderr, "\n\nhtop " VERSION " aborting. Please report bug at http://hisham.hm/htop\n");
+ fprintf(stderr, "\n\nhtop " VERSION " aborting. Please report bug at https://htop.dev\n");
#ifdef HAVE_EXECINFO_H
size_t size = backtrace(backtraceArray, sizeof(backtraceArray) / sizeof(void *));
fprintf(stderr, "\n Please include in your report the following backtrace: \n");
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c
index 31f488e..514453f 100644
--- a/solaris/SolarisProcess.c
+++ b/solaris/SolarisProcess.c
@@ -90,7 +90,7 @@ ProcessFieldData Process_fields[] = {
[PROCESSOR] = { .name = "PROCESSOR", .title = "CPU ", .description = "Id of the CPU the process last executed on", .flags = 0, },
[M_SIZE] = { .name = "M_SIZE", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, },
- [ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, },
+ [ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, },
[PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, },
[PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, },
[USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c
index 2c68185..ab2cf68 100644
--- a/solaris/SolarisProcessList.c
+++ b/solaris/SolarisProcessList.c
@@ -25,8 +25,12 @@ in the source distribution for its full text.
#define MAXCMDLINE 255
+#define GZONE "global "
+#define UZONE "unknown "
/*{
+#include "zfs/ZfsArcStats.h"
+
#include <kstat.h>
#include <sys/param.h>
#include <sys/uio.h>
@@ -55,6 +59,7 @@ typedef struct SolarisProcessList_ {
ProcessList super;
kstat_ctl_t* kd;
CPUData* cpus;
+ ZfsArcStats zfs;
} SolarisProcessList;
}*/
@@ -62,12 +67,12 @@ typedef struct SolarisProcessList_ {
char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) {
char* zname;
if ( sproc->zoneid == 0 ) {
- zname = xStrdup("global ");
+ zname = xStrdup(GZONE);
} else if ( kd == NULL ) {
- zname = xStrdup("unknown ");
+ zname = xStrdup(UZONE);
} else {
kstat_t* ks = kstat_lookup( kd, "zones", sproc->zoneid, NULL );
- zname = xStrdup(ks->ks_name);
+ zname = xStrdup(ks == NULL ? UZONE : ks->ks_name);
}
return zname;
}
@@ -153,7 +158,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
idlebuf += cpuData->idlePercent;
}
}
-
+
if (cpus > 1) {
CPUData* cpuData = &(spl->cpus[0]);
cpuData->userPercent = userbuf / cpus;
@@ -177,7 +182,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
uint64_t totalswap = 0;
uint64_t totalfree = 0;
int nswap = 0;
- char *spath = NULL;
+ char *spath = NULL;
char *spathbase = NULL;
// Part 1 - physical memory
@@ -191,7 +196,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
pl->totalMem = totalmem_pgs->value.ui64 * PAGE_SIZE_KB;
pl->usedMem = lockedmem_pgs->value.ui64 * PAGE_SIZE_KB;
// Not sure how to implement this on Solaris - suggestions welcome!
- pl->cachedMem = 0;
+ pl->cachedMem = 0;
// Not really "buffers" but the best Solaris analogue that I can find to
// "memory in use but not by programs or the kernel itself"
pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * PAGE_SIZE_KB;
@@ -202,12 +207,12 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
pl->cachedMem = 0;
pl->usedMem = pl->totalMem - (sysconf(_SC_AVPHYS_PAGES) * PAGE_SIZE);
}
-
+
// Part 2 - swap
nswap = swapctl(SC_GETNSWP, NULL);
if (nswap > 0) { sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int)); }
if (sl != NULL) { spathbase = xMalloc( nswap * MAXPATHLEN ); }
- if (spathbase != NULL) {
+ if (spathbase != NULL) {
spath = spathbase;
swapdev = sl->swt_ent;
for (int i = 0; i < nswap; i++, swapdev++) {
@@ -217,7 +222,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
sl->swt_n = nswap;
}
nswap = swapctl(SC_LIST, sl);
- if (nswap > 0) {
+ if (nswap > 0) {
swapdev = sl->swt_ent;
for (int i = 0; i < nswap; i++, swapdev++) {
totalswap += swapdev->ste_pages;
@@ -227,7 +232,50 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
free(spathbase);
free(sl);
pl->totalSwap = totalswap * PAGE_SIZE_KB;
- pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB);
+ pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB);
+}
+
+static inline void SolarisProcessList_scanZfsArcstats(ProcessList* pl) {
+ SolarisProcessList* spl = (SolarisProcessList*) pl;
+ kstat_t *arcstats = NULL;
+ int ksrphyserr = -1;
+ kstat_named_t *cur_kstat = NULL;
+
+ if (spl->kd != NULL) { arcstats = kstat_lookup(spl->kd,"zfs",0,"arcstats"); }
+ if (arcstats != NULL) { ksrphyserr = kstat_read(spl->kd,arcstats,NULL); }
+ if (ksrphyserr != -1) {
+ cur_kstat = kstat_data_lookup( arcstats, "size" );
+ spl->zfs.size = cur_kstat->value.ui64 / 1024;
+ spl->zfs.enabled = spl->zfs.size > 0 ? 1 : 0;
+
+ cur_kstat = kstat_data_lookup( arcstats, "c_max" );
+ spl->zfs.max = cur_kstat->value.ui64 / 1024;
+
+ cur_kstat = kstat_data_lookup( arcstats, "mfu_size" );
+ spl->zfs.MFU = cur_kstat->value.ui64 / 1024;
+
+ cur_kstat = kstat_data_lookup( arcstats, "mru_size" );
+ spl->zfs.MRU = cur_kstat->value.ui64 / 1024;
+
+ cur_kstat = kstat_data_lookup( arcstats, "anon_size" );
+ spl->zfs.anon = cur_kstat->value.ui64 / 1024;
+
+ cur_kstat = kstat_data_lookup( arcstats, "hdr_size" );
+ spl->zfs.header = cur_kstat->value.ui64 / 1024;
+
+ cur_kstat = kstat_data_lookup( arcstats, "other_size" );
+ spl->zfs.other = cur_kstat->value.ui64 / 1024;
+
+ if ((cur_kstat = kstat_data_lookup( arcstats, "compressed_size" )) != NULL) {
+ spl->zfs.compressed = cur_kstat->value.ui64 / 1024;
+ spl->zfs.isCompressed = 1;
+
+ cur_kstat = kstat_data_lookup( arcstats, "uncompressed_size" );
+ spl->zfs.uncompressed = cur_kstat->value.ui64 / 1024;
+ } else {
+ spl->zfs.isCompressed = 0;
+ }
+ }
}
void ProcessList_delete(ProcessList* pl) {
@@ -242,7 +290,7 @@ void ProcessList_delete(ProcessList* pl) {
* and MUST conform to the appropriate definition in order
* to work. See libproc(3LIB) on a Solaris or Illumos
* system for more info.
- */
+ */
int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr) {
struct timeval tv;
@@ -262,7 +310,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
getpid = _psinfo->pr_pid * 1024;
} else {
getpid = lwpid;
- }
+ }
Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, (Process_New) SolarisProcess_new);
SolarisProcess *sproc = (SolarisProcess*) proc;
@@ -293,7 +341,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
sproc->realpid = _psinfo->pr_pid;
sproc->lwpid = lwpid_real;
sproc->zoneid = _psinfo->pr_zoneid;
- sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc);
+ sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc);
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
proc->comm = xStrdup(_psinfo->pr_fname);
proc->commLen = strnlen(_psinfo->pr_fname,PRFNSZ);
@@ -332,7 +380,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu/(double)32768)*(double)100.0;
proc->time = _lwpsinfo->pr_time.tv_sec;
if (!preExisting) { // Tasks done only for NEW LWPs
- sproc->is_lwp = true;
+ sproc->is_lwp = true;
proc->basenameOffset = -1;
proc->ppid = _psinfo->pr_pid * 1024;
proc->tgid = _psinfo->pr_pid * 1024;
@@ -367,7 +415,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
void ProcessList_goThroughEntries(ProcessList* this) {
SolarisProcessList_scanCPUTime(this);
SolarisProcessList_scanMemoryInfo(this);
+ SolarisProcessList_scanZfsArcstats(this);
this->kernelThreads = 1;
proc_walk(&SolarisProcessList_walkproc, this, PR_WALK_LWP);
}
-
diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h
index a5f2fbc..06c1330 100644
--- a/solaris/SolarisProcessList.h
+++ b/solaris/SolarisProcessList.h
@@ -12,6 +12,10 @@ in the source distribution for its full text.
#define MAXCMDLINE 255
+#define GZONE "global "
+#define UZONE "unknown "
+
+#include "zfs/ZfsArcStats.h"
#include <kstat.h>
#include <sys/param.h>
@@ -41,6 +45,7 @@ typedef struct SolarisProcessList_ {
ProcessList super;
kstat_ctl_t* kd;
CPUData* cpus;
+ ZfsArcStats zfs;
} SolarisProcessList;
@@ -54,7 +59,7 @@ void ProcessList_delete(ProcessList* pl);
* and MUST conform to the appropriate definition in order
* to work. See libproc(3LIB) on a Solaris or Illumos
* system for more info.
- */
+ */
int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr);

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