diff options
author | OBATA Akio <obache@wizdas.com> | 2019-04-06 16:49:26 +0900 |
---|---|---|
committer | OBATA Akio <obache@wizdas.com> | 2019-08-18 14:45:26 +0900 |
commit | 2a88ec3c02ab46c8b816cfa348ea53075f57a59c (patch) | |
tree | e7029145d265a0a6a31601a1eb476a719d6dd4b5 /ksysguard | |
parent | df19ff6b7dc7adcdb88e86d50d9d88d622a09d88 (diff) | |
download | tdebase-2a88ec3c02ab46c8b816cfa348ea53075f57a59c.tar.gz tdebase-2a88ec3c02ab46c8b816cfa348ea53075f57a59c.zip |
Revive NetBSD support
Catch up to TDE and OS changes
Signed-off-by: OBATA Akio <obache@wizdas.com>
Diffstat (limited to 'ksysguard')
-rw-r--r-- | ksysguard/gui/ksgrd/SensorManager.cc | 5 | ||||
-rw-r--r-- | ksysguard/ksysguardd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/CMakeLists.txt | 28 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/CPU.c | 76 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/ConfigureChecks.cmake | 13 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/Memory.c | 117 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/Memory.h | 14 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/ProcessList.c | 106 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/apm.c | 3 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/diskstat.c | 9 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/netdev.c | 5 | ||||
-rw-r--r-- | ksysguard/ksysguardd/NetBSD/netdev.h | 2 | ||||
-rw-r--r-- | ksysguard/ksysguardd/modules.h | 26 |
13 files changed, 249 insertions, 157 deletions
diff --git a/ksysguard/gui/ksgrd/SensorManager.cc b/ksysguard/gui/ksgrd/SensorManager.cc index 7794d9c10..237e73b23 100644 --- a/ksysguard/gui/ksgrd/SensorManager.cc +++ b/ksysguard/gui/ksgrd/SensorManager.cc @@ -60,6 +60,11 @@ SensorManager::SensorManager() mDict.insert( "used", new TQString( i18n( "Used Memory" ) ) ); mDict.insert( "application", new TQString( i18n( "Application Memory" ) ) ); mDict.insert( "free", new TQString( i18n( "Free Memory" ) ) ); + mDict.insert( "active", new TQString( i18n( "Active Memory" ) ) ); + mDict.insert( "inactive", new TQString( i18n( "Inactive Memory" ) ) ); + mDict.insert( "wired", new TQString( i18n( "Wired Memory" ) ) ); + mDict.insert( "execpages", new TQString( i18n( "Exec Pages" ) ) ); + mDict.insert( "filepages", new TQString( i18n( "File Pages" ) ) ); mDict.insert( "pscount", new TQString( i18n( "Process Count" ) ) ); mDict.insert( "ps", new TQString( i18n( "Process Controller" ) ) ); mDict.insert( "disk", new TQString( i18n( "Disk Throughput" ) ) ); diff --git a/ksysguard/ksysguardd/CMakeLists.txt b/ksysguard/ksysguardd/CMakeLists.txt index 58c5f2399..f90bdadb0 100644 --- a/ksysguard/ksysguardd/CMakeLists.txt +++ b/ksysguard/ksysguardd/CMakeLists.txt @@ -19,6 +19,8 @@ elseif( ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" ) set( OS_SPECIFIC_DIR OpenBSD ) elseif( ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" ) set( OS_SPECIFIC_DIR FreeBSD ) +elseif( ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" ) + set( OS_SPECIFIC_DIR NetBSD ) else() tde_message_fatal( "Your operating system (${CMAKE_SYSTEM_NAME}) is not supported yet." ) endif() diff --git a/ksysguard/ksysguardd/NetBSD/CMakeLists.txt b/ksysguard/ksysguardd/NetBSD/CMakeLists.txt new file mode 100644 index 000000000..0d0765382 --- /dev/null +++ b/ksysguard/ksysguardd/NetBSD/CMakeLists.txt @@ -0,0 +1,28 @@ +################################################# +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include( ConfigureChecks.cmake ) + +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ksysguard/CContLib + ${CMAKE_SOURCE_DIR}/ksysguard/ksysguardd +) + + +##### ksysguardd (static) ####################### + +if ( HAVE_APMIO ) + set( APM_SOURCES apm.c ) +endif ( HAVE_APMIO ) + +tde_add_library( ksysguardd STATIC + SOURCES + CPU.c Memory.c ProcessList.c ${APM_SOURCES} diskstat.c loadavg.c logfile.c netdev.c + LINK kvm +) diff --git a/ksysguard/ksysguardd/NetBSD/CPU.c b/ksysguard/ksysguardd/NetBSD/CPU.c index 959924087..1d80d9bb6 100644 --- a/ksysguard/ksysguardd/NetBSD/CPU.c +++ b/ksysguard/ksysguardd/NetBSD/CPU.c @@ -19,10 +19,11 @@ */ +#include <sys/param.h> +#include <sys/sysctl.h> #include <sys/dkstat.h> #include <sys/sched.h> /* CPUSTATES */ #include <fcntl.h> -#include <kvm.h> #include <nlist.h> #include <stdio.h> #include <stdlib.h> @@ -33,20 +34,11 @@ #include "Command.h" #include "ksysguardd.h" -long percentages(int cnt, int *out, long *new, long *old, long *diffs); +void percentages(int cnt, int *out, u_int64_t *new, u_int64_t *old, u_int64_t *diffs); -struct nlist my_nlist[] = { - {"_cp_time"}, - { 0 } -}; - -kvm_t *kd; - -unsigned long cp_time_offset; - -long cp_time[CPUSTATES]; -long cp_old[CPUSTATES]; -long cp_diff[CPUSTATES]; +u_int64_t cp_time[CPUSTATES]; +u_int64_t cp_old[CPUSTATES]; +u_int64_t cp_diff[CPUSTATES]; int cpu_states[CPUSTATES]; void @@ -61,9 +53,6 @@ initCpuInfo(struct SensorModul* sm) printCPUSysInfo, sm); registerMonitor("cpu/idle", "integer", printCPUIdle, printCPUIdleInfo, sm); - kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"); - kvm_nlist(kd, my_nlist); - cp_time_offset = my_nlist[0].n_value; updateCpuInfo(); } @@ -71,13 +60,18 @@ initCpuInfo(struct SensorModul* sm) void exitCpuInfo(void) { - kvm_close(kd); } int updateCpuInfo(void) { - kvm_read(kd, cp_time_offset, (char *)cp_time, sizeof(cp_time)); + int mib[2]; + size_t size; + + mib[0] = CTL_KERN; + mib[1] = KERN_CP_TIME; + size = sizeof(cp_time[0]) * CPUSTATES; + sysctl(mib, 2, cp_time, &size, NULL, 0); percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff); return (0); } @@ -152,20 +146,20 @@ printCPUIdleInfo(const char* cmd) * useful on BSD mchines for calculating cpu state percentages. */ -long percentages(cnt, out, new, old, diffs) +void percentages(cnt, out, new, old, diffs) int cnt; int *out; -register long *new; -register long *old; -long *diffs; +u_int64_t *new; +u_int64_t *old; +u_int64_t *diffs; { - register int i; - register long change; - register long total_change; - register long *dp; - long half_total; + int i; + u_int64_t change; + u_int64_t total_change; + u_int64_t *dp; + u_int64_t half_total; /* initialization */ total_change = 0; @@ -174,12 +168,11 @@ long *diffs; /* calculate changes for each state and the overall change */ for (i = 0; i < cnt; i++) { - if ((change = *new - *old) < 0) - { - /* this only happens when the counter wraps */ - change = (int) - ((unsigned long)*new-(unsigned long)*old); - } + /* + * Don't worry about wrapping - even at hz=1GHz, a + * u_int64_t will last at least 544 years. + */ + change = *new - *old; total_change += (*dp++ = change); *old++ = *new++; } @@ -191,16 +184,9 @@ long *diffs; } /* calculate percentages based on overall change, rounding up */ - half_total = total_change / 2l; - - /* Do not divide by 0. Causes Floating point exception */ - if(total_change) { - for (i = 0; i < cnt; i++) - { - *out++ = (int)((*diffs++ * 1000 + half_total) / total_change); - } + half_total = total_change / 2; + for (i = 0; i < cnt; i++) + { + *out++ = (int)((*diffs++ * 1000 + half_total) / total_change); } - - /* return the total in case the caller wants to use it */ - return(total_change); } diff --git a/ksysguard/ksysguardd/NetBSD/ConfigureChecks.cmake b/ksysguard/ksysguardd/NetBSD/ConfigureChecks.cmake new file mode 100644 index 000000000..60d0b0495 --- /dev/null +++ b/ksysguard/ksysguardd/NetBSD/ConfigureChecks.cmake @@ -0,0 +1,13 @@ +################################################# +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +# apmio +check_include_files( "sys/types.h;dev/apm/apmio.h" HAVE_DEV_APM_APMIO_H ) +if( HAVE_DEV_APM_APMIO_H ) + set( HAVE_APMIO 1 CACHE INTERNAL "" FORCE ) +endif( ) diff --git a/ksysguard/ksysguardd/NetBSD/Memory.c b/ksysguard/ksysguardd/NetBSD/Memory.c index 8e9779506..19931e62b 100644 --- a/ksysguard/ksysguardd/NetBSD/Memory.c +++ b/ksysguard/ksysguardd/NetBSD/Memory.c @@ -21,12 +21,12 @@ */ #include <fcntl.h> -#include <kvm.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/param.h> +#include <sys/resource.h> #include <sys/sysctl.h> #include <sys/types.h> #include <sys/vmmeter.h> @@ -34,6 +34,7 @@ /* Everything post 1.5.x uses uvm/uvm_* includes */ #if __NetBSD_Version__ >= 105010000 #include <uvm/uvm_param.h> +#include <uvm/uvm_extern.h> #else #include <vm/vm_param.h> #endif @@ -45,29 +46,25 @@ static size_t Total = 0; static size_t MFree = 0; static size_t Used = 0; -static size_t Buffers = 0; -static size_t Cached = 0; +static size_t Active =0; +static size_t Inactive = 0; +static size_t Wired = 0; +static size_t Execpages = 0; +static size_t Filepages = 0; static size_t STotal = 0; static size_t SFree = 0; static size_t SUsed = 0; -static kvm_t *kd; void initMemory(struct SensorModul* sm) { - char *nlistf = NULL; - char *memf = NULL; - char buf[_POSIX2_LINE_MAX]; - - if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL) { - log_error("kvm_openfiles()"); - return; - } - registerMonitor("mem/physical/free", "integer", printMFree, printMFreeInfo, sm); registerMonitor("mem/physical/used", "integer", printUsed, printUsedInfo, sm); - registerMonitor("mem/physical/buf", "integer", printBuffers, printBuffersInfo, sm); - registerMonitor("mem/physical/cached", "integer", printCached, printCachedInfo, sm); + registerMonitor("mem/physical/active", "integer", printActive, printActiveInfo, sm); + registerMonitor("mem/physical/inactive", "integer", printInactive, printInactiveInfo, sm); + registerMonitor("mem/physical/wired", "integer", printWired, printWiredInfo, sm); + registerMonitor("mem/physical/execpages", "integer", printExecpages, printExecpagesInfo, sm); + registerMonitor("mem/physical/filepages", "integer", printFilepages, printFilepagesInfo, sm); registerMonitor("mem/swap/free", "integer", printSwapFree, printSwapFreeInfo, sm); registerMonitor("mem/swap/used", "integer", printSwapUsed, printSwapUsedInfo, sm); } @@ -75,7 +72,6 @@ initMemory(struct SensorModul* sm) void exitMemory(void) { - kvm_close(kd); } int @@ -83,7 +79,6 @@ updateMemory(void) { #define ARRLEN(X) (sizeof(X)/sizeof(X[0])) - long pagesize; /* using a long promotes the arithmetic */ size_t len; { @@ -95,35 +90,23 @@ updateMemory(void) } { - struct uvmexp x; - static int mib[] = { CTL_VM, VM_UVMEXP }; + struct uvmexp_sysctl x; + static int mib[] = { CTL_VM, VM_UVMEXP2 }; len = sizeof(x); STotal = SUsed = SFree = -1; - pagesize = 1; + Active = Inactive = Wired = Execpages = Filepages = MFree = Used = -1; if (-1 < sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0)) { - pagesize = x.pagesize; - STotal = (pagesize*x.swpages) >> 10; - SUsed = (pagesize*x.swpginuse) >> 10; + STotal = (x.pagesize*x.swpages) >> 10; + SUsed = (x.pagesize*x.swpginuse) >> 10; SFree = STotal - SUsed; - } - } - - /* can't find NetBSD filesystem buffer info */ - Buffers = -1; - - /* NetBSD doesn't know about vm.stats */ - Cached = -1; - - { - static int mib[]={ CTL_VM, VM_METER }; - struct vmtotal x; - - len = sizeof(x); - MFree = Used = -1; - if (sysctl(mib, ARRLEN(mib), &x, &len, NULL, 0) > -1) { - MFree = (x.t_free * pagesize) >> 10; - Used = (x.t_rm * pagesize) >> 10; + MFree = STotal - SUsed; + Active = (x.active * x.pagesize) >> 10; + Inactive = (x.inactive * x.pagesize) >> 10; + Wired = (x.wired * x.pagesize) >> 10; + Execpages = (x.execpages * x.pagesize) >> 10; + Filepages = (x.filepages * x.pagesize) >> 10; + Used = Total - MFree; } } return 0; @@ -154,27 +137,63 @@ printUsedInfo(const char* cmd) } void -printBuffers(const char* cmd) +printActive(const char* cmd) +{ + fprintf(CurrentClient, "%d\n", Active); +} + +void +printActiveInfo(const char* cmd) +{ + fprintf(CurrentClient, "Active Memory\t0\t%dtKB\n", Total); +} + +void +printInactive(const char* cmd) +{ + fprintf(CurrentClient, "%d\n", Inactive); +} + +void +printInactiveInfo(const char* cmd) +{ + fprintf(CurrentClient, "Inctive Memory\t0\t%dtKB\n", Total); +} + +void +printWired(const char* cmd) +{ + fprintf(CurrentClient, "%d\n", Wired); +} + +void +printWiredInfo(const char* cmd) +{ + fprintf(CurrentClient, "Wired Memory\t0\t%dtKB\n", Total); +} + +void +printExecpages(const char* cmd) { - fprintf(CurrentClient, "%d\n", Buffers); + fprintf(CurrentClient, "%d\n", Execpages); } void -printBuffersInfo(const char* cmd) +printExecpagesInfo(const char* cmd) { - fprintf(CurrentClient, "Buffer Memory\t0\t%d\tKB\n", Total); + fprintf(CurrentClient, "Exec Pages\t0%d\tKB\n", Total); } void -printCached(const char* cmd) +printFilepages(const char* cmd) { - fprintf(CurrentClient, "%d\n", Cached); + fprintf(CurrentClient, "%d\n", Filepages); } void -printCachedInfo(const char* cmd) +printFilepagesInfo(const char* cmd) { - fprintf(CurrentClient, "Cached Memory\t0\t%d\tKB\n", Total); + fprintf(CurrentClient, "File Pages\t0\t%d\tKB\n", Total); } void diff --git a/ksysguard/ksysguardd/NetBSD/Memory.h b/ksysguard/ksysguardd/NetBSD/Memory.h index 57abb73a2..391306eec 100644 --- a/ksysguard/ksysguardd/NetBSD/Memory.h +++ b/ksysguard/ksysguardd/NetBSD/Memory.h @@ -31,10 +31,16 @@ void printMFree(const char* cmd); void printMFreeInfo(const char* cmd); void printUsed(const char* cmd); void printUsedInfo(const char* cmd); -void printBuffers(const char* cmd); -void printBuffersInfo(const char* cmd); -void printCached(const char* cmd); -void printCachedInfo(const char* cmd); +void printActive(const char* cmd); +void printActiveInfo(const char* cmd); +void printInactive(const char* cmd); +void printInactiveInfo(const char* cmd); +void printWired(const char* cmd); +void printWiredInfo(const char* cmd); +void printExecpages(const char* cmd); +void printExecpagesInfo(const char* cmd); +void printFilepages(const char* cmd); +void printFilepagesInfo(const char* cmd); void printSwapUsed(const char* cmd); void printSwapUsedInfo(const char* cmd); void printSwapFree(const char* cmd); diff --git a/ksysguard/ksysguardd/NetBSD/ProcessList.c b/ksysguard/ksysguardd/NetBSD/ProcessList.c index 54ab65513..13c65053d 100644 --- a/ksysguard/ksysguardd/NetBSD/ProcessList.c +++ b/ksysguard/ksysguardd/NetBSD/ProcessList.c @@ -24,15 +24,17 @@ #include <ctype.h> #include <dirent.h> +#include <errno.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <kvm.h> #include <sys/param.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/types.h> -#include <sys/user.h> +#include <sys/resource.h> #include <unistd.h> #include <signal.h> @@ -46,6 +48,8 @@ CONTAINER ProcessList = 0; #define BUFSIZE 1024 +static kvm_t *kd; + typedef struct { /* This flag is set for all found processes at the beginning of the @@ -157,15 +161,13 @@ findProcessInList(int pid) } static int -updateProcess(int pid) +updateProcess(int pid, struct kinfo_proc2 *p) { - static char *statuses[] = { "idle","run","sleep","stop","zombie" }; + static char *statuses[] = { "", "idle","run","sleep","stop","zombie","dead","onproc" }; ProcessInfo* ps; struct passwd* pwent; - int mib[4]; - struct kinfo_proc p; - size_t len; + char **argv, **a; if ((ps = findProcessInList(pid)) == 0) { @@ -178,26 +180,18 @@ updateProcess(int pid) ps->alive = 1; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = pid; - - len = sizeof (p); - if (sysctl(mib, 4, &p, &len, NULL, 0) == -1 || !len) - return -1; - - ps->pid = p.kp_proc.p_pid; - ps->ppid = p.kp_eproc.e_ppid; - ps->uid = p.kp_eproc.e_ucred.cr_uid; - ps->gid = p.kp_eproc.e_pgid; - ps->priority = p.kp_proc.p_priority; - ps->niceLevel = p.kp_proc.p_nice; + ps->pid = p->p_pid; + ps->ppid = p->p_ppid; + ps->uid = p->p_uid; + ps->gid = p->p_gid; + ps->priority = p->p_priority -22; /* why 22? */ + ps->niceLevel = p->p_nice - NZERO; - /* this isn't usertime -- it's total time (??) */ - ps->userTime = p.kp_proc.p_rtime.tv_sec*100+p.kp_proc.p_rtime.tv_usec/100; +#if 0 + ps->userTime = p->p_rtime_sec*100+p->p_rtime_usec/100; ps->sysTime = 0; ps->sysLoad = 0; +#endif /* memory, process name, process uid */ /* find out user name with process uid */ @@ -205,19 +199,26 @@ updateProcess(int pid) strlcpy(ps->userName,pwent&&pwent->pw_name? pwent->pw_name:"????",sizeof(ps->userName)); ps->userName[sizeof(ps->userName)-1]='\0'; - ps->userLoad = p.kp_proc.p_pctcpu / 100; - ps->vmSize = (p.kp_eproc.e_vm.vm_tsize + - p.kp_eproc.e_vm.vm_dsize + - p.kp_eproc.e_vm.vm_ssize) * getpagesize(); - ps->vmRss = p.kp_eproc.e_vm.vm_rssize * getpagesize(); - strlcpy(ps->name,p.kp_proc.p_comm ? p.kp_proc.p_comm : "????", sizeof(ps->name)); - strlcpy(ps->status,(p.kp_proc.p_stat>=1)&&(p.kp_proc.p_stat<=5)? statuses[p.kp_proc.p_stat-1]:"????", sizeof(ps->status)); + ps->userLoad = 100.0 * ((double)(p->p_pctcpu) /FSCALE); + ps->vmSize = (p->p_vm_tsize + + p->p_vm_dsize + + p->p_vm_ssize) * getpagesize(); + ps->vmRss = p->p_vm_rssize * getpagesize(); + strlcpy(ps->name,p->p_comm ? p->p_comm : "????", sizeof(ps->name)); + strlcpy(ps->status,(p->p_stat<=7)? statuses[p->p_stat]:"????", sizeof(ps->status)); /* process command line */ - /* the following line causes segfaults on some FreeBSD systems... why? - strncpy(ps->cmdline, p.kp_proc.p_args->ar_args, sizeof(ps->cmdline) - 1); - */ - strcpy(ps->cmdline, "????"); + argv = kvm_getargv2(kd, p, sizeof(ps->cmdline)); + ps->cmdline[0] = '\0'; + if ((a = argv) != NULL) { + while (*a) { + strlcat(ps->cmdline, *a, sizeof(ps->cmdline)); + a++; + strlcat(ps->cmdline, " ", sizeof(ps->cmdline)); + } + } else { + strcpy(ps->cmdline, "????"); + } return (0); } @@ -266,6 +267,8 @@ initProcessList(struct SensorModul* sm) registerCommand("setpriority", setPriority); } + kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); + updateProcessList(); } @@ -277,27 +280,22 @@ exitProcessList(void) if (ProcessList) free (ProcessList); + + kvm_close(kd); } int updateProcessList(void) { - int mib[3]; - size_t len; - size_t num; - struct kinfo_proc *p; - - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_ALL; - sysctl(mib, 3, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 3, p, &len, NULL, 0); - - for (num = 0; num < len / sizeof(struct kinfo_proc); num++) - updateProcess(p[num].kp_proc.p_pid); - free(p); + int len; + int num; + struct kinfo_proc2 *p; + + p = kvm_getproc2(kd, KERN_PROC_ALL, 0, + sizeof(struct kinfo_proc2), &len); + + for (num = 0; num < len; num++) + updateProcess(p[num].p_pid, &p[num]); cleanupProcessList(); return (0); @@ -306,8 +304,8 @@ updateProcessList(void) void printProcessListInfo(const char* cmd) { - fprintf(CurrentClient, "Name\tPID\tPPID\tUID\tGID\tStatus\tUser%%\tSystem%%\tNice\tVmSize\tVmRss\tLogin\tCommand\n"); - fprintf(CurrentClient, "s\td\td\td\td\tS\tf\tf\td\tD\tD\ts\ts\n"); + fprintf(CurrentClient, "Name\tPID\tPPID\tUID\tGID\tStatus\tCPU%%\tPrio%%\tNice\tVmSize\tVmRss\tLogin\tCommand\n"); + fprintf(CurrentClient, "s\td\td\td\td\tS\tf\td\td\tD\tD\ts\ts\n"); } void @@ -318,10 +316,10 @@ printProcessList(const char* cmd) ps = first_ctnr(ProcessList); /* skip 'kernel' entry */ for (ps = next_ctnr(ProcessList); ps; ps = next_ctnr(ProcessList)) { - fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%.2f\t%d\t%d\t%d\t%s\t%s\n", + fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%d\t%d\t%d\t%d\t%s\t%s\n", ps->name, (long)ps->pid, (long)ps->ppid, (long)ps->uid, (long)ps->gid, ps->status, - ps->userLoad, ps->sysLoad, ps->niceLevel, + ps->userLoad, ps->priority, ps->niceLevel, ps->vmSize / 1024, ps->vmRss / 1024, ps->userName, ps->cmdline); } } diff --git a/ksysguard/ksysguardd/NetBSD/apm.c b/ksysguard/ksysguardd/NetBSD/apm.c index f24887483..5929da8fc 100644 --- a/ksysguard/ksysguardd/NetBSD/apm.c +++ b/ksysguard/ksysguardd/NetBSD/apm.c @@ -20,7 +20,7 @@ #include <fcntl.h> -#include <machine/apmvar.h> +#include <dev/apm/apmio.h> #include <sys/ioctl.h> #include <unistd.h> #include <stdio.h> @@ -97,4 +97,3 @@ printApmBatTimeInfo(const char* c) { fprintf(CurrentClient, "Remaining battery time\t0\t0\tmin\n"); } - diff --git a/ksysguard/ksysguardd/NetBSD/diskstat.c b/ksysguard/ksysguardd/NetBSD/diskstat.c index 818eee1d4..e9c569065 100644 --- a/ksysguard/ksysguardd/NetBSD/diskstat.c +++ b/ksysguard/ksysguardd/NetBSD/diskstat.c @@ -63,7 +63,11 @@ char *getMntPnt(const char *cmd) int numMntPnt(void) { +#ifdef HAVE_STATVFS + struct statvfs *fs_info; +#else struct statfs *fs_info; +#endif int i, n, counter = 0; n = getmntinfo(&fs_info, MNT_WAIT); @@ -129,8 +133,13 @@ void exitDiskStat(void) int updateDiskStat(void) { +#ifdef HAVE_STATVFS + struct statvfs *fs_info; + struct statvfs fs; +#else struct statfs *fs_info; struct statfs fs; +#endif float percent; int i, mntcount; DiskInfo *disk_info; diff --git a/ksysguard/ksysguardd/NetBSD/netdev.c b/ksysguard/ksysguardd/NetBSD/netdev.c index 477acc40e..efa25cc08 100644 --- a/ksysguard/ksysguardd/NetBSD/netdev.c +++ b/ksysguard/ksysguardd/NetBSD/netdev.c @@ -269,12 +269,12 @@ void exitNetDev(void) { NDreg(0); } -void updateNetDev(void) { +int updateNetDev(void) { NetDevInfo *p, *q; int n; if (-1==(n = readSys(0))) - return; + return 0; NetDevCnt = n; /*fixme: assumes the interfaces are in the same order each time */ @@ -289,6 +289,7 @@ void updateNetDev(void) { } } + return 0; } void checkNetDev(void) { diff --git a/ksysguard/ksysguardd/NetBSD/netdev.h b/ksysguard/ksysguardd/NetBSD/netdev.h index 4287c9203..17d9c89e9 100644 --- a/ksysguard/ksysguardd/NetBSD/netdev.h +++ b/ksysguard/ksysguardd/NetBSD/netdev.h @@ -24,7 +24,7 @@ void initNetDev(struct SensorModul* sm); void exitNetDev(void); -void updateNetDev(void); +int updateNetDev(void); void checkNetDev(void); void printNetDevRecBytes(const char* cmd); diff --git a/ksysguard/ksysguardd/modules.h b/ksysguard/ksysguardd/modules.h index 06b290b27..fe66ad537 100644 --- a/ksysguard/ksysguardd/modules.h +++ b/ksysguard/ksysguardd/modules.h @@ -55,6 +55,19 @@ #include "netdev.h" #endif /* OSTYPE_FreeBSD */ +#ifdef OSTYPE_NetBSD +#include "CPU.h" +#include "Memory.h" +#include "ProcessList.h" +#ifdef HAVE_APMIO +#include "apm.h" +#endif +#include "diskstat.h" +#include "loadavg.h" +#include "logfile.h" +#include "netdev.h" +#endif /* OSTYPE_NetBSD */ + #ifdef OSTYPE_Solaris #include "LoadAvg.h" #include "Memory.h" @@ -120,6 +133,19 @@ struct SensorModul SensorModulList[] = { { "NetDev", initNetDev, exitNetDev, updateNetDev, checkNetDev, 0, NULLTIME }, #endif /* OSTYPE_FreeBSD */ +#ifdef OSTYPE_NetBSD + { "CpuInfo", initCpuInfo, exitCpuInfo, updateCpuInfo, NULLVVFUNC, 0, NULLTIME }, + { "Memory", initMemory, exitMemory, updateMemory, NULLVVFUNC, 0, NULLTIME }, + { "ProcessList", initProcessList, exitProcessList, updateProcessList, NULLVVFUNC, 0, NULLTIME }, +#ifdef HAVE_APMIO + { "Apm", initApm, exitApm, updateApm, NULLVVFUNC, 0, NULLTIME }, +#endif + { "DiskStat", initDiskStat, exitDiskStat, updateDiskStat, checkDiskStat, 0, NULLTIME }, + { "LoadAvg", initLoadAvg, exitLoadAvg, updateLoadAvg, NULLVVFUNC, 0, NULLTIME }, + { "LogFile", initLogFile, exitLogFile, NULLIVFUNC, NULLVVFUNC, 0, NULLTIME }, + { "NetDev", initNetDev, exitNetDev, updateNetDev, checkNetDev, 0, NULLTIME }, +#endif /* OSTYPE_NetBSD */ + #ifdef OSTYPE_Solaris { "LoadAvg", initLoadAvg, exitLoadAvg, updateLoadAvg, NULLVVFUNC, 0, NULLTIME }, { "Memory", initMemory, exitMemory, updateMemory, NULLVVFUNC, 0, NULLTIME }, |