aboutsummaryrefslogtreecommitdiffstats
path: root/solaris/Platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'solaris/Platform.c')
-rw-r--r--solaris/Platform.c81
1 files changed, 46 insertions, 35 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 968e013..7439195 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -7,11 +7,24 @@ Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-#include "Platform.h"
+#include "solaris/Platform.h"
+
+#include <kstat.h>
+#include <math.h>
+#include <string.h>
+#include <time.h>
+#include <utmpx.h>
+#include <sys/loadavg.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/var.h>
+
#include "Macros.h"
#include "Meter.h"
#include "CPUMeter.h"
#include "MemoryMeter.h"
+#include "MemorySwapMeter.h"
#include "SwapMeter.h"
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
@@ -19,25 +32,13 @@ in the source distribution for its full text.
#include "DateMeter.h"
#include "DateTimeMeter.h"
#include "HostnameMeter.h"
+#include "SysArchMeter.h"
#include "UptimeMeter.h"
#include "zfs/ZfsArcMeter.h"
#include "zfs/ZfsCompressedArcMeter.h"
#include "SolarisProcess.h"
#include "SolarisProcessList.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <utmpx.h>
-#include <sys/loadavg.h>
-#include <string.h>
-#include <kstat.h>
-#include <time.h>
-#include <math.h>
-#include <sys/var.h>
-
-
-double plat_loadavg[3] = {0};
const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 },
@@ -97,9 +98,11 @@ const MeterClass* const Platform_meterTypes[] = {
&LoadMeter_class,
&MemoryMeter_class,
&SwapMeter_class,
+ &MemorySwapMeter_class,
&TasksMeter_class,
&BatteryMeter_class,
&HostnameMeter_class,
+ &SysArchMeter_class,
&UptimeMeter_class,
&AllCPUsMeter_class,
&AllCPUs2Meter_class,
@@ -138,7 +141,7 @@ int Platform_getUptime() {
struct utmpx* ent;
while (( ent = getutxent() )) {
- if ( !strcmp("system boot", ent->ut_line )) {
+ if ( String_eq("system boot", ent->ut_line )) {
boot_time = ent->ut_tv.tv_sec;
}
}
@@ -149,7 +152,13 @@ int Platform_getUptime() {
}
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
- getloadavg( plat_loadavg, 3 );
+ double plat_loadavg[3];
+ if (getloadavg( plat_loadavg, 3 ) < 0) {
+ *one = NAN;
+ *five = NAN;
+ *fifteen = NAN;
+ return;
+ }
*one = plat_loadavg[LOADAVG_1MIN];
*five = plat_loadavg[LOADAVG_5MIN];
*fifteen = plat_loadavg[LOADAVG_15MIN];
@@ -160,7 +169,7 @@ int Platform_getMaxPid() {
kstat_ctl_t* kc = kstat_open();
if (kc != NULL) {
- kstat_t* kshandle = kstat_lookup(kc, "unix", 0, "var");
+ kstat_t* kshandle = kstat_lookup_wrapper(kc, "unix", 0, "var");
if (kshandle != NULL) {
kstat_read(kc, kshandle, NULL);
@@ -175,9 +184,9 @@ int Platform_getMaxPid() {
return vproc;
}
-double Platform_setCPUValues(Meter* this, int cpu) {
+double Platform_setCPUValues(Meter* this, unsigned int cpu) {
const SolarisProcessList* spl = (const SolarisProcessList*) this->pl;
- int cpus = this->pl->cpuCount;
+ unsigned int cpus = this->pl->existingCPUs;
const CPUData* cpuData = NULL;
if (cpus == 1) {
@@ -187,6 +196,11 @@ double Platform_setCPUValues(Meter* this, int cpu) {
cpuData = &(spl->cpus[cpu]);
}
+ if (!cpuData->online) {
+ this->curItems = 0;
+ return NAN;
+ }
+
double percent;
double* v = this->values;
@@ -216,13 +230,16 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
this->values[1] = pl->buffersMem;
- this->values[2] = pl->cachedMem;
+ // this->values[2] = "shared memory, like tmpfs and shm"
+ this->values[3] = pl->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;
}
void Platform_setZfsArcValues(Meter* this) {
@@ -249,7 +266,7 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr
return 1;
}
strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size));
- strncpy( accump->env + accump->size + thissz + 1, "\n", 1);
+ strncpy( accump->env + accump->size + thissz + 1, "\n", 2);
accump->size = accump->size + thissz + 1;
return 0;
}
@@ -261,7 +278,7 @@ char* Platform_getProcessEnv(pid_t pid) {
struct ps_prochandle* Phandle;
if ((Phandle = Pgrab(realpid, PGRAB_RDONLY, &graberr)) == NULL) {
- return "Unable to read process environment.";
+ return NULL;
}
envBuilder.capacity = 4096;
@@ -277,14 +294,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) {
@@ -293,15 +310,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;
}

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