ports/72013: New port: net/pload: display network i/f stats in an X11 window
J.R. Oldroyd
jr at opal.com
Wed Sep 22 21:00:44 UTC 2004
>Number: 72013
>Category: ports
>Synopsis: New port: net/pload: display network i/f stats in an X11 window
>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: Wed Sep 22 21:00:43 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator: J.R. Oldroyd
>Release: FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD linwhf.opal.com 6.0-CURRENT FreeBSD 6.0-CURRENT #61: Tue Sep 21 12:57:00 EDT 2004 jr at linwhf.opal.com:/usr/src-current/sys/i386/compile/LINWHF i386
>Description:
Pload is an X11 program to monitor network device statistics. It
graphs information using Athena stripchart widgets.
Original author: Matt Smith <mdsmith at engr.utk.edu>
WWW: http://www.engr.utk.edu/~mdsmith/pload/
>How-To-Repeat:
>Fix:
# 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:
#
# pload
# pload/files
# pload/files/patch-ioctl_stats.c
# pload/files/patch-pload.c
# pload/files/patch-pload.man
# pload/files/patch-Imakefile
# pload/pkg-descr
# pload/Makefile
# pload/pkg-plist
# pload/distinfo
#
echo c - pload
mkdir -p pload > /dev/null 2>&1
echo c - pload/files
mkdir -p pload/files > /dev/null 2>&1
echo x - pload/files/patch-ioctl_stats.c
sed 's/^X//' >pload/files/patch-ioctl_stats.c << 'END-of-pload/files/patch-ioctl_stats.c'
Xdiff -c ioctl_stat.c.orig ioctl_stat.c
X*** ioctl_stat.c.orig Tue Feb 1 02:11:24 2000
X--- ioctl_stat.c Wed Sep 22 14:01:06 2004
X***************
X*** 30,35 ****
X--- 30,41 ----
X #include <fcntl.h> /* open */
X #include <sys/ioctl.h> /* ioctl */
X #include <errno.h>
X+ #ifdef __FreeBSD__
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 #ifndef STREAMS /* Linux, FreeBSD, NetBSD, Ultrix */
X # include <sys/socket.h> /* socket */
X***************
X*** 84,101 ****
X #define ifr_name ifr__name
X #endif
X
X! strncpy(req.ifr_name, ifd->device, sizeof(req.ifr_name));
X! if (ioctl(ifd->s, SIOCGPPPSTATS, &req) != 0)
X! {
X! /* shouldn't fail if SIOCGIFFLAGS worked... */
X! ifd->in_bytes = 0UL;
X! ifd->out_bytes = 0UL;
X! return;
X }
X!
X! ifd->in_bytes = (unsigned long)req.stats.p.ppp_ibytes;
X! ifd->out_bytes = (unsigned long)req.stats.p.ppp_obytes;
X!
X return;
X }
X
X--- 90,133 ----
X #define ifr_name ifr__name
X #endif
X
X! #ifdef __FreeBSD__
X! static int if_ix = -1;
X! struct ifmibdata ifmd;
X! size_t ifmd_sz = sizeof(ifmd);
X! int nr_ifs;
X! size_t nr_ifs_sz = sizeof(nr_ifs);
X! int name[6];
X! int i;
X!
X! name[0] = CTL_NET;
X! name[1] = PF_LINK;
X! name[2] = NETLINK_GENERIC;
X! name[3] = IFMIB_IFDATA;
X! name[5] = IFDATA_GENERAL;
X!
X! if (if_ix < 0) {
X! if (sysctlbyname("net.link.generic.system.ifcount", (void *) &nr_ifs, &nr_ifs_sz, (void *) 0, 0) < 0) {
X! return;
X! }
X! for (i = 1; i <= nr_ifs; i++) {
X! name[4] = i; /* row of the ifmib table */
X!
X! if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) < 0) {
X! continue;
X! }
X! if (strncmp(ifmd.ifmd_name, ifr.ifr_name, strlen(ifr.ifr_name)) == 0) {
X! if_ix = i;
X! break;
X! }
X! }
X }
X! name[4] = if_ix;
X! if (sysctl(name, 6, (void *) &ifmd, &ifmd_sz, (void *) 0, 0) >= 0) {
X! ifd->in_bytes = ifmd.ifmd_data.ifi_ibytes;
X! ifd->out_bytes = ifmd.ifmd_data.ifi_obytes;
X! }
X! #endif
X!
X return;
X }
X
END-of-pload/files/patch-ioctl_stats.c
echo x - pload/files/patch-pload.c
sed 's/^X//' >pload/files/patch-pload.c << 'END-of-pload/files/patch-pload.c'
Xdiff -c pload.c.orig pload.c
X*** pload.c.orig Tue Feb 1 02:11:24 2000
X--- pload.c Wed Sep 22 13:13:46 2004
X***************
X*** 596,608 ****
X void do_total(char *b, double total)
X {
X if (total < 1024.0)
X! sprintf(b, "%s%0.0f b", b, total);
X else if (total < (1024.0*1024.0))
X! sprintf(b, "%s%0.2f k", b, total/1024.0);
X else if (total < (1024.0*1024.0*1024.0))
X! sprintf(b, "%s%0.2f M", b, total/1024.0/1024.0);
X else
X! sprintf(b, "%s%0.2f G", b, total/1024.0/1024.0/1024.0);
X
X return;
X }
X--- 596,608 ----
X void do_total(char *b, double total)
X {
X if (total < 1024.0)
X! sprintf(b, "%s%0.0f B", b, total);
X else if (total < (1024.0*1024.0))
X! sprintf(b, "%s%0.2f kB", b, total/1024.0);
X else if (total < (1024.0*1024.0*1024.0))
X! sprintf(b, "%s%0.2f MB", b, total/1024.0/1024.0);
X else
X! sprintf(b, "%s%0.2f GB", b, total/1024.0/1024.0/1024.0);
X
X return;
X }
X***************
X*** 610,622 ****
X void do_rate(char *b, double rate)
X {
X if (rate < 1024.0)
X! sprintf(b, "%s%0.0f b/s",b, rate);
X else if (rate < (1024.0*1024.0))
X! sprintf(b, "%s%0.2f k/s",b, rate/1024.0);
X else if (rate < (1024.0*1024.0*1024.0))
X! sprintf(b, "%s%0.2f M/s",b, rate/1024.0/1024.0);
X else
X! sprintf(b, "%s%0.2f G/s", b, rate/1024.0/1024.0/1024.0);
X return;
X }
X
X--- 610,622 ----
X void do_rate(char *b, double rate)
X {
X if (rate < 1024.0)
X! sprintf(b, "%s%0.0f B/s",b, rate);
X else if (rate < (1024.0*1024.0))
X! sprintf(b, "%s%0.2f kB/s",b, rate/1024.0);
X else if (rate < (1024.0*1024.0*1024.0))
X! sprintf(b, "%s%0.2f MB/s",b, rate/1024.0/1024.0);
X else
X! sprintf(b, "%s%0.2f GB/s", b, rate/1024.0/1024.0/1024.0);
X return;
X }
X
X***************
X*** 643,648 ****
X--- 643,651 ----
X break;
X case 'M':
X do_rate(buff, max);
X+ break;
X+ case 'd':
X+ sprintf(buff, "%s", resources.device);
X break;
X case '%': /* literal % */
X i = strlen(buff);
END-of-pload/files/patch-pload.c
echo x - pload/files/patch-pload.man
sed 's/^X//' >pload/files/patch-pload.man << 'END-of-pload/files/patch-pload.man'
X--- pload.man.orig Tue Feb 1 02:11:24 2000
X+++ pload.man Wed Sep 22 16:44:12 2004
X@@ -18,7 +18,7 @@
X .TH PLOAD 1 "" "January 2000"
X
X .SH NAME
X-pload \- display ppp throughput statistics in an X window
X+pload \- display network interface statistics in an X window
X
X .SH SYNOPSIS
X .ta 6n
X@@ -30,9 +30,9 @@
X [-iformat \fIfmt\fP] [-oformat \fIfmt\fP]
X
X .SH DESCRIPTION
X-The \fBpload\fP program displays information about network interface (ppp) statistics.
X-Additionally, for Linux 2.2 it can display statistics for any interface that
X-reports to /proc/net/dev .
X+The \fBpload\fP program displays network throughput statistics in an X window
X+Athena stripchart graph.
X+On FreeBSD, \fBpload\fP can handle any network interface.
X
X .SH OPTIONS
X .PP
X@@ -144,7 +144,7 @@
X .TP 8
X .B \-iformat \fIfmt\fP
X Use string \fIfmt\fP for the inbound label. The \fIfmt\fP string will be displayed
X-literally with the special tags %t %r and %M expanding to the interface total, current
X+literally with the special tags %d %t %r and %M expanding to the interface name, interface total, current
X rate, and maximum rate respectively. The default is "%t %r in".
X
X .TP 8
END-of-pload/files/patch-pload.man
echo x - pload/files/patch-Imakefile
sed 's/^X//' >pload/files/patch-Imakefile << 'END-of-pload/files/patch-Imakefile'
Xdiff -c Imakefile.orig Imakefile
X*** Imakefile.orig Tue Feb 1 02:11:24 2000
X--- Imakefile Tue Aug 3 10:02:12 2004
X***************
X*** 15,21 ****
X
X ComplexProgramTarget(pload)
X
X! distclean: clean
X $(RM) Makefile osdefs.mk core \
X pload-$(VER).tar.gz \
X pload-$(VER)-1.i386.rpm \
X--- 15,21 ----
X
X ComplexProgramTarget(pload)
X
X! distclean:: clean
X $(RM) Makefile osdefs.mk core \
X pload-$(VER).tar.gz \
X pload-$(VER)-1.i386.rpm \
END-of-pload/files/patch-Imakefile
echo x - pload/pkg-descr
sed 's/^X//' >pload/pkg-descr << 'END-of-pload/pkg-descr'
XPload is an X11 program to monitor network device statistics. It
Xgraphs information using Athena stripchart widgets.
X
XOriginal author: Matt Smith <mdsmith at engr.utk.edu>
X
XWWW: http://www.engr.utk.edu/~mdsmith/pload/
X
X-jr
Xjr at opal.com
END-of-pload/pkg-descr
echo x - pload/Makefile
sed 's/^X//' >pload/Makefile << 'END-of-pload/Makefile'
X# New ports collection makefile for: pload
X# Date created: 22 Septemper 2004
X# Whom: J.R. Oldroyd <jr at opal.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME= pload
XPORTVERSION= 0.9.5
XCATEGORIES= net x11 sysutils
XMASTER_SITES= http://www.engr.utk.edu/~mdsmith/pload/
X
XMAINTAINER= jr at opal.com
XCOMMENT= An X11 program to display network traffic graphs
X
XUSE_X_PREFIX= yes
X
XMAN1= pload.1
XMANCOMPRESSED= yes
X
XUSE_IMAKE= yes
XHAS_CONFIGURE= yes
X
X.include <bsd.port.mk>
END-of-pload/Makefile
echo x - pload/pkg-plist
sed 's/^X//' >pload/pkg-plist << 'END-of-pload/pkg-plist'
Xbin/pload
END-of-pload/pkg-plist
echo x - pload/distinfo
sed 's/^X//' >pload/distinfo << 'END-of-pload/distinfo'
XMD5 (pload-0.9.5.tar.gz) = f109f3984212627f9955d1ac57c7a4f7
XSIZE (pload-0.9.5.tar.gz) = 22423
END-of-pload/distinfo
exit
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list