mirror of https://github.com/xzeldon/htop.git
Whitespace and indentation issues
This commit is contained in:
parent
9a16b1079e
commit
b23f8235e2
|
@ -65,7 +65,7 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
|||
} else {
|
||||
unsigned int id;
|
||||
hwloc_bitmap_foreach_begin(id, cpuset);
|
||||
Affinity_add(affinity, id);
|
||||
Affinity_add(affinity, id);
|
||||
hwloc_bitmap_foreach_end();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, u
|
|||
left -= len;
|
||||
}
|
||||
xSnprintf(&indent_buf[off], left, "%s",
|
||||
obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
|
||||
obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
|
||||
// Uncomment when further appending to indent_buf
|
||||
//size_t len = strlen(&indent_buf[off]);
|
||||
//off += len;
|
||||
|
@ -417,7 +417,7 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
|
|||
#ifdef HAVE_LIBHWLOC
|
||||
int i;
|
||||
hwloc_bitmap_foreach_begin(i, this->workCpuset)
|
||||
Affinity_add(affinity, i);
|
||||
Affinity_add(affinity, i);
|
||||
hwloc_bitmap_foreach_end();
|
||||
#else
|
||||
for (int i = 0; i < this->pl->cpuCount; i++) {
|
||||
|
|
2
IncSet.c
2
IncSet.c
|
@ -170,7 +170,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||
doSearch = false;
|
||||
}
|
||||
} else if (ch == KEY_RESIZE) {
|
||||
Panel_resize(panel, COLS, LINES-panel->y-1);
|
||||
Panel_resize(panel, COLS, LINES - panel->y - 1);
|
||||
} else {
|
||||
if (mode->isFilter) {
|
||||
filterChanged = true;
|
||||
|
|
|
@ -31,9 +31,9 @@ static void ListItem_display(const Object* cast, RichString* out) {
|
|||
if (this->moving) {
|
||||
RichString_write(out, CRT_colors[DEFAULT_COLOR],
|
||||
#ifdef HAVE_LIBNCURSESW
|
||||
CRT_utf8 ? "↕ " :
|
||||
CRT_utf8 ? "↕ " :
|
||||
#endif
|
||||
"+ ");
|
||||
"+ ");
|
||||
} else {
|
||||
RichString_prune(out);
|
||||
}
|
||||
|
|
4
Panel.c
4
Panel.c
|
@ -254,8 +254,8 @@ void Panel_draw(Panel* this, bool focus) {
|
|||
int upTo = MINIMUM(first + h, size);
|
||||
|
||||
int selectionColor = focus
|
||||
? this->selectionColor
|
||||
: CRT_colors[PANEL_SELECTION_UNFOCUS];
|
||||
? this->selectionColor
|
||||
: CRT_colors[PANEL_SELECTION_UNFOCUS];
|
||||
|
||||
if (this->needsRedraw) {
|
||||
int line = 0;
|
||||
|
|
|
@ -287,8 +287,8 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||
|
||||
for (int i = 0; i < 32; i++)
|
||||
if (indent & (1U << i))
|
||||
maxIndent = i+1;
|
||||
for (int i = 0; i < maxIndent - 1; i++) {
|
||||
maxIndent = i + 1;
|
||||
for (int i = 0; i < maxIndent - 1; i++) {
|
||||
int written, ret;
|
||||
if (indent & (1 << i))
|
||||
ret = snprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]);
|
||||
|
|
|
@ -182,8 +182,9 @@ static bool Settings_read(Settings* this, const char* fileName, int initialCpuCo
|
|||
this->delay = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "color_scheme")) {
|
||||
this->colorScheme = atoi(option[1]);
|
||||
if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME) this->colorScheme = 0;
|
||||
} else if (String_eq(option[0], "enable_mouse")) {
|
||||
if (this->colorScheme < 0 || this->colorScheme >= LAST_COLORSCHEME)
|
||||
this->colorScheme = 0;
|
||||
} else if (String_eq(option[0], "enable_mouse")) {
|
||||
this->enableMouse = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "left_meters")) {
|
||||
Settings_readMeters(this, option[1], 0);
|
||||
|
|
|
@ -32,12 +32,12 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
|||
/* Get the battery */
|
||||
for (int i = 0; i < len && battery == NULL; ++i) {
|
||||
CFDictionaryRef candidate = IOPSGetPowerSourceDescription(power_sources,
|
||||
CFArrayGetValueAtIndex(list, i)); /* GET rule */
|
||||
CFArrayGetValueAtIndex(list, i)); /* GET rule */
|
||||
CFStringRef type;
|
||||
|
||||
if (NULL != candidate) {
|
||||
type = (CFStringRef) CFDictionaryGetValue(candidate,
|
||||
CFSTR(kIOPSTransportTypeKey)); /* GET rule */
|
||||
CFSTR(kIOPSTransportTypeKey)); /* GET rule */
|
||||
|
||||
if (kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) {
|
||||
CFRetain(candidate);
|
||||
|
@ -51,17 +51,17 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
|
|||
CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey));
|
||||
|
||||
*isOnAC = (kCFCompareEqualTo == CFStringCompare(power_state, CFSTR(kIOPSACPowerValue), 0))
|
||||
? AC_PRESENT
|
||||
: AC_ABSENT;
|
||||
? AC_PRESENT
|
||||
: AC_ABSENT;
|
||||
|
||||
/* Get the percentage remaining */
|
||||
double current;
|
||||
double max;
|
||||
|
||||
CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)),
|
||||
kCFNumberDoubleType, ¤t);
|
||||
kCFNumberDoubleType, ¤t);
|
||||
CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)),
|
||||
kCFNumberDoubleType, &max);
|
||||
kCFNumberDoubleType, &max);
|
||||
|
||||
*level = (current * 100.0) / max;
|
||||
|
||||
|
|
|
@ -158,12 +158,12 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
|
|||
/* Convert previous '\0'. */
|
||||
*np = ' ';
|
||||
}
|
||||
/* Note location of current '\0'. */
|
||||
np = cp;
|
||||
if (*basenameOffset == 0) {
|
||||
*basenameOffset = cp - sp;
|
||||
}
|
||||
}
|
||||
/* Note location of current '\0'. */
|
||||
np = cp;
|
||||
if (*basenameOffset == 0) {
|
||||
*basenameOffset = cp - sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -247,10 +247,10 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
|
|||
if (sizeof(pti) == proc_pidinfo(proc->super.pid, PROC_PIDTASKINFO, 0, &pti, sizeof(pti))) {
|
||||
if (0 != proc->utime || 0 != proc->stime) {
|
||||
uint64_t diff = (pti.pti_total_system - proc->stime)
|
||||
+ (pti.pti_total_user - proc->utime);
|
||||
+ (pti.pti_total_user - proc->utime);
|
||||
|
||||
proc->super.percent_cpu = (double)diff * (double)dpl->super.cpuCount
|
||||
/ ((double)dpl->global_diff * 100000.0);
|
||||
/ ((double)dpl->global_diff * 100000.0);
|
||||
|
||||
// fprintf(stderr, "%f %llu %llu %llu %llu %llu\n", proc->super.percent_cpu,
|
||||
// proc->stime, proc->utime, pti.pti_total_system, pti.pti_total_user, dpl->global_diff);
|
||||
|
@ -263,7 +263,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
|
|||
proc->super.m_resident = pti.pti_resident_size / CRT_pageSize;
|
||||
proc->super.majflt = pti.pti_faults;
|
||||
proc->super.percent_mem = (double)pti.pti_resident_size * 100.0
|
||||
/ (double)dpl->host_info.max_mem;
|
||||
/ (double)dpl->host_info.max_mem;
|
||||
|
||||
proc->stime = pti.pti_total_system;
|
||||
proc->utime = pti.pti_total_user;
|
||||
|
|
|
@ -24,7 +24,7 @@ in the source distribution for its full text.
|
|||
#include <stdbool.h>
|
||||
|
||||
struct kern {
|
||||
short int version[3];
|
||||
short int version[3];
|
||||
};
|
||||
|
||||
void GetKernelVersion(struct kern *k) {
|
||||
|
@ -35,9 +35,11 @@ void GetKernelVersion(struct kern *k) {
|
|||
char str[256] = {0};
|
||||
size_t size = sizeof(str);
|
||||
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
|
||||
if (ret == 0) sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]);
|
||||
}
|
||||
memcpy(k->version, version_, sizeof(version_));
|
||||
if (ret == 0) {
|
||||
sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]);
|
||||
}
|
||||
}
|
||||
memcpy(k->version, version_, sizeof(version_));
|
||||
}
|
||||
|
||||
/* compare the given os version with the one installed returns:
|
||||
|
@ -46,28 +48,36 @@ positive value if less than the installed version
|
|||
negative value if more than the installed version
|
||||
*/
|
||||
int CompareKernelVersion(short int major, short int minor, short int component) {
|
||||
struct kern k;
|
||||
GetKernelVersion(&k);
|
||||
if ( k.version[0] != major) return k.version[0] - major;
|
||||
if ( k.version[1] != minor) return k.version[1] - minor;
|
||||
if ( k.version[2] != component) return k.version[2] - component;
|
||||
return 0;
|
||||
struct kern k;
|
||||
GetKernelVersion(&k);
|
||||
|
||||
if (k.version[0] != major) {
|
||||
return k.version[0] - major;
|
||||
}
|
||||
if (k.version[1] != minor) {
|
||||
return k.version[1] - minor;
|
||||
}
|
||||
if (k.version[2] != component) {
|
||||
return k.version[2] - component;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
|
||||
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
|
||||
|
||||
if (0 != host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)p, &info_size)) {
|
||||
CRT_fatalError("Unable to retrieve host info\n");
|
||||
CRT_fatalError("Unable to retrieve host info\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessList_freeCPULoadInfo(processor_cpu_load_info_t *p) {
|
||||
if (NULL != p && NULL != *p) {
|
||||
if (0 != munmap(*p, vm_page_size)) {
|
||||
CRT_fatalError("Unable to free old CPU load information\n");
|
||||
}
|
||||
*p = NULL;
|
||||
if (0 != munmap(*p, vm_page_size)) {
|
||||
CRT_fatalError("Unable to free old CPU load information\n");
|
||||
}
|
||||
*p = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,18 +86,19 @@ unsigned ProcessList_allocateCPULoadInfo(processor_cpu_load_info_t *p) {
|
|||
unsigned cpu_count;
|
||||
|
||||
// TODO Improving the accuracy of the load counts woule help a lot.
|
||||
if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)p, &info_size)) {
|
||||
CRT_fatalError("Unable to retrieve CPU info\n");
|
||||
if (0 != host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t*)p, &info_size)) {
|
||||
CRT_fatalError("Unable to retrieve CPU info\n");
|
||||
}
|
||||
|
||||
return cpu_count;
|
||||
}
|
||||
|
||||
void ProcessList_getVMStats(vm_statistics_t p) {
|
||||
mach_msg_type_number_t info_size = HOST_VM_INFO_COUNT;
|
||||
mach_msg_type_number_t info_size = HOST_VM_INFO_COUNT;
|
||||
|
||||
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)p, &info_size) != 0)
|
||||
CRT_fatalError("Unable to retrieve VM statistics\n");
|
||||
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)p, &info_size) != 0) {
|
||||
CRT_fatalError("Unable to retrieve VM statistics\n");
|
||||
}
|
||||
}
|
||||
|
||||
struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
|
||||
|
@ -145,67 +156,68 @@ void ProcessList_delete(ProcessList* this) {
|
|||
}
|
||||
|
||||
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
||||
DarwinProcessList *dpl = (DarwinProcessList *)super;
|
||||
bool preExisting = true;
|
||||
struct kinfo_proc *ps;
|
||||
size_t count;
|
||||
DarwinProcess *proc;
|
||||
DarwinProcessList* dpl = (DarwinProcessList*)super;
|
||||
bool preExisting = true;
|
||||
struct kinfo_proc* ps;
|
||||
size_t count;
|
||||
DarwinProcess* proc;
|
||||
|
||||
/* Update the global data (CPU times and VM stats) */
|
||||
ProcessList_freeCPULoadInfo(&dpl->prev_load);
|
||||
dpl->prev_load = dpl->curr_load;
|
||||
ProcessList_allocateCPULoadInfo(&dpl->curr_load);
|
||||
ProcessList_getVMStats(&dpl->vm_stats);
|
||||
openzfs_sysctl_updateArcStats(&dpl->zfs);
|
||||
/* Update the global data (CPU times and VM stats) */
|
||||
ProcessList_freeCPULoadInfo(&dpl->prev_load);
|
||||
dpl->prev_load = dpl->curr_load;
|
||||
ProcessList_allocateCPULoadInfo(&dpl->curr_load);
|
||||
ProcessList_getVMStats(&dpl->vm_stats);
|
||||
openzfs_sysctl_updateArcStats(&dpl->zfs);
|
||||
|
||||
// in pause mode only gather global data for meters (CPU/memory/...)
|
||||
if (pauseProcessUpdate)
|
||||
return;
|
||||
// in pause mode only gather global data for meters (CPU/memory/...)
|
||||
if (pauseProcessUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the time difference */
|
||||
dpl->global_diff = 0;
|
||||
for (int i = 0; i < dpl->super.cpuCount; ++i) {
|
||||
for (size_t j = 0; j < CPU_STATE_MAX; ++j) {
|
||||
dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j];
|
||||
}
|
||||
}
|
||||
/* Get the time difference */
|
||||
dpl->global_diff = 0;
|
||||
for (int i = 0; i < dpl->super.cpuCount; ++i) {
|
||||
for (size_t j = 0; j < CPU_STATE_MAX; ++j) {
|
||||
dpl->global_diff += dpl->curr_load[i].cpu_ticks[j] - dpl->prev_load[i].cpu_ticks[j];
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear the thread counts */
|
||||
super->kernelThreads = 0;
|
||||
super->userlandThreads = 0;
|
||||
super->totalTasks = 0;
|
||||
super->runningTasks = 0;
|
||||
/* Clear the thread counts */
|
||||
super->kernelThreads = 0;
|
||||
super->userlandThreads = 0;
|
||||
super->totalTasks = 0;
|
||||
super->runningTasks = 0;
|
||||
|
||||
/* We use kinfo_procs for initial data since :
|
||||
*
|
||||
* 1) They always succeed.
|
||||
* 2) The contain the basic information.
|
||||
*
|
||||
* We attempt to fill-in additional information with libproc.
|
||||
*/
|
||||
ps = ProcessList_getKInfoProcs(&count);
|
||||
/* We use kinfo_procs for initial data since :
|
||||
*
|
||||
* 1) They always succeed.
|
||||
* 2) The contain the basic information.
|
||||
*
|
||||
* We attempt to fill-in additional information with libproc.
|
||||
*/
|
||||
ps = ProcessList_getKInfoProcs(&count);
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
proc = (DarwinProcess*)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, DarwinProcess_new);
|
||||
|
||||
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting);
|
||||
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
||||
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], preExisting);
|
||||
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
||||
|
||||
// Disabled for High Sierra due to bug in macOS High Sierra
|
||||
bool isScanThreadSupported = ! ( CompareKernelVersion(17, 0, 0) >= 0 && CompareKernelVersion(17, 5, 0) < 0);
|
||||
// Disabled for High Sierra due to bug in macOS High Sierra
|
||||
bool isScanThreadSupported = ! ( CompareKernelVersion(17, 0, 0) >= 0 && CompareKernelVersion(17, 5, 0) < 0);
|
||||
|
||||
if (isScanThreadSupported){
|
||||
DarwinProcess_scanThreads(proc);
|
||||
}
|
||||
if (isScanThreadSupported) {
|
||||
DarwinProcess_scanThreads(proc);
|
||||
}
|
||||
|
||||
super->totalTasks += 1;
|
||||
super->totalTasks += 1;
|
||||
|
||||
if (!preExisting) {
|
||||
proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid);
|
||||
if (!preExisting) {
|
||||
proc->super.user = UsersTable_getRef(super->usersTable, proc->super.st_uid);
|
||||
|
||||
ProcessList_add(super, &proc->super);
|
||||
}
|
||||
}
|
||||
ProcessList_add(super, &proc->super);
|
||||
}
|
||||
}
|
||||
|
||||
free(ps);
|
||||
free(ps);
|
||||
}
|
||||
|
|
|
@ -211,11 +211,11 @@ double Platform_setCPUValues(Meter* mtr, int cpu) {
|
|||
}
|
||||
|
||||
mtr->values[CPU_METER_NICE]
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_NICE] - (double)prev->cpu_ticks[CPU_STATE_NICE])* 100.0 / total;
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_NICE] - (double)prev->cpu_ticks[CPU_STATE_NICE]) * 100.0 / total;
|
||||
mtr->values[CPU_METER_NORMAL]
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_USER] - (double)prev->cpu_ticks[CPU_STATE_USER])* 100.0 / total;
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_USER] - (double)prev->cpu_ticks[CPU_STATE_USER]) * 100.0 / total;
|
||||
mtr->values[CPU_METER_KERNEL]
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM])* 100.0 / total;
|
||||
= ((double)curr->cpu_ticks[CPU_STATE_SYSTEM] - (double)prev->cpu_ticks[CPU_STATE_SYSTEM]) * 100.0 / total;
|
||||
|
||||
mtr->curItems = 3;
|
||||
|
||||
|
@ -239,13 +239,13 @@ void Platform_setMemoryValues(Meter* mtr) {
|
|||
}
|
||||
|
||||
void Platform_setSwapValues(Meter* mtr) {
|
||||
int mib[2] = {CTL_VM, VM_SWAPUSAGE};
|
||||
struct xsw_usage swapused;
|
||||
size_t swlen = sizeof(swapused);
|
||||
sysctl(mib, 2, &swapused, &swlen, NULL, 0);
|
||||
int mib[2] = {CTL_VM, VM_SWAPUSAGE};
|
||||
struct xsw_usage swapused;
|
||||
size_t swlen = sizeof(swapused);
|
||||
sysctl(mib, 2, &swapused, &swlen, NULL, 0);
|
||||
|
||||
mtr->total = swapused.xsu_total / 1024;
|
||||
mtr->values[0] = swapused.xsu_used / 1024;
|
||||
mtr->total = swapused.xsu_total / 1024;
|
||||
mtr->values[0] = swapused.xsu_used / 1024;
|
||||
}
|
||||
|
||||
void Platform_setZfsArcValues(Meter* this) {
|
||||
|
|
|
@ -101,10 +101,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
|
|||
pl->cpuCount = MAXIMUM(cpus, 1);
|
||||
|
||||
if (cpus == 1 ) {
|
||||
dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData));
|
||||
dfpl->cpus = xRealloc(dfpl->cpus, sizeof(CPUData));
|
||||
} else {
|
||||
// on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well)
|
||||
dfpl->cpus = xRealloc(dfpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData));
|
||||
// on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well)
|
||||
dfpl->cpus = xRealloc(dfpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData));
|
||||
}
|
||||
|
||||
len = sizeof(kernelFScale);
|
||||
|
@ -161,12 +161,12 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
|
||||
// get rest of CPUs
|
||||
if (cpus > 1) {
|
||||
// on smp systems DragonFlyBSD kernel concats all CPU states into one long array in
|
||||
// kern.cp_times sysctl OID
|
||||
// we store averages in dfpl->cpus[0], and actual cores after that
|
||||
maxcpu = cpus + 1;
|
||||
sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES;
|
||||
sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_n, &sizeof_cp_time_array, NULL, 0);
|
||||
// on smp systems DragonFlyBSD kernel concats all CPU states into one long array in
|
||||
// kern.cp_times sysctl OID
|
||||
// we store averages in dfpl->cpus[0], and actual cores after that
|
||||
maxcpu = cpus + 1;
|
||||
sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES;
|
||||
sysctl(MIB_kern_cp_times, 2, dfpl->cp_times_n, &sizeof_cp_time_array, NULL, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxcpu; i++) {
|
||||
|
@ -176,14 +176,14 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
cp_time_o = dfpl->cp_time_o;
|
||||
} else {
|
||||
if (i == 0 ) {
|
||||
// average
|
||||
cp_time_n = dfpl->cp_time_n;
|
||||
cp_time_o = dfpl->cp_time_o;
|
||||
// average
|
||||
cp_time_n = dfpl->cp_time_n;
|
||||
cp_time_o = dfpl->cp_time_o;
|
||||
} else {
|
||||
// specific smp cores
|
||||
cp_times_offset = i - 1;
|
||||
cp_time_n = dfpl->cp_times_n + (cp_times_offset * CPUSTATES);
|
||||
cp_time_o = dfpl->cp_times_o + (cp_times_offset * CPUSTATES);
|
||||
// specific smp cores
|
||||
cp_times_offset = i - 1;
|
||||
cp_time_n = dfpl->cp_times_n + (cp_times_offset * CPUSTATES);
|
||||
cp_time_o = dfpl->cp_times_o + (cp_times_offset * CPUSTATES);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,9 +192,9 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
unsigned long long total_n = 0;
|
||||
unsigned long long total_d = 0;
|
||||
for (int s = 0; s < CPUSTATES; s++) {
|
||||
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
||||
total_o += cp_time_o[s];
|
||||
total_n += cp_time_n[s];
|
||||
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
||||
total_o += cp_time_o[s];
|
||||
total_n += cp_time_n[s];
|
||||
}
|
||||
|
||||
// totals
|
||||
|
@ -203,8 +203,8 @@ static inline void DragonFlyBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
|
||||
// save current state as old and calc percentages
|
||||
for (int s = 0; s < CPUSTATES; ++s) {
|
||||
cp_time_o[s] = cp_time_n[s];
|
||||
cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100;
|
||||
cp_time_o[s] = cp_time_n[s];
|
||||
cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100;
|
||||
}
|
||||
|
||||
CPUData* cpuData = &(dfpl->cpus[i]);
|
||||
|
@ -344,8 +344,9 @@ retry:
|
|||
}
|
||||
|
||||
curpos = nextpos;
|
||||
}
|
||||
free(jls);
|
||||
}
|
||||
|
||||
free(jls);
|
||||
}
|
||||
|
||||
char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) {
|
||||
|
|
|
@ -154,10 +154,10 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
|||
const CPUData* cpuData;
|
||||
|
||||
if (cpus == 1) {
|
||||
// single CPU box has everything in fpl->cpus[0]
|
||||
cpuData = &(fpl->cpus[0]);
|
||||
// single CPU box has everything in fpl->cpus[0]
|
||||
cpuData = &(fpl->cpus[0]);
|
||||
} else {
|
||||
cpuData = &(fpl->cpus[cpu]);
|
||||
cpuData = &(fpl->cpus[cpu]);
|
||||
}
|
||||
|
||||
double percent;
|
||||
|
|
|
@ -124,10 +124,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
|
|||
pl->cpuCount = MAXIMUM(cpus, 1);
|
||||
|
||||
if (cpus == 1 ) {
|
||||
fpl->cpus = xRealloc(fpl->cpus, sizeof(CPUData));
|
||||
fpl->cpus = xRealloc(fpl->cpus, sizeof(CPUData));
|
||||
} else {
|
||||
// on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well)
|
||||
fpl->cpus = xRealloc(fpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData));
|
||||
// on smp we need CPUs + 1 to store averages too (as kernel kindly provides that as well)
|
||||
fpl->cpus = xRealloc(fpl->cpus, (pl->cpuCount + 1) * sizeof(CPUData));
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,12 +187,12 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
|
||||
// get rest of CPUs
|
||||
if (cpus > 1) {
|
||||
// on smp systems FreeBSD kernel concats all CPU states into one long array in
|
||||
// kern.cp_times sysctl OID
|
||||
// we store averages in fpl->cpus[0], and actual cores after that
|
||||
maxcpu = cpus + 1;
|
||||
sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES;
|
||||
sysctl(MIB_kern_cp_times, 2, fpl->cp_times_n, &sizeof_cp_time_array, NULL, 0);
|
||||
// on smp systems FreeBSD kernel concats all CPU states into one long array in
|
||||
// kern.cp_times sysctl OID
|
||||
// we store averages in fpl->cpus[0], and actual cores after that
|
||||
maxcpu = cpus + 1;
|
||||
sizeof_cp_time_array = cpus * sizeof(unsigned long) * CPUSTATES;
|
||||
sysctl(MIB_kern_cp_times, 2, fpl->cp_times_n, &sizeof_cp_time_array, NULL, 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxcpu; i++) {
|
||||
|
@ -202,14 +202,14 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
cp_time_o = fpl->cp_time_o;
|
||||
} else {
|
||||
if (i == 0 ) {
|
||||
// average
|
||||
cp_time_n = fpl->cp_time_n;
|
||||
cp_time_o = fpl->cp_time_o;
|
||||
// average
|
||||
cp_time_n = fpl->cp_time_n;
|
||||
cp_time_o = fpl->cp_time_o;
|
||||
} else {
|
||||
// specific smp cores
|
||||
cp_times_offset = i - 1;
|
||||
cp_time_n = fpl->cp_times_n + (cp_times_offset * CPUSTATES);
|
||||
cp_time_o = fpl->cp_times_o + (cp_times_offset * CPUSTATES);
|
||||
// specific smp cores
|
||||
cp_times_offset = i - 1;
|
||||
cp_time_n = fpl->cp_times_n + (cp_times_offset * CPUSTATES);
|
||||
cp_time_o = fpl->cp_times_o + (cp_times_offset * CPUSTATES);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,9 +218,9 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
unsigned long long total_n = 0;
|
||||
unsigned long long total_d = 0;
|
||||
for (int s = 0; s < CPUSTATES; s++) {
|
||||
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
||||
total_o += cp_time_o[s];
|
||||
total_n += cp_time_n[s];
|
||||
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
||||
total_o += cp_time_o[s];
|
||||
total_n += cp_time_n[s];
|
||||
}
|
||||
|
||||
// totals
|
||||
|
@ -229,8 +229,8 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||
|
||||
// save current state as old and calc percentages
|
||||
for (int s = 0; s < CPUSTATES; ++s) {
|
||||
cp_time_o[s] = cp_time_n[s];
|
||||
cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100;
|
||||
cp_time_o[s] = cp_time_n[s];
|
||||
cp_time_p[s] = ((double)cp_time_d[s]) / ((double)total_d) * 100;
|
||||
}
|
||||
|
||||
CPUData* cpuData = &(fpl->cpus[i]);
|
||||
|
|
|
@ -165,10 +165,10 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
|||
const CPUData* cpuData;
|
||||
|
||||
if (cpus == 1) {
|
||||
// single CPU box has everything in fpl->cpus[0]
|
||||
cpuData = &(fpl->cpus[0]);
|
||||
// single CPU box has everything in fpl->cpus[0]
|
||||
cpuData = &(fpl->cpus[0]);
|
||||
} else {
|
||||
cpuData = &(fpl->cpus[cpu]);
|
||||
cpuData = &(fpl->cpus[cpu]);
|
||||
}
|
||||
|
||||
double percent;
|
||||
|
|
|
@ -194,11 +194,11 @@ bool LinuxProcess_setIOPriority(Process* this, Arg ioprio) {
|
|||
|
||||
#ifdef HAVE_DELAYACCT
|
||||
void LinuxProcess_printDelay(float delay_percent, char* buffer, int n) {
|
||||
if (isnan(delay_percent)) {
|
||||
xSnprintf(buffer, n, " N/A ");
|
||||
} else {
|
||||
xSnprintf(buffer, n, "%4.1f ", delay_percent);
|
||||
}
|
||||
if (isnan(delay_percent)) {
|
||||
xSnprintf(buffer, n, " N/A ");
|
||||
} else {
|
||||
xSnprintf(buffer, n, "%4.1f ", delay_percent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -379,7 +379,8 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
|
|||
default:
|
||||
return Process_compare(v1, v2);
|
||||
}
|
||||
test_diff:
|
||||
|
||||
test_diff:
|
||||
return (diff > 0) ? 1 : (diff < 0 ? -1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -419,20 +419,20 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||
while ((line = strsep(&buf, "\n")) != NULL) {
|
||||
switch (line[0]) {
|
||||
case 'r':
|
||||
if (line[1] == 'c' && String_startsWith(line+2, "har: "))
|
||||
process->io_rchar = strtoull(line+7, NULL, 10);
|
||||
else if (String_startsWith(line+1, "ead_bytes: ")) {
|
||||
process->io_read_bytes = strtoull(line+12, NULL, 10);
|
||||
if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
|
||||
process->io_rchar = strtoull(line + 7, NULL, 10);
|
||||
} else if (String_startsWith(line + 1, "ead_bytes: ")) {
|
||||
process->io_read_bytes = strtoull(line + 12, NULL, 10);
|
||||
process->io_rate_read_bps =
|
||||
((double)(process->io_read_bytes - last_read))/(((double)(now - process->io_rate_read_time))/1000);
|
||||
process->io_rate_read_time = now;
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
if (line[1] == 'c' && String_startsWith(line+2, "har: "))
|
||||
process->io_wchar = strtoull(line+7, NULL, 10);
|
||||
else if (String_startsWith(line+1, "rite_bytes: ")) {
|
||||
process->io_write_bytes = strtoull(line+13, NULL, 10);
|
||||
if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
|
||||
process->io_wchar = strtoull(line + 7, NULL, 10);
|
||||
} else if (String_startsWith(line + 1, "rite_bytes: ")) {
|
||||
process->io_write_bytes = strtoull(line + 13, NULL, 10);
|
||||
process->io_rate_write_bps =
|
||||
((double)(process->io_write_bytes - last_write))/(((double)(now - process->io_rate_write_time))/1000);
|
||||
process->io_rate_write_time = now;
|
||||
|
@ -446,8 +446,8 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||
}
|
||||
break;
|
||||
case 'c':
|
||||
if (String_startsWith(line+1, "ancelled_write_bytes: ")) {
|
||||
process->io_cancelled_write_bytes = strtoull(line+23, NULL, 10);
|
||||
if (String_startsWith(line + 1, "ancelled_write_bytes: ")) {
|
||||
process->io_cancelled_write_bytes = strtoull(line + 23, NULL, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1087,7 +1087,9 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||
continue;
|
||||
|
||||
// Exception handler.
|
||||
errorReadingProcess: {
|
||||
|
||||
errorReadingProcess:
|
||||
{
|
||||
if (preExisting) {
|
||||
ProcessList_remove(pl, proc);
|
||||
} else {
|
||||
|
|
|
@ -24,24 +24,24 @@ static const int PressureStallMeter_attributes[] = {
|
|||
};
|
||||
|
||||
static void PressureStallMeter_updateValues(Meter* this, char* buffer, int len) {
|
||||
const char *file;
|
||||
if (strstr(Meter_name(this), "CPU")) {
|
||||
file = "cpu";
|
||||
} else if (strstr(Meter_name(this), "IO")) {
|
||||
file = "io";
|
||||
} else {
|
||||
file = "memory";
|
||||
}
|
||||
const char* file;
|
||||
if (strstr(Meter_name(this), "CPU")) {
|
||||
file = "cpu";
|
||||
} else if (strstr(Meter_name(this), "IO")) {
|
||||
file = "io";
|
||||
} else {
|
||||
file = "memory";
|
||||
}
|
||||
|
||||
bool some;
|
||||
if (strstr(Meter_name(this), "Some")) {
|
||||
some = true;
|
||||
} else {
|
||||
some = false;
|
||||
}
|
||||
bool some;
|
||||
if (strstr(Meter_name(this), "Some")) {
|
||||
some = true;
|
||||
} else {
|
||||
some = false;
|
||||
}
|
||||
|
||||
Platform_getPressureStall(file, some, &this->values[0], &this->values[1], &this->values[2]);
|
||||
xSnprintf(buffer, len, "xxxx %.2lf%% %.2lf%% %.2lf%%", this->values[0], this->values[1], this->values[2]);
|
||||
Platform_getPressureStall(file, some, &this->values[0], &this->values[1], &this->values[2]);
|
||||
xSnprintf(buffer, len, "xxxx %.2lf%% %.2lf%% %.2lf%%", this->values[0], this->values[1], this->values[2]);
|
||||
}
|
||||
|
||||
static void PressureStallMeter_display(const Object* cast, RichString* out) {
|
||||
|
|
|
@ -32,127 +32,152 @@ ProcessFieldData Process_fields[] = {
|
|||
.name = "",
|
||||
.title = NULL,
|
||||
.description = NULL,
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PID] = {
|
||||
.name = "PID",
|
||||
.title = " PID ",
|
||||
.description = "Process/thread ID",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[COMM] = {
|
||||
.name = "Command",
|
||||
.title = "Command ",
|
||||
.description = "Command line",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[STATE] = {
|
||||
.name = "STATE",
|
||||
.title = "S ",
|
||||
.description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PPID] = {
|
||||
.name = "PPID",
|
||||
.title = " PPID ",
|
||||
.description = "Parent process ID",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PGRP] = {
|
||||
.name = "PGRP",
|
||||
.title = " PGRP ",
|
||||
.description = "Process group ID",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[SESSION] = {
|
||||
.name = "SESSION",
|
||||
.title = " SESN ",
|
||||
.description = "Process's session ID",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[TTY_NR] = {
|
||||
.name = "TTY_NR",
|
||||
.title = " TTY ",
|
||||
.description = "Controlling terminal",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[TPGID] = {
|
||||
.name = "TPGID",
|
||||
.title = " TPGID ",
|
||||
.description = "Process ID of the fg process group of the controlling terminal",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[MINFLT] = {
|
||||
.name = "MINFLT",
|
||||
.title = " MINFLT ",
|
||||
.description = "Number of minor faults which have not required loading a memory page from disk",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[MAJFLT] = {
|
||||
.name = "MAJFLT",
|
||||
.title = " MAJFLT ",
|
||||
.description = "Number of major faults which have required loading a memory page from disk",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PRIORITY] = {
|
||||
.name = "PRIORITY",
|
||||
.title = "PRI ",
|
||||
.description = "Kernel's internal priority for the process",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[NICE] = {
|
||||
.name = "NICE",
|
||||
.title = " NI ",
|
||||
.description = "Nice value (the higher the value, the more it lets other processes take priority)",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[STARTTIME] = {
|
||||
.name = "STARTTIME",
|
||||
.title = "START ",
|
||||
.description = "Time the process was started",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PROCESSOR] = {
|
||||
.name = "PROCESSOR",
|
||||
.title = "CPU ",
|
||||
.description = "Id of the CPU the process last executed on",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[M_SIZE] = {
|
||||
.name = "M_SIZE",
|
||||
.title = " VIRT ",
|
||||
.description = "Total program size in virtual memory",
|
||||
.flags = 0, },
|
||||
.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, },
|
||||
.flags = 0,
|
||||
},
|
||||
[ST_UID] = {
|
||||
.name = "ST_UID",
|
||||
.title = " UID ",
|
||||
.description = "User ID of the process owner",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[PERCENT_CPU] = {
|
||||
.name = "PERCENT_CPU",
|
||||
.title = "CPU% ",
|
||||
.description = "Percentage of the CPU time the process used in the last sampling",
|
||||
.flags = 0, },
|
||||
.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, },
|
||||
.flags = 0,
|
||||
},
|
||||
[USER] = {
|
||||
.name = "USER",
|
||||
.title = "USER ",
|
||||
.description = "Username of the process owner (or user ID if name cannot be determined)",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[TIME] = {
|
||||
.name = "TIME",
|
||||
.title = " TIME+ ",
|
||||
.description = "Total time the process has spent in user and system time",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[NLWP] = {
|
||||
.name = "NLWP",
|
||||
.title = "NLWP ",
|
||||
.description = "Number of threads in the process",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[TGID] = {
|
||||
.name = "TGID",
|
||||
.title = " TGID ",
|
||||
.description = "Thread group ID (i.e. process ID)",
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
[LAST_PROCESSFIELD] = {
|
||||
.name = "*** report bug! ***",
|
||||
.title = NULL,
|
||||
.description = NULL,
|
||||
.flags = 0, },
|
||||
.flags = 0,
|
||||
},
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
|
|
|
@ -254,7 +254,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
|||
return NULL;
|
||||
|
||||
if ((kproc = kvm_getprocs(kt, KERN_PROC_PID, pid,
|
||||
sizeof(struct kinfo_proc), &count)) == NULL) {\
|
||||
sizeof(struct kinfo_proc), &count)) == NULL) {
|
||||
(void) kvm_close(kt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -278,10 +278,10 @@ char* Platform_getProcessEnv(pid_t pid) {
|
|||
}
|
||||
|
||||
if (size < 2 || env[size - 1] || env[size - 2]) {
|
||||
if (size + 2 < capacity)
|
||||
env = xRealloc(env, capacity + 2);
|
||||
env[size] = 0;
|
||||
env[size+1] = 0;
|
||||
if (size + 2 < capacity)
|
||||
env = xRealloc(env, capacity + 2);
|
||||
env[size] = 0;
|
||||
env[size + 1] = 0;
|
||||
}
|
||||
|
||||
(void) kvm_close(kt);
|
||||
|
|
|
@ -172,10 +172,10 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
|||
const CPUData* cpuData = NULL;
|
||||
|
||||
if (cpus == 1) {
|
||||
// single CPU box has everything in spl->cpus[0]
|
||||
cpuData = &(spl->cpus[0]);
|
||||
// single CPU box has everything in spl->cpus[0]
|
||||
cpuData = &(spl->cpus[0]);
|
||||
} else {
|
||||
cpuData = &(spl->cpus[cpu]);
|
||||
cpuData = &(spl->cpus[cpu]);
|
||||
}
|
||||
|
||||
double percent;
|
||||
|
|
|
@ -29,16 +29,18 @@ in the source distribution for its full text.
|
|||
#define MAXCMDLINE 255
|
||||
|
||||
char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) {
|
||||
char* zname;
|
||||
if ( sproc->zoneid == 0 ) {
|
||||
zname = xStrdup(GZONE);
|
||||
} else if ( kd == NULL ) {
|
||||
zname = xStrdup(UZONE);
|
||||
} else {
|
||||
kstat_t* ks = kstat_lookup( kd, "zones", sproc->zoneid, NULL );
|
||||
zname = xStrdup(ks == NULL ? UZONE : ks->ks_name);
|
||||
}
|
||||
return zname;
|
||||
char* zname;
|
||||
|
||||
if ( sproc->zoneid == 0 ) {
|
||||
zname = xStrdup(GZONE);
|
||||
} else if ( kd == NULL ) {
|
||||
zname = xStrdup(UZONE);
|
||||
} else {
|
||||
kstat_t* ks = kstat_lookup( kd, "zones", sproc->zoneid, NULL );
|
||||
zname = xStrdup(ks == NULL ? UZONE : ks->ks_name);
|
||||
}
|
||||
|
||||
return zname;
|
||||
}
|
||||
|
||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
|
||||
|
@ -78,15 +80,19 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
|
|||
assert(cpus > 0);
|
||||
|
||||
if (cpus > 1) {
|
||||
// Store values for the stats loop one extra element up in the array
|
||||
// to leave room for the average to be calculated afterwards
|
||||
arrskip++;
|
||||
// Store values for the stats loop one extra element up in the array
|
||||
// to leave room for the average to be calculated afterwards
|
||||
arrskip++;
|
||||
}
|
||||
|
||||
// Calculate per-CPU statistics first
|
||||
for (int i = 0; i < cpus; i++) {
|
||||
if (spl->kd != NULL) { cpuinfo = kstat_lookup(spl->kd,"cpu",i,"sys"); }
|
||||
if (cpuinfo != NULL) { kchain = kstat_read(spl->kd,cpuinfo,NULL); }
|
||||
if (spl->kd != NULL) {
|
||||
cpuinfo = kstat_lookup(spl->kd, "cpu", i, "sys");
|
||||
}
|
||||
if (cpuinfo != NULL) {
|
||||
kchain = kstat_read(spl->kd, cpuinfo, NULL);
|
||||
}
|
||||
if (kchain != -1 ) {
|
||||
idletime = kstat_data_lookup(cpuinfo,"cpu_nsec_idle");
|
||||
intrtime = kstat_data_lookup(cpuinfo,"cpu_nsec_intr");
|
||||
|
@ -170,7 +176,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
// 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) * CRT_pageSizeKB;
|
||||
} else {
|
||||
} else {
|
||||
// Fall back to basic sysconf if kstat isn't working
|
||||
pl->totalMem = sysconf(_SC_PHYS_PAGES) * CRT_pageSize;
|
||||
pl->buffersMem = 0;
|
||||
|
@ -180,8 +186,12 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||
|
||||
// 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 (nswap > 0) {
|
||||
sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int));
|
||||
}
|
||||
if (sl != NULL) {
|
||||
spathbase = xMalloc( nswap * MAXPATHLEN );
|
||||
}
|
||||
if (spathbase != NULL) {
|
||||
spath = spathbase;
|
||||
swapdev = sl->swt_ent;
|
||||
|
@ -211,8 +221,12 @@ static inline void SolarisProcessList_scanZfsArcstats(ProcessList* pl) {
|
|||
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 (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;
|
||||
|
|
|
@ -30,43 +30,43 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||
if (pauseProcessUpdate)
|
||||
return;
|
||||
|
||||
bool preExisting = true;
|
||||
Process *proc;
|
||||
bool preExisting = true;
|
||||
Process* proc;
|
||||
|
||||
proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
|
||||
proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
|
||||
|
||||
/* Empty values */
|
||||
proc->time = proc->time + 10;
|
||||
proc->pid = 1;
|
||||
proc->ppid = 1;
|
||||
proc->tgid = 0;
|
||||
proc->comm = "<unsupported architecture>";
|
||||
proc->basenameOffset = 0;
|
||||
proc->updated = true;
|
||||
/* Empty values */
|
||||
proc->time = proc->time + 10;
|
||||
proc->pid = 1;
|
||||
proc->ppid = 1;
|
||||
proc->tgid = 0;
|
||||
proc->comm = "<unsupported architecture>";
|
||||
proc->basenameOffset = 0;
|
||||
proc->updated = true;
|
||||
|
||||
proc->state = 'R';
|
||||
proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
|
||||
proc->pgrp = 0;
|
||||
proc->session = 0;
|
||||
proc->tty_nr = 0;
|
||||
proc->tpgid = 0;
|
||||
proc->st_uid = 0;
|
||||
proc->flags = 0;
|
||||
proc->processor = 0;
|
||||
proc->state = 'R';
|
||||
proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
|
||||
proc->pgrp = 0;
|
||||
proc->session = 0;
|
||||
proc->tty_nr = 0;
|
||||
proc->tpgid = 0;
|
||||
proc->st_uid = 0;
|
||||
proc->flags = 0;
|
||||
proc->processor = 0;
|
||||
|
||||
proc->percent_cpu = 2.5;
|
||||
proc->percent_mem = 2.5;
|
||||
proc->user = "nobody";
|
||||
proc->percent_cpu = 2.5;
|
||||
proc->percent_mem = 2.5;
|
||||
proc->user = "nobody";
|
||||
|
||||
proc->priority = 0;
|
||||
proc->nice = 0;
|
||||
proc->nlwp = 1;
|
||||
proc->starttime_ctime = 1433116800; // Jun 01, 2015
|
||||
Process_fillStarttimeBuffer(proc);
|
||||
proc->priority = 0;
|
||||
proc->nice = 0;
|
||||
proc->nlwp = 1;
|
||||
proc->starttime_ctime = 1433116800; // Jun 01, 2015
|
||||
Process_fillStarttimeBuffer(proc);
|
||||
|
||||
proc->m_size = 100;
|
||||
proc->m_resident = 100;
|
||||
proc->m_size = 100;
|
||||
proc->m_resident = 100;
|
||||
|
||||
proc->minflt = 20;
|
||||
proc->majflt = 20;
|
||||
proc->minflt = 20;
|
||||
proc->majflt = 20;
|
||||
}
|
||||
|
|
|
@ -33,21 +33,24 @@ void openzfs_sysctl_init(ZfsArcStats *stats) {
|
|||
|
||||
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);
|
||||
stats->enabled = 1;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue