From 69f439eff387a6ecb52734e400b297a3c85f2285 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Tue, 21 Sep 2021 08:35:19 +0200 Subject: New upstream version 3.1.0 --- openbsd/Platform.c | 57 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'openbsd/Platform.c') diff --git a/openbsd/Platform.c b/openbsd/Platform.c index 8ee8141..a62381f 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -6,7 +6,7 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "Platform.h" +#include "openbsd/Platform.h" #include #include @@ -15,6 +15,8 @@ in the source distribution for its full text. #include #include #include +#include // needs to be included before for 'struct sigaltstack' +#include #include #include #include @@ -30,16 +32,18 @@ in the source distribution for its full text. #include "LoadAverageMeter.h" #include "Macros.h" #include "MemoryMeter.h" +#include "MemorySwapMeter.h" #include "Meter.h" -#include "OpenBSDProcess.h" -#include "OpenBSDProcessList.h" #include "ProcessList.h" #include "Settings.h" #include "SignalsPanel.h" #include "SwapMeter.h" +#include "SysArchMeter.h" #include "TasksMeter.h" #include "UptimeMeter.h" #include "XUtils.h" +#include "openbsd/OpenBSDProcess.h" +#include "openbsd/OpenBSDProcessList.h" const ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_VIRT, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; @@ -95,10 +99,12 @@ const MeterClass* const Platform_meterTypes[] = { &LoadMeter_class, &MemoryMeter_class, &SwapMeter_class, + &MemorySwapMeter_class, &TasksMeter_class, &UptimeMeter_class, &BatteryMeter_class, &HostnameMeter_class, + &SysArchMeter_class, &AllCPUsMeter_class, &AllCPUs2Meter_class, &AllCPUs4Meter_class, @@ -160,17 +166,23 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) { } int Platform_getMaxPid() { - // this is hard-coded in sys/proc.h - no sysctl exists - return 99999; + return 2 * THREAD_PID_OFFSET; } -double Platform_setCPUValues(Meter* this, int cpu) { +double Platform_setCPUValues(Meter* this, unsigned int cpu) { const OpenBSDProcessList* pl = (const OpenBSDProcessList*) this->pl; - const CPUData* cpuData = &(pl->cpus[cpu]); - double total = cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod; + const CPUData* cpuData = &(pl->cpuData[cpu]); + double total; double totalPercent; double* v = this->values; + if (!cpuData->online) { + this->curItems = 0; + return NAN; + } + + total = cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod; + v[CPU_METER_NICE] = cpuData->nicePeriod / total * 100.0; v[CPU_METER_NORMAL] = cpuData->userPeriod / total * 100.0; if (this->pl->settings->detailedCPUTime) { @@ -194,6 +206,8 @@ double Platform_setCPUValues(Meter* this, int cpu) { v[CPU_METER_TEMPERATURE] = NAN; + v[CPU_METER_FREQUENCY] = (pl->cpuSpeed != -1) ? pl->cpuSpeed : NAN; + return totalPercent; } @@ -206,13 +220,16 @@ void Platform_setMemoryValues(Meter* this) { this->total = pl->totalMem; this->values[0] = usedMem; this->values[1] = buffersMem; - this->values[2] = cachedMem; + // this->values[2] = "shared memory, like tmpfs and shm" + this->values[3] = cachedMem; + // this->values[4] = "available memory" } void Platform_setSwapValues(Meter* this) { const ProcessList* pl = this->pl; this->total = pl->totalSwap; this->values[0] = pl->usedSwap; + this->values[1] = NAN; } char* Platform_getProcessEnv(pid_t pid) { @@ -264,14 +281,14 @@ char* Platform_getProcessEnv(pid_t pid) { } char* Platform_getInodeFilename(pid_t pid, ino_t inode) { - (void)pid; - (void)inode; - return NULL; + (void)pid; + (void)inode; + return NULL; } FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid) { - (void)pid; - return NULL; + (void)pid; + return NULL; } bool Platform_getDiskIO(DiskIOData* data) { @@ -280,15 +297,9 @@ bool Platform_getDiskIO(DiskIOData* data) { return false; } -bool Platform_getNetworkIO(unsigned long int* bytesReceived, - unsigned long int* packetsReceived, - unsigned long int* bytesTransmitted, - unsigned long int* packetsTransmitted) { +bool Platform_getNetworkIO(NetworkIOData* data) { // TODO - *bytesReceived = 0; - *packetsReceived = 0; - *bytesTransmitted = 0; - *packetsTransmitted = 0; + (void)data; return false; } @@ -301,7 +312,7 @@ static bool findDevice(const char* name, int* mib, struct sensordev* snsrdev, si if (errno == ENOENT) return false; } - if (strcmp(name, snsrdev->xname) == 0) { + if (String_eq(name, snsrdev->xname)) { return true; } } -- cgit v1.2.3