Date: Thu, 6 Feb 2003 00:58:53 +0100 (CET) From: Hendrik Scholz <hendrik@scholz.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Hendrik Scholz <hendrik@scholz.net> Subject: ports/47981: new port: net/wmnetload (a network load monitor dockapp) Message-ID: <200302052358.h15Nwr6O042655@goanna.lan.raisdorf.net>
next in thread | raw e-mail | index | archive | help
>Number: 47981 >Category: ports >Synopsis: new port: net/wmnetload (a network load monitor dockapp) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 05 16:00:21 PST 2003 >Closed-Date: >Last-Modified: >Originator: Hendrik Scholz >Release: FreeBSD 5.0-CURRENT i386 >Organization: NetUSE AG >Environment: System: FreeBSD goanna.lan.raisdorf.net 5.0-CURRENT FreeBSD 5.0-CURRENT #2: Fri Jan 24 01:44:03 CET 2003 hscholz@goanna.lan.raisdorf.net:/source/src/sys/i386/compile/GOANNA i386 >Description: wmnetload is a windowmaker dockapp reassembling the design of wmcpuload and wmmemmon. The files/ directory contains additional FreeBSD support as wmnetload doesn't support FreeBSD itself as of now. >How-To-Repeat: >Fix: --- wmnetload-1.2.shar begins here --- # 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: # # wmnetload # wmnetload/files # wmnetload/files/patch-wmnetload.c # wmnetload/files/patch-ifstat_freebsd.c # wmnetload/files/patch-configure # wmnetload/Makefile # wmnetload/distinfo # wmnetload/pkg-comment # wmnetload/pkg-descr # wmnetload/pkg-plist # echo c - wmnetload mkdir -p wmnetload > /dev/null 2>&1 echo c - wmnetload/files mkdir -p wmnetload/files > /dev/null 2>&1 echo x - wmnetload/files/patch-wmnetload.c sed 's/^X//' >wmnetload/files/patch-wmnetload.c << 'END-of-wmnetload/files/patch-wmnetload.c' Xdiff -urP wmnetload-1.2.orig/src/wmnetload.c wmnetload-1.2/src/wmnetload.c X--- src/wmnetload.c Sun Oct 27 05:55:27 2002 X+++ src/wmnetload.c Thu Feb 6 00:20:21 2003 X@@ -48,6 +48,14 @@ X #include <alloca.h> X #endif X X+#ifdef __FreeBSD__ X+#include <sys/types.h> X+#include <sys/sysctl.h> X+#include <sys/socket.h> X+#include <net/if.h> X+#include <net/if_mib.h> X+#endif X+ X #include "ifstat.h" X #include "utils.h" X #include "pixmaps.h" X@@ -176,6 +184,11 @@ X static unsigned int *timetable; X static ulonglong_t alarmthresh; /* in bits per second; 0 = none */ X X+#ifdef __FreeBSD__ X+int num_iface; X+int cur_iface; X+#endif X+ X int X main(int argc, char **argv) X { X@@ -190,6 +203,10 @@ X ifinfo_t *ifp; X Pixmap pixmap; X X+#ifdef __FreeBSD__ X+ num_iface = -1; /* just for initalization */ X+#endif X+ X progname = strrchr(argv[0], '/'); X if (progname != NULL) X progname++; X@@ -878,6 +895,44 @@ X static int X if_next(int fd, const char *ifname, char *nextifname) X { X+#ifdef __FreeBSD__ X+ int i, len; X+ int name[6]; X+ struct ifmibdata ifmd; X+ X+ if (num_iface == -1) X+ { X+ /* just started so lets determine the correct number of interfaces */ X+ len = sizeof(num_iface); X+ sysctlbyname("net.link.generic.system.ifcount", &num_iface, X+ &len, NULL, 0); X+ /* here we are FreeBSD-style */ X+ cur_iface = 0; /* iface list starts at 1 */ X+ } X+ /* no lets check if num_iface is postive and quit if not */ X+ if (num_iface < 1) X+ return 0; X+ X+ if (cur_iface < num_iface) X+ cur_iface++; X+ else X+ cur_iface=1; X+ X+ /* set nextifname */ X+ name[0] = CTL_NET; X+ name[1] = PF_LINK; X+ name[2] = NETLINK_GENERIC; X+ name[3] = IFMIB_IFDATA; X+ name[4] = cur_iface; X+ name[5] = IFDATA_GENERAL; X+ X+ len = sizeof(ifmd); X+ sysctl(name, 6, &ifmd, &len, NULL, 0); X+ strncpy(nextifname, ifmd.ifmd_name, IFNAMSIZ); X+ /* we are done here */ X+ return 1; X+ X+#else X struct ifconf ifc; X struct ifreq *ifrp, *matchifrp = NULL, *loifrp; X void *startp, *endp; X@@ -975,6 +1030,7 @@ X return (1); X } X return (0); X+#endif X } X X /* END-of-wmnetload/files/patch-wmnetload.c echo x - wmnetload/files/patch-ifstat_freebsd.c sed 's/^X//' >wmnetload/files/patch-ifstat_freebsd.c << 'END-of-wmnetload/files/patch-ifstat_freebsd.c' Xdiff -urP wmnetload-1.2.orig/src/ifstat_freebsd.c wmnetload-1.2/src/ifstat_freebsd.c X--- src/ifstat_freebsd.c Thu Jan 1 01:00:00 1970 X+++ src/ifstat_freebsd.c Thu Feb 6 00:25:31 2003 X@@ -0,0 +1,102 @@ X+/****************************************************************************** X+ * X+ * ifstat_freebsd.c X+ * X+ * FreeBSD version of the three functions needed. X+ * X+ * (c) 2003 by Hendrik Scholz <hendrik@scholz.net> http://www.raisdorf.net/ X+ * X+ *****************************************************************************/ X+ X+#include <config.h> X+#include <stdlib.h> X+#include <stdio.h> X+#include <string.h> X+#include <sys/types.h> X+#include <sys/sysctl.h> X+#include <sys/socket.h> X+#include <net/if.h> X+#include <net/if_mib.h> X+ X+#include "ifstat.h" X+#include "utils.h" X+ X+struct ifstatstate X+{ X+ int num; /* we just need something in here */ X+}; X+ X+/****************************************************************************** X+ * X+ * if_statinit() X+ * X+ * we cannot speed up anything here, so we just determine the number of X+ * interfaces X+ * X+ *****************************************************************************/ X+ X+ifstatstate_t * if_statinit(void) X+{ X+ ifstatstate_t *statep; X+ X+ int num_iface, len; X+ int name[6]; X+ struct ifmibdata ifmd; X+ X+ statep = malloc(sizeof (ifstatstate_t)); X+ if (statep == NULL) X+ { X+ warn("cannot allocate interface statistics state"); X+ return (NULL); X+ } X+ len = sizeof(num_iface); X+ sysctlbyname("net.link.generic.system.ifcount", &num_iface, &len, NULL, 0); X+ statep->num = num_iface; X+ X+ return statep; X+} X+ X+/****************************************************************************** X+ * X+ * if_stats() X+ * X+ * sysctl() just rocks X+ * X+ *****************************************************************************/ X+ X+int if_stats(const char *ifname, ifstatstate_t *statep, ifstats_t *ifstatsp) X+{ X+ int name[6]; X+ int i, len; X+ struct ifmibdata ifmd; X+ X+ for (i=1; i <= statep->num; i++) X+ { X+ name[0] = CTL_NET; X+ name[1] = PF_LINK; X+ name[2] = NETLINK_GENERIC; X+ name[3] = IFMIB_IFDATA; X+ name[4] = i; X+ name[5] = IFDATA_GENERAL; X+ X+ len = sizeof(ifmd); X+ sysctl(name, 6, &ifmd, &len, NULL, 0); X+ if (strcmp(ifmd.ifmd_name, ifname) == 0) X+ { X+ /* got the right interface */ X+ ifstatsp->rxbytes = ifmd.ifmd_data.ifi_ibytes; X+ ifstatsp->txbytes = ifmd.ifmd_data.ifi_obytes; X+ } X+ } X+} X+/****************************************************************************** X+ * X+ * if_statfini() X+ * X+ * nothing here :) X+ * X+ *****************************************************************************/ X+void if_statfini(ifstatstate_t *statep) X+{ X+ /* we don't need no education, we don't need no thought control */ X+} END-of-wmnetload/files/patch-ifstat_freebsd.c echo x - wmnetload/files/patch-configure sed 's/^X//' >wmnetload/files/patch-configure << 'END-of-wmnetload/files/patch-configure' X--- configure.orig Thu Feb 6 00:40:20 2003 X+++ configure Thu Feb 6 00:40:51 2003 X@@ -3048,6 +3048,10 @@ X LIBRARY_RPATH="$LIBRARY_RPATH:/usr/X11R6/lib" X LIBS="$LIBS -lkvm" X ;; X+*freebsd*) X+ OS=freebsd X+ LIBRARY_RPATH="$LIBRARY_RPATH:/usr/X11R6/lib" X+ ;; X *) X echo "" X echo "Sorry, $host_os is not supported yet." END-of-wmnetload/files/patch-configure echo x - wmnetload/Makefile sed 's/^X//' >wmnetload/Makefile << 'END-of-wmnetload/Makefile' X# New ports collection makefile for: wmnetload X# Date created: 6 February 2003 X# Whom: Hendrik Scholz <hendrik@scholz.net> X# X# $FreeBSD$ X# X XPORTNAME= wmnetload XPORTVERSION= 1.2 XCATEGORIES= windowmaker afterstep net XMASTER_SITES= ftp://truffula.com/pub/ X XMAINTAINER= hendrik@scholz.net X XBUILD_DEPENDS= ${X11BASE}/include/dockapp.h:${PORTSDIR}/x11-wm/libdockapp X XUSE_BZIP2= yes XGNU_CONFIGURE= yes X Xpost-install: X.if !defined(NOPORTDOCS) X @${MKDIR} ${PREFIX}/share/doc/wmnetload X @${INSTALL_DATA} ${WRKSRC}/README ${PREFIX}/share/doc/wmnetload/ X.endif X X.include <bsd.port.mk> END-of-wmnetload/Makefile echo x - wmnetload/distinfo sed 's/^X//' >wmnetload/distinfo << 'END-of-wmnetload/distinfo' XMD5 (wmnetload-1.2.tar.bz2) = e2c2774da0348aed7bd86439f988013c END-of-wmnetload/distinfo echo x - wmnetload/pkg-comment sed 's/^X//' >wmnetload/pkg-comment << 'END-of-wmnetload/pkg-comment' XNetwork load monitor dockapp END-of-wmnetload/pkg-comment echo x - wmnetload/pkg-descr sed 's/^X//' >wmnetload/pkg-descr << 'END-of-wmnetload/pkg-descr' Xwmnetload is a network interface monitor dockapp. It is designed to Xfit well with dockapps like wmcpuload and wmmemmon. X XWWW: http://freshmeat.net/projects/wmnetload X X-- Hendrik Scholz <hendrik@scholz.net> END-of-wmnetload/pkg-descr echo x - wmnetload/pkg-plist sed 's/^X//' >wmnetload/pkg-plist << 'END-of-wmnetload/pkg-plist' Xbin/wmnetload X%%PORTDOCS%%share/doc/wmnetload/README X%%PORTDOCS%%@dirrm share/doc/wmnetload END-of-wmnetload/pkg-plist exit --- wmnetload-1.2.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302052358.h15Nwr6O042655>