ports/55133: New port: sysutils/xfce4-systemload-plugin
Thorsten Greiner
thorsten.greiner at web.de
Thu Jul 31 21:10:20 UTC 2003
>Number: 55133
>Category: ports
>Synopsis: New port: sysutils/xfce4-systemload-plugin
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Jul 31 14:10:17 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Thorsten Greiner
>Release: FreeBSD 5.1-CURRENT i386
>Organization:
n/a
>Environment:
System: FreeBSD tybalt 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Wed Jul 30 21:02:42 CEST 2003 root at tybalt:/usr/src/sys/i386/compile/TYBALT i386
>Description:
System Load plugin for XFce4
>How-To-Repeat:
n/a
>Fix:
Unpack the shar archive
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# xfce4-systemload-plugin
# xfce4-systemload-plugin/Makefile
# xfce4-systemload-plugin/files
# xfce4-systemload-plugin/files/patch-memswap.c
# xfce4-systemload-plugin/distinfo
# xfce4-systemload-plugin/pkg-plist
# xfce4-systemload-plugin/pkg-descr
#
echo c - xfce4-systemload-plugin
mkdir -p xfce4-systemload-plugin > /dev/null 2>&1
echo x - xfce4-systemload-plugin/Makefile
sed 's/^X//' >xfce4-systemload-plugin/Makefile << 'END-of-xfce4-systemload-plugin/Makefile'
X# New ports collection makefile for: xfce-systemload-plugin
X# Date created: 31 June 2003
X# Whom: Thorsten Greiner <thorsten.greiner at web.de>
X#
X# $FreeBSD$
X#
X
XPORTNAME= xfce4-systemload-plugin
XPORTVERSION= 0.3.2
XCATEGORIES= sysutils
XMASTER_SITES= http://download.berlios.de/xfce-goodies/
XDISTNAME= xfce4-systemload-plugin-${PORTVERSION}
XDIST_SUBDIR= xfce4
X
XMAINTAINER= ports at FreeBSD.org
XCOMMENT= System Load plugin for XFce4
X
XBUILD_DEPENDS= xfce4-panel:${PORTSDIR}/x11-wm/xfce4-panel
XLIB_DEPENDS= xfce4util:${PORTSDIR}/x11/libxfce4util
X
XUSE_GNOME= gtk20
XUSE_X_PREFIX= yes
XGNU_CONFIGURE= yes
XCONFIGURE_TARGET= --build=${ARCH}-portbld-freebsd${OSREL}
X
X.include <bsd.port.mk>
END-of-xfce4-systemload-plugin/Makefile
echo c - xfce4-systemload-plugin/files
mkdir -p xfce4-systemload-plugin/files > /dev/null 2>&1
echo x - xfce4-systemload-plugin/files/patch-memswap.c
sed 's/^X//' >xfce4-systemload-plugin/files/patch-memswap.c << 'END-of-xfce4-systemload-plugin/files/patch-memswap.c'
X--- panel-plugin/memswap.c.orig Tue Jul 29 21:40:55 2003
X+++ panel-plugin/memswap.c Thu Jul 31 22:43:10 2003
X@@ -193,4 +193,113 @@
X
X return 0;
X }
X-#endif
X\ No newline at end of file
X+#endif
X+
X+#if defined(__FreeBSD__)
X+/*
X+ * This is inspired by /usr/src/usr.bin/top/machine.c
X+ *
X+ * Adapted by Thorsten Greiner <thorsten.greiner at web.de>
X+ *
X+ * Original authors: Christos Zoulas <christos at ee.cornell.edu>
X+ * Steven Wallace <swallace at freebsd.org>
X+ * Wolfram Schneider <wosch at FreeBSD.org>
X+ * Thomas Moestl <tmoestl at gmx.net>
X+ */
X+
X+#include <sys/types.h>
X+#include <fcntl.h>
X+#include <kvm.h>
X+
X+#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
X+
X+static int getsysctl (char *name, void *ptr, size_t len)
X+{
X+ size_t nlen = len;
X+ if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
X+ return -1;
X+ }
X+ if (nlen != len) {
X+ return -1;
X+ }
X+ return 0;
X+}
X+
X+static kvm_t *kd = NULL;
X+
X+static int swapmode(int *retavail, int *retfree)
X+{
X+ int n;
X+ int pagesize = getpagesize();
X+ struct kvm_swap swapary[1];
X+ static int kd_init = TRUE;
X+
X+ if(kd_init) {
X+ kd_init = FALSE;
X+ if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
X+ O_RDONLY, "kvm_open")) == NULL) {
X+ g_warning("Cannot read kvm.");
X+ return -1;
X+ }
X+ }
X+ if(kd == NULL) {
X+ return -1;
X+ }
X+
X+ *retavail = 0;
X+ *retfree = 0;
X+
X+#define CONVERT(v) ((quad_t)(v) * pagesize / 1024)
X+
X+ n = kvm_getswapinfo(kd, swapary, 1, 0);
X+ if (n < 0 || swapary[0].ksw_total == 0)
X+ return(0);
X+
X+ *retavail = CONVERT(swapary[0].ksw_total);
X+ *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
X+
X+ n = (int)((double)swapary[0].ksw_used * 100.0 /
X+ (double)swapary[0].ksw_total);
X+ return(n);
X+}
X+
X+gint read_memswap(gulong *mem, gulong *swap, gulong *MT, gulong *MU, gulong *ST, gulong *SU)
X+{
X+ int total_pages;
X+ int free_pages;
X+ int inactive_pages;
X+ int pagesize = getpagesize();
X+ int swap_avail;
X+ int swap_free;
X+
X+ if(GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
X+ g_warning("Cannot read sysctl \"vm.stats.vm.v_page_count\"");
X+ return -1;
X+ }
X+ if(GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
X+ g_warning("Cannot read sysctl \"vm.stats.vm.v_free_count\"");
X+ return -1;
X+ }
X+ if(GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
X+ g_warning("Cannot read sysctl \"vm.stats.vm.v_inactive_count\"");
X+ return -1;
X+ }
X+
X+ *MT = (total_pages*pagesize) >> 10;
X+ *MU = ((total_pages-free_pages-inactive_pages) * pagesize) >> 10;
X+ *mem = *MU * 100 / *MT;
X+
X+ if((*swap = swapmode(&swap_avail, &swap_free)) >= 0) {
X+ *ST = swap_avail;
X+ *SU = (swap_avail - swap_free);
X+ }
X+ else {
X+ *swap = 0;
X+ *ST = 0;
X+ *SU = 0;
X+ }
X+
X+ return 0;
X+}
X+
X+#endif /* defined(__FREEBSD) */
END-of-xfce4-systemload-plugin/files/patch-memswap.c
echo x - xfce4-systemload-plugin/distinfo
sed 's/^X//' >xfce4-systemload-plugin/distinfo << 'END-of-xfce4-systemload-plugin/distinfo'
XMD5 (xfce4/xfce4-systemload-plugin-0.3.2.tar.gz) = 54f940ea77261bb61ca54dd77253c222
END-of-xfce4-systemload-plugin/distinfo
echo x - xfce4-systemload-plugin/pkg-plist
sed 's/^X//' >xfce4-systemload-plugin/pkg-plist << 'END-of-xfce4-systemload-plugin/pkg-plist'
Xlib/xfce4/panel-plugins/libsystemload.a
Xlib/xfce4/panel-plugins/libsystemload.la
Xlib/xfce4/panel-plugins/libsystemload.so
X at unexec rmdir %D/lib/xfce4/panel-plugins 2>/dev/null || true
X at unexec rmdir %D/lib/xfce4 2>/dev/null || true
END-of-xfce4-systemload-plugin/pkg-plist
echo x - xfce4-systemload-plugin/pkg-descr
sed 's/^X//' >xfce4-systemload-plugin/pkg-descr << 'END-of-xfce4-systemload-plugin/pkg-descr'
XSystem Load plugin for XFce4.
X
XWWW: http://www.xfce.org
END-of-xfce4-systemload-plugin/pkg-descr
exit
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list