summaryrefslogtreecommitdiff
path: root/sysutils/free
diff options
context:
space:
mode:
authorhubertf <hubertf@pkgsrc.org>2003-08-29 18:51:05 +0000
committerhubertf <hubertf@pkgsrc.org>2003-08-29 18:51:05 +0000
commitfadd7bfe95883444b9e6a7e73a7bef92a0f42ee4 (patch)
tree91c2ba30a0973b1ab508d0a224271e0bff38b861 /sysutils/free
parentf5640c7ae89c9427858639f4c72ac9914a3a9f8d (diff)
downloadpkgsrc-fadd7bfe95883444b9e6a7e73a7bef92a0f42ee4.tar.gz
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>
Diffstat (limited to 'sysutils/free')
-rw-r--r--sysutils/free/DESCR2
-rw-r--r--sysutils/free/Makefile24
-rw-r--r--sysutils/free/PLIST2
-rwxr-xr-xsysutils/free/files/free49
4 files changed, 77 insertions, 0 deletions
diff --git a/sysutils/free/DESCR b/sysutils/free/DESCR
new file mode 100644
index 00000000000..c498a89fa08
--- /dev/null
+++ b/sysutils/free/DESCR
@@ -0,0 +1,2 @@
+Many users with a linux-background expect the command free, here it is,
+based on NetBSD's vmstat.
diff --git a/sysutils/free/Makefile b/sysutils/free/Makefile
new file mode 100644
index 00000000000..c6d06729fa7
--- /dev/null
+++ b/sysutils/free/Makefile
@@ -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
+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 --git a/sysutils/free/PLIST b/sysutils/free/PLIST
new file mode 100644
index 00000000000..a53dbaf3795
--- /dev/null
+++ b/sysutils/free/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2003/08/29 18:51:05 hubertf Exp $
+bin/free
diff --git a/sysutils/free/files/free b/sysutils/free/files/free
new file mode 100755
index 00000000000..c3d8325a4d1
--- /dev/null
+++ b/sysutils/free/files/free
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# by Karsten Kruse <tecneeq@tecneeq.de>
+#
+
+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