pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils/free Import free-1.0: Displays memory usage
details: https://anonhg.NetBSD.org/pkgsrc/rev/18a735cb24e2
branches: trunk
changeset: 460375:18a735cb24e2
user: hubertf <hubertf%pkgsrc.org@localhost>
date: Fri Aug 29 18:51:05 2003 +0000
description:
Import free-1.0: Displays memory usage
Many users with a linux-background expect the command free, here it is,
based on NetBSD's vmstat.
>From bsdforums.org (http://www.bsdforums.org/forums/showthread.php?s=&threadid=13410),
with permission by the author Karsten Kruse <tecneeq%tecneeq.de@localhost>
diffstat:
sysutils/free/DESCR | 2 +
sysutils/free/Makefile | 24 +++++++++++++++++++++++
sysutils/free/PLIST | 2 +
sysutils/free/files/free | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 77 insertions(+), 0 deletions(-)
diffs (93 lines):
diff -r 972f6013f01b -r 18a735cb24e2 sysutils/free/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/free/DESCR Fri Aug 29 18:51:05 2003 +0000
@@ -0,0 +1,2 @@
+Many users with a linux-background expect the command free, here it is,
+based on NetBSD's vmstat.
diff -r 972f6013f01b -r 18a735cb24e2 sysutils/free/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/free/Makefile Fri Aug 29 18:51:05 2003 +0000
@@ -0,0 +1,24 @@
+# $NetBSD: Makefile,v 1.1.1.1 2003/08/29 18:51:05 hubertf Exp $
+#
+
+DISTNAME= free-1.0
+WRKSRC= ${WRKDIR}
+CATEGORIES= sysutils
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= hubertf%NetBSD.org@localhost
+COMMENT= Displays memory usage
+
+USE_PKGINSTALL= YES
+
+# This pkg doesn't regard USE_INET6 (leave this comment for README-IPv6.html!)
+EXTRACT_ONLY= # empty
+NO_CHECKSUM= yes
+NO_CONFIGURE= yes
+NO_BUILD= yes
+
+do-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/free ${PREFIX}/bin/free
+
+.include "../../mk/bsd.pkg.mk"
diff -r 972f6013f01b -r 18a735cb24e2 sysutils/free/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/free/PLIST Fri Aug 29 18:51:05 2003 +0000
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2003/08/29 18:51:05 hubertf Exp $
+bin/free
diff -r 972f6013f01b -r 18a735cb24e2 sysutils/free/files/free
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/free/files/free Fri Aug 29 18:51:05 2003 +0000
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# by Karsten Kruse <tecneeq%tecneeq.de@localhost>
+#
+
+if [ ! _NetBSD = _`uname -s` ] ; then
+ echo "Kid, get yerself a System: www.netbsd.org"
+ exit 1
+fi
+
+show_kb(){
+vmstat -s | awk '
+/ bytes per page$/ { bpp = $1 }
+/ pages managed$/ { totalmem = $1 }
+/ pages free$/ { free = $1 }
+/ cached file pages$/ { fcache = $1 }
+/ cached executable pages$/ { ecache = $1 }
+/ swap pages$/ { totalswap = $1 }
+/ swap pages in use$/ { swapused = $1 }
+END {
+ printf(" %10s %10s %10s %10s\n","total","used","free","buffers");
+ printf("Mem: %10d %10d %10d %10d\n",totalmem * bpp / 1024,(totalmem - free) * bpp / 1024,free * bpp / 1024,(fcache + ecache) * bpp / 1024);
+ printf("Swap: %10d %10d %10d\n",totalswap * bpp / 1024,swapused * bpp / 1024,(totalswap - swapused) * bpp / 1024);
+}'
+}
+
+show_mb(){
+vmstat -s | awk '
+/ bytes per page$/ { bpp = $1 }
+/ pages managed$/ { totalmem = $1 }
+/ pages free$/ { free = $1 }
+/ cached file pages$/ { fcache = $1 }
+/ cached executable pages$/ { ecache = $1 }
+/ swap pages$/ { totalswap = $1 }
+/ swap pages in use$/ { swapused = $1 }
+END {
+ printf(" %10s %10s %10s %10s\n","total","used","free","buffers");
+ printf("Mem: %10d %10d %10d %10d\n",totalmem * bpp / 1024 / 1024,(totalmem - free) * bpp / 1024 / 1024,free * bpp / 1024 / 1024,(fcache + ecache) * bpp / 1024 / 1024);
+ printf("Swap: %10d %10d %10d\n",totalswap * bpp / 1024 / 1024,swapused * bpp / 1024 / 1024,(totalswap - swapused) * bpp / 1024 / 1024);
+}'
+}
+
+case $1 in
+ -k) show_kb ; exit ;;
+ -m) show_mb ; exit ;;
+ -*) echo "Usage: free [-k|-m]" ; exit 1 ;;
+esac
+
+show_kb
Home |
Main Index |
Thread Index |
Old Index