summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/FreeBSDProcess.c4
-rw-r--r--freebsd/FreeBSDProcessList.c63
-rw-r--r--freebsd/Platform.c3
3 files changed, 53 insertions, 17 deletions
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
index f81fadf5..c8d30f69 100644
--- a/freebsd/FreeBSDProcess.c
+++ b/freebsd/FreeBSDProcess.c
@@ -73,7 +73,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, },
@@ -119,7 +119,7 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
// add FreeBSD-specific fields here
case JID: xSnprintf(buffer, n, Process_pidFormat, fp->jid); break;
case JAIL:{
- xSnprintf(buffer, n, "%-11s ", fp->jname); break;
+ xSnprintf(buffer, n, "%-11s ", fp->jname);
if (buffer[11] != '\0') {
buffer[11] = ' ';
buffer[12] = '\0';
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index fd694198..7bc42db6 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -20,6 +20,7 @@ in the source distribution for its full text.
#include <fcntl.h>
#include <limits.h>
#include <string.h>
+#include <time.h>
/*{
@@ -289,26 +290,51 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) {
//
// htop_used = active + (wired - arc)
// htop_cache = buffers + cache + arc
- size_t len = sizeof(pl->totalMem);
+ u_long totalMem;
+ u_int memActive, memWire, cachedMem;
+ long buffersMem;
+ uint64_t memZfsArc;
+ size_t len;
//disabled for now, as it is always smaller than phycal amount of memory...
//...to avoid "where is my memory?" questions
//sysctl(MIB_vm_stats_vm_v_page_count, 4, &(pl->totalMem), &len, NULL, 0);
//pl->totalMem *= pageSizeKb;
- sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0);
- pl->totalMem /= 1024;
-
- sysctl(MIB_vm_stats_vm_v_active_count, 4, &(fpl->memActive), &len, NULL, 0);
- fpl->memActive *= pageSizeKb;
-
- sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(fpl->memWire), &len, NULL, 0);
- fpl->memWire *= pageSizeKb;
-
- sysctl(MIB_vfs_bufspace, 2, &(pl->buffersMem), &len, NULL, 0);
- pl->buffersMem /= 1024;
-
- sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
- pl->cachedMem *= pageSizeKb;
+ len = sizeof(totalMem);
+ sysctl(MIB_hw_physmem, 2, &(totalMem), &len, NULL, 0);
+ totalMem /= 1024;
+ pl->totalMem = totalMem;
+
+ len = sizeof(memActive);
+ sysctl(MIB_vm_stats_vm_v_active_count, 4, &(memActive), &len, NULL, 0);
+ memActive *= pageSizeKb;
+ fpl->memActive = memActive;
+
+ len = sizeof(memWire);
+ sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(memWire), &len, NULL, 0);
+ memWire *= pageSizeKb;
+ fpl->memWire = memWire;
+
+ len = sizeof(buffersMem);
+ sysctl(MIB_vfs_bufspace, 2, &(buffersMem), &len, NULL, 0);
+ buffersMem /= 1024;
+ pl->buffersMem = buffersMem;
+
+ len = sizeof(cachedMem);
+ sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(cachedMem), &len, NULL, 0);
+ cachedMem *= pageSizeKb;
+ pl->cachedMem = cachedMem;
+
+ if (fpl->zfsArcEnabled) {
+ len = sizeof(memZfsArc);
+ sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(memZfsArc), &len , NULL, 0);
+ memZfsArc /= 1024;
+ fpl->memZfsArc = memZfsArc;
+ fpl->memWire -= fpl->memZfsArc;
+ pl->cachedMem += fpl->memZfsArc;
+ // maybe when we learn how to make custom memory meter
+ // we could do custom arc breakdown?
+ }
if (fpl->zfs.enabled) {
fpl->memWire -= fpl->zfs.size;
@@ -418,10 +444,14 @@ void ProcessList_goThroughEntries(ProcessList* this) {
int count = 0;
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+
for (int i = 0; i < count; i++) {
struct kinfo_proc* kproc = &kprocs[i];
bool preExisting = false;
bool isIdleProcess = false;
+ struct tm date;
Process* proc = ProcessList_getProcess(this, kproc->ki_pid, &preExisting, (Process_New) FreeBSDProcess_new);
FreeBSDProcess* fp = (FreeBSDProcess*) proc;
@@ -512,6 +542,9 @@ void ProcessList_goThroughEntries(ProcessList* this) {
this->kernelThreads++;
}
+ (void) localtime_r((time_t*) &proc->starttime_ctime, &date);
+ strftime(proc->starttime_show, 7, ((proc->starttime_ctime > tv.tv_sec - 86400) ? "%R " : "%b%d "), &date);
+
this->totalTasks++;
if (proc->state == 'R')
this->runningTasks++;
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 0986a3dd..e6acebdb 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -182,6 +182,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;
}