Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jun 1999 17:09:19 -0400 (EDT)
From:      jack@germanium.xtalwind.net
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/12025: New port of asmem-1.1
Message-ID:  <199906042109.RAA48758@germanium.xtalwind.net>

next in thread | raw e-mail | index | archive | help

>Number:         12025
>Category:       ports
>Synopsis:       New port of asmem-1.1
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun  4 14:10:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
>Environment:


>Description:

	The asmem tool is an AfterStep look-n-feel memory utilization monitor for
	X Windows. asmem shows the levels of utilization of the various kinds of
	memory and swap space.

>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:
#
#	/usr/ports/sysutils/asmem
#	/usr/ports/sysutils/asmem/Makefile
#	/usr/ports/sysutils/asmem/files
#	/usr/ports/sysutils/asmem/files/md5
#	/usr/ports/sysutils/asmem/patches
#	/usr/ports/sysutils/asmem/patches/patch-aa
#	/usr/ports/sysutils/asmem/patches/patch-ab
#	/usr/ports/sysutils/asmem/pkg
#	/usr/ports/sysutils/asmem/pkg/PLIST
#	/usr/ports/sysutils/asmem/pkg/COMMENT
#	/usr/ports/sysutils/asmem/pkg/DESCR
#
echo c - /usr/ports/sysutils/asmem
mkdir -p /usr/ports/sysutils/asmem > /dev/null 2>&1
echo x - /usr/ports/sysutils/asmem/Makefile
sed 's/^X//' >/usr/ports/sysutils/asmem/Makefile << 'END-of-/usr/ports/sysutils/asmem/Makefile'
X# New ports collection makefile for:	asfsm
X# Version required:	asmem-1.1
X# Date created:		4 June 1999
X# Whom:				jack
X#
X
XDISTNAME=		asmem-1.1
XCATEGORIES=		sysutils afterstep
XMASTER_SITES=	http://www.bewoner.dma.be/Albert/software/
X
XMAINTAINER=    jack@germnaium.xtalwind.net
X
XLIB_DEPENDS=    Xpm.4:${PORTSDIR}/graphics/xpm
X
XUSE_X_PREFIX=	yes
X
XMAKEFILE=		Makefile.UNIX
X
XMAN1=			asmem.1
X
Xdo-install:
X	${INSTALL_MAN} ${WRKSRC}/asmem.man ${PREFIX}/man/man1/asmem.1
X	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g kmem -m 2755 ${WRKSRC}/asmem ${PREFIX}/bin
X
X.include <bsd.port.mk>
END-of-/usr/ports/sysutils/asmem/Makefile
echo c - /usr/ports/sysutils/asmem/files
mkdir -p /usr/ports/sysutils/asmem/files > /dev/null 2>&1
echo x - /usr/ports/sysutils/asmem/files/md5
sed 's/^X//' >/usr/ports/sysutils/asmem/files/md5 << 'END-of-/usr/ports/sysutils/asmem/files/md5'
XMD5 (asmem-1.1.tar.gz) = ccb5985d30a16dade91232a131307ec0
END-of-/usr/ports/sysutils/asmem/files/md5
echo c - /usr/ports/sysutils/asmem/patches
mkdir -p /usr/ports/sysutils/asmem/patches > /dev/null 2>&1
echo x - /usr/ports/sysutils/asmem/patches/patch-aa
sed 's/^X//' >/usr/ports/sysutils/asmem/patches/patch-aa << 'END-of-/usr/ports/sysutils/asmem/patches/patch-aa'
X*** Makefile.UNIX.orig	Sat Mar  6 09:13:53 1999
X--- Makefile.UNIX	Fri Jun  4 15:41:11 1999
X***************
X*** 5,11 ****
X  
X  # The location and names of the X11 libraries
X  LDIR = -L/usr/X11R6/lib
X! LIBS = -lXpm -lX11
X  
X  # The include path to the X11 files
X  C_INCLUDE = -I. -I/usr/X11R6/include
X--- 5,11 ----
X  
X  # The location and names of the X11 libraries
X  LDIR = -L/usr/X11R6/lib
X! LIBS = -lXpm -lX11 -lkvm
X  
X  # The include path to the X11 files
X  C_INCLUDE = -I. -I/usr/X11R6/include
X***************
X*** 17,23 ****
X  
X  CFLAGS = $(COPTS) $(COMPILE_FLAGS) $(C_INCLUDE)
X  
X! OBJ = asmem.o asmem_x.o read_mem.o x_color.o safecopy.o
X  
X  all:	asmem
X  	@echo Ready.
X--- 17,23 ----
X  
X  CFLAGS = $(COPTS) $(COMPILE_FLAGS) $(C_INCLUDE)
X  
X! OBJ = asmem.o asmem_x.o kvm_read.o x_color.o safecopy.o
X  
X  all:	asmem
X  	@echo Ready.
X***************
X*** 34,40 ****
X  x_color.o: x_color.c
X  	$(CC) -c $< $(CFLAGS) -o $@
X  
X! read_mem.o: read_mem.h read_mem.c state.h
X  	$(CC) -c $< $(CFLAGS) -o $@
X  
X  asmem_x.o: asmem_x.c asmem_x.h x_color.h safecopy.h state.h\
X--- 34,40 ----
X  x_color.o: x_color.c
X  	$(CC) -c $< $(CFLAGS) -o $@
X  
X! kvm_read.o: read_mem.h kvm_read.c state.h
X  	$(CC) -c $< $(CFLAGS) -o $@
X  
X  asmem_x.o: asmem_x.c asmem_x.h x_color.h safecopy.h state.h\
END-of-/usr/ports/sysutils/asmem/patches/patch-aa
echo x - /usr/ports/sysutils/asmem/patches/patch-ab
sed 's/^X//' >/usr/ports/sysutils/asmem/patches/patch-ab << 'END-of-/usr/ports/sysutils/asmem/patches/patch-ab'
X*** kvm_read.c.orig	Fri Jun  4 15:45:13 1999
X--- kvm_read.c	Fri Jun  4 15:49:13 1999
X***************
X*** 0 ****
X--- 1,194 ----
X+ /*
X+  * This file obtains memory usage via FreeBSD's kvm library.
X+  * It is a modified version of read_mem.c which is
X+  * Copyright (c) 1999  Albert Dorofeev <Albert@mail.dma.be>
X+  * use this in place of that file for FreeBSD systems.
X+  *
X+  * This software is distributed under GPL. For details see LICENSE file.
X+  */
X+ 
X+ 
X+ #include <stdio.h>
X+ #include <stdlib.h>
X+ #include <string.h>
X+ #include <fcntl.h>
X+ #include <unistd.h>
X+ 
X+ #include "state.h"
X+ 
X+ #include <err.h>
X+ #include <kvm.h>
X+ #include <nlist.h>
X+ #include <sys/rlist.h>
X+ #include <sys/conf.h>
X+ #include <sys/vmmeter.h>
X+ #include <sys/types.h>
X+ #include <sys/sysctl.h>
X+ #include <vm/vm_param.h>
X+ 
X+ extern struct asmem_state state;
X+ 
X+ kvm_t	*kd;
X+ 
X+ #define	SVAR(var) __STRING(var)	/* to force expansion */
X+ #define	KGET(idx, var)							\
X+ 	KGET1(idx, &var, sizeof(var), SVAR(var))
X+ #define	KGET1(idx, p, s, msg)						\
X+ 	KGET2(nl[idx].n_value, p, s, msg)
X+ #define	KGET2(addr, p, s, msg)						\
X+ 	if (kvm_read(kd, (u_long)(addr), p, s) != s)			\
X+ 		warnx("cannot read %s: %s", msg, kvm_geterr(kd))
X+ 
X+ struct nlist nl[] = {
X+ #define VM_SWAPLIST 0
X+     { "_swaplist" },/* list of free swap areas */
X+ #define VM_SWDEVT   1
X+ 	{ "_swdevt" },  /* list of swap devices and sizes */
X+ #define VM_NSWAP    2
X+ 	{ "_nswap" },   /* size of largest swap device */
X+ #define VM_NSWDEV   3
X+ 	{ "_nswdev" },  /* number of swap devices */
X+ #define VM_DMMAX    4
X+ 	{ "_dmmax" },   /* maximum size of a swap block */
X+ #define X_CNT		5
X+ 	{ "_cnt" },
X+ #define X_BUFSPACE  6
X+     { "_bufspace" },    /* K in buffer cache */
X+ 	{ "" }
X+ };
X+ 
X+ int close_meminfo()
X+ {
X+ 	kvm_close(kd);
X+ 	return 0;
X+ }
X+ 
X+ int read_meminfo()
X+ {
X+ 
X+ 	int nswap, nswdev, dmmax;
X+ 	int i, avail, nfree, used, bufspace = 0;
X+ 	struct swdevt *sw;
X+ 	struct vmmeter sum;
X+ 	long *perdev;
X+ 	struct rlist head;
X+ 	struct rlisthdr swaplist;
X+ 	struct rlist *swapptr;
X+ 	u_long ptr;
X+ 
X+ 	KGET(VM_NSWAP, nswap);
X+ 	KGET(VM_NSWDEV, nswdev);
X+ 	KGET(VM_DMMAX, dmmax);
X+ 	KGET1(VM_SWAPLIST, &swaplist, sizeof swaplist, "swaplist");
X+ 	if ((sw = (struct swdevt*)malloc(nswdev * sizeof(*sw))) == NULL ||
X+ 	    (perdev = (long *)malloc(nswdev * sizeof(*perdev))) == NULL)
X+ 		errx(1, "malloc");
X+ 	KGET1(VM_SWDEVT, &ptr, sizeof ptr, "swdevt");
X+ 	KGET2(ptr, sw, nswdev * sizeof(*sw), "*swdevt");
X+ 
X+ 	/* Count up swap space. */
X+ 	nfree = 0;
X+ 	memset(perdev, 0, nswdev * sizeof(*perdev));
X+ 	swapptr = swaplist.rlh_list;
X+ 	while (swapptr) {
X+ 		int	top, bottom, next_block;
X+ 
X+ 		KGET2(swapptr, &head, sizeof(struct rlist), "swapptr");
X+ 
X+ 		top = head.rl_end;
X+ 		bottom = head.rl_start;
X+ 
X+ 		nfree += top - bottom + 1;
X+ 
X+ 		/*
X+ 		 * Swap space is split up among the configured disks.
X+ 		 *
X+ 		 * For interleaved swap devices, the first dmmax blocks
X+ 		 * of swap space some from the first disk, the next dmmax
X+ 		 * blocks from the next, and so on up to nswap blocks.
X+ 		 *
X+ 		 * The list of free space joins adjacent free blocks,
X+ 		 * ignoring device boundries.  If we want to keep track
X+ 		 * of this information per device, we'll just have to
X+ 		 * extract it ourselves.
X+ 		 */
X+ 		while (top / dmmax != bottom / dmmax) {
X+ 			next_block = ((bottom + dmmax) / dmmax);
X+ 			perdev[(bottom / dmmax) % nswdev] +=
X+ 				next_block * dmmax - bottom;
X+ 			bottom = next_block * dmmax;
X+ 		}
X+ 		perdev[(bottom / dmmax) % nswdev] +=
X+ 			top - bottom + 1;
X+ 
X+ 		swapptr = head.rl_next;
X+ 	}
X+ 
X+ 	avail = 0;
X+ 	for (i = 0; i < nswdev; i++) {
X+ 		int xsize, xfree;
X+ 
X+ 		/*
X+ 		 * Don't report statistics for partitions which have not
X+ 		 * yet been activated via swapon(8).
X+ 		 */
X+ 		if (!(sw[i].sw_flags & SW_FREED))
X+ 			continue;
X+ 
X+ 		/* The first dmmax is never allocated to avoid trashing of
X+ 		 * disklabels
X+ 		 */
X+ 		xsize = sw[i].sw_nblks - dmmax;
X+ 		xfree = perdev[i];
X+ 		used = xsize - xfree;
X+ 		avail += xsize;
X+ 	}
X+ 
X+ 	/*
X+ 	 * If only one partition has been set up via swapon(8), we don't
X+ 	 * need to bother with totals.
X+ 	 */
X+ 	used = avail - nfree;
X+ 	free(sw);
X+ 	free(perdev);
X+ 
X+ 	state.fresh.swap_total = avail * 512;
X+ 	state.fresh.swap_used = used * 512;
X+ 	state.fresh.swap_free = (avail - used) * 512;
X+ 
X+ 	KGET(X_CNT, sum);
X+ 	KGET(X_BUFSPACE, bufspace);
X+ 
X+ 	state.fresh.total = sum.v_page_size * sum.v_page_count;
X+ 	state.fresh.used = sum.v_page_size * (sum.v_page_count - sum.v_free_count);
X+ 	state.fresh.free = sum.v_page_size * sum.v_free_count;
X+ 	state.fresh.shared = 0;
X+ 	state.fresh.cached = sum.v_page_size * sum.v_cache_count;
X+ 
X+ 	state.fresh.buffers = bufspace;
X+ 	return(0);
X+ 
X+ }
X+ 
X+ int open_meminfo()
X+ {
X+ 
X+ 	if (kd == 0) {
X+ 		kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, 0);
X+ 		if (kd != NULL) {
X+ 			if (kvm_nlist(kd, nl) < 0) {
X+ 				errx(1, "kvm_nlist: %s", kvm_geterr(kd));
X+ 			}
X+ 
X+ 			if (nl[0].n_type == 0) {
X+ 				errx(1, "no namelist");
X+ 			}
X+ 		} else {
X+ 			warnx("kvm not available");
X+ 			return(-1);
X+ 		}
X+ 	}
X+ 	return(0);
X+ }
X+ 
X+ 
END-of-/usr/ports/sysutils/asmem/patches/patch-ab
echo c - /usr/ports/sysutils/asmem/pkg
mkdir -p /usr/ports/sysutils/asmem/pkg > /dev/null 2>&1
echo x - /usr/ports/sysutils/asmem/pkg/PLIST
sed 's/^X//' >/usr/ports/sysutils/asmem/pkg/PLIST << 'END-of-/usr/ports/sysutils/asmem/pkg/PLIST'
Xbin/asmem
END-of-/usr/ports/sysutils/asmem/pkg/PLIST
echo x - /usr/ports/sysutils/asmem/pkg/COMMENT
sed 's/^X//' >/usr/ports/sysutils/asmem/pkg/COMMENT << 'END-of-/usr/ports/sysutils/asmem/pkg/COMMENT'
Xasmem is an AfterStep look-n-feel memory utilization monitor.
END-of-/usr/ports/sysutils/asmem/pkg/COMMENT
echo x - /usr/ports/sysutils/asmem/pkg/DESCR
sed 's/^X//' >/usr/ports/sysutils/asmem/pkg/DESCR << 'END-of-/usr/ports/sysutils/asmem/pkg/DESCR'
XThe asmem tool is an AfterStep look-n-feel memory utilization monitor for X
XWindows. asmem shows the levels of utilization of the various kinds of memory
Xand swap space. Multiple options for customization are available (colors,
Xappearance, other stuff). 
END-of-/usr/ports/sysutils/asmem/pkg/DESCR
exit


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906042109.RAA48758>