partial support for ksysguard: at least let ksysguardd compile and display

some useful information.
This commit is contained in:
espie 2003-01-09 02:47:40 +00:00
parent cb0d5ce0ab
commit 8a6c685fef
7 changed files with 186 additions and 2 deletions

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-configure_in,v 1.6 2003/01/09 02:47:40 espie Exp $
--- configure.in.orig Wed Jan 8 20:39:13 2003
+++ configure.in Wed Jan 8 22:57:28 2003
@@ -1339,6 +1339,7 @@ AC_MSG_CHECKING(if ksysguardd can be com
case "$host" in
*-*-linux*) ksysguardd_compile=yes; UNAME='Linux' ;;
*-*-freebsd*) ksysguardd_compile=yes; UNAME='FreeBSD' ;;
+ *-*-openbsd*) ksysguardd_compile=yes; UNAME='FreeBSD' ;;
*-*-solaris*) ksysguardd_compile=yes; UNAME='Solaris' ;;
*-*-osf*) ksysguardd_compile=yes; UNAME='Tru64' ;;
*) ksysguardd_compile=no; UNAME='' ;;

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-ksysguard_ksysguardd_FreeBSD_CPU_c,v 1.1 2003/01/09 02:47:40 espie Exp $
--- ksysguard/ksysguardd/FreeBSD/CPU.c.orig Thu Jan 3 21:30:02 2002
+++ ksysguard/ksysguardd/FreeBSD/CPU.c Thu Jan 9 01:23:42 2003
@@ -19,7 +19,9 @@
*/
#include <sys/dkstat.h>
+#ifndef __OpenBSD__
#include <devstat.h>
+#endif
#include <fcntl.h>
#include <kvm.h>
#include <nlist.h>

View File

@ -0,0 +1,92 @@
$OpenBSD: patch-ksysguard_ksysguardd_FreeBSD_Memory_c,v 1.1 2003/01/09 02:47:40 espie Exp $
--- ksysguard/ksysguardd/FreeBSD/Memory.c.orig Fri Sep 14 23:11:20 2001
+++ ksysguard/ksysguardd/FreeBSD/Memory.c Thu Jan 9 01:23:54 2003
@@ -32,7 +32,11 @@
#include <sys/types.h>
#include <sys/vmmeter.h>
#include <unistd.h>
+#ifdef __OpenBSD__
+#include <sys/swap.h>
+#else
#include <vm/vm_param.h>
+#endif
#include "Command.h"
#include "Memory.h"
@@ -82,15 +86,42 @@ updateMemory(void)
struct vmtotal p;
FILE *file;
char buf[256];
+#ifdef __FreeBSD__
struct kvm_swap kswap[16];
+#endif
int i, swap_count, hlen, pagesize = getpagesize();
long blocksize;
len = sizeof (Total);
+#ifdef __OpenBSD__
+ mib[0] = CTL_HW;
+ mib[1] = HW_PHYSMEM;
+ sysctl(mib, 2, &Total, &len, NULL, 0);
+#else
sysctlbyname("hw.physmem", &Total, &len, NULL, 0);
+#endif
Total /= 1024;
/* Borrowed from pstat */
+
+#ifdef __OpenBSD__
+ swap_count = swapctl(SWAP_NSWAP, 0, 0);
+ if (swap_count > 0) {
+ struct swapent *swdev;
+ swdev = malloc(swap_count * sizeof(*swdev));
+ if (swdev == NULL)
+ return 0;
+ (void)swapctl(SWAP_STATS, swdev, swap_count);
+ STotal = SUsed = 0;
+ for (i = 0; i < swap_count; i++) {
+ if (!(swdev[i].se_flags & SWF_ENABLE))
+ continue;
+ STotal += swdev[i].se_nblks;
+ SUsed += swdev[i].se_inuse;
+ }
+ SFree = STotal - SUsed;
+ }
+#else
swap_count = kvm_getswapinfo(kd, kswap, 16, SWIF_DEV_PREFIX);
getbsize(&hlen, &blocksize);
@@ -101,22 +132,33 @@ updateMemory(void)
SUsed = CONVERT(kswap[0].ksw_used);
SFree = CONVERT(kswap[0].ksw_total - kswap[0].ksw_used);
}
+#endif
len = sizeof (Buffers);
+#ifndef __OpenBSD__
if ((sysctlbyname("vfs.bufspace", &Buffers, &len, NULL, 0) == -1) || !len)
+#endif
Buffers = 0; /* Doesn't work under FreeBSD v2.2.x */
Buffers /= 1024;
len = sizeof (Cached);
+#ifndef __OpenBSD__
if ((sysctlbyname("vm.stats.vm.v_cache_count", &Cached, &len, NULL, 0) == -1) || !len)
+#endif
Cached = 0; /* Doesn't work under FreeBSD v2.2.x */
Cached *= getpagesize() / 1024;
/* initializes the pointer to the vmmeter struct */
len = sizeof (p);
+#ifdef __OpenBSD__
+ mib[0] = CTL_VM;
+ mib[1] = VM_METER;
+ sysctl(mib, 2, &p, &len, NULL, 0);
+#else
sysctlbyname("vm.vmmeter", &p, &len, NULL, 0);
+#endif
MFree = p.t_free * getpagesize() / 1024;
Used = p.t_arm * getpagesize() / 1024 + Buffers + Cached;

View File

@ -0,0 +1,46 @@
$OpenBSD: patch-ksysguard_ksysguardd_FreeBSD_apm_c,v 1.1 2003/01/09 02:47:40 espie Exp $
--- ksysguard/ksysguardd/FreeBSD/apm.c.orig Thu Jan 9 01:24:30 2003
+++ ksysguard/ksysguardd/FreeBSD/apm.c Thu Jan 9 01:27:04 2003
@@ -20,7 +20,11 @@
*/
#include <fcntl.h>
+#ifdef __OpenBSD__
+#include <machine/apmvar.h>
+#else
#include <machine/apm_bios.h>
+#endif
#include <stdio.h>
#include "Command.h"
@@ -59,6 +63,22 @@ exitApm(void)
close(ApmFD);
}
+#ifdef __OpenBSD__
+
+int
+updateApm(void)
+{
+ struct apm_power_info info;
+ int retval;
+
+ retval = ioctl(ApmFD, APM_IOC_GETPOWER, &info);
+
+ BattFill = info.battery_life;
+ BattTime = info.minutes_left;
+
+ return retval;
+}
+#else
int
updateApm(void)
{
@@ -72,6 +92,7 @@ updateApm(void)
return retval;
}
+#endif
void
printApmBatFill(const char* c)

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-ksysguard_ksysguardd_FreeBSD_netdev_c,v 1.1 2003/01/09 02:47:40 espie Exp $
--- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Thu Jan 9 01:27:29 2003
+++ ksysguard/ksysguardd/FreeBSD/netdev.c Thu Jan 9 01:29:21 2003
@@ -19,6 +19,7 @@
$Id: patch-ksysguard_ksysguardd_FreeBSD_netdev_c,v 1.1 2003/01/09 02:47:40 espie Exp $
*/
+#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
@@ -317,3 +318,9 @@ void printNetDevSentBytesInfo(const char
if (!strncmp(retval[1], "collisions", 10))
fprintf(CurrentClient, "Transmitter Collisions\t0\t0\t1/s\n");
}
+#else
+void initNetDev(void) {}
+void exitNetDev(void) {}
+void updateNetDev(void) {}
+void checkNetDev(void) {}
+#endif

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PFRAG.shared,v 1.8 2002/07/16 12:20:42 espie Exp $
@comment $OpenBSD: PFRAG.shared,v 1.9 2003/01/09 02:47:40 espie Exp $
${KDE}/libchildpanel_panelextension.so.1.0
${KDE}/libclock_panelapplet.so.1.0
${KDE}/libdockbar_panelextension.so.1.0

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.14 2003/01/05 20:52:23 espie Exp $
@comment $OpenBSD: PLIST,v 1.15 2003/01/09 02:47:40 espie Exp $
bin/appletproxy
bin/chooser
bin/conttest
@ -58,6 +58,7 @@ bin/ksmserver
bin/ksplash
bin/kstart
bin/ksysguard
bin/ksysguardd
bin/ksystraycmd
bin/ktip
bin/kwebdesktop