|
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
|
|
#
|
|
|
|
# Filename: package/.../embutils/free.patch
|
|
|
|
# Copyright (C) 2007 The OpenSDE Project
|
|
|
|
# Copyright (C) 2004 - 2006 The T2 SDE Project
|
|
|
|
#
|
|
|
|
# More information can be found in the files COPYING and README.
|
|
|
|
#
|
|
|
|
# This patch file is dual-licensed. It is available under the license the
|
|
|
|
# patched project is licensed under, as long as it is an OpenSource license
|
|
|
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
|
|
|
# of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
|
|
|
|
A memory foodprint overview can be quite handy.
|
|
|
|
|
|
|
|
Rene Rebe <rene@exactcode.de>
|
|
|
|
|
|
|
|
--- ./Makefile.orig 2007-03-28 00:46:09.000000000 -0400
|
|
|
|
+++ ./Makefile 2007-03-28 00:46:49.000000000 -0400
|
|
|
|
@@ -12,7 +12,7 @@
|
|
|
|
domainname id ln mv cp yes which cat rm wc ls whoami mkfifo head install \
|
|
|
|
sosrm soscp sosmv sosln soslns md5sum sleep2 allinone uniq tr mesg du \
|
|
|
|
uuencode uudecode nohup nice cmp mktemp truncate strings test date \
|
|
|
|
-printenv chrootuid renice
|
|
|
|
+printenv chrootuid renice free
|
|
|
|
|
|
|
|
OS:=$(shell uname)
|
|
|
|
ifeq ($(OS),Linux)
|
|
|
|
--- /dev/null 2005-02-03 08:15:19.790903464 +0100
|
|
|
|
+++ embutils-0.17-free/free.c 2005-02-07 01:35:28.941469088 +0100
|
|
|
|
@@ -0,0 +1,90 @@
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <sys/vfs.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+
|
|
|
|
+/* Rene Rebe <rene@exactcode.de>
|
|
|
|
+
|
|
|
|
+/* TODO: maybe support some options ... */
|
|
|
|
+
|
|
|
|
+#include "fmt_str.c"
|
|
|
|
+#include "fmt_ulong.c"
|
|
|
|
+#include "fmt_ulongpadright.c"
|
|
|
|
+
|
|
|
|
+int main(int argc, char* argv[]) {
|
|
|
|
+ int fd=open("/proc/meminfo",O_RDONLY);
|
|
|
|
+ char buf[4096];
|
|
|
|
+ int len=read(fd,buf,4096);
|
|
|
|
+ char *line, *max;
|
|
|
|
+
|
|
|
|
+ struct meminfo_t {
|
|
|
|
+ const char* tag;
|
|
|
|
+ int val;} meminfo [] = {
|
|
|
|
+ "MemTotal", 0,
|
|
|
|
+ "MemFree", 0,
|
|
|
|
+ "Buffers", 0,
|
|
|
|
+ "Cached", 0,
|
|
|
|
+ "SwapTotal", 0,
|
|
|
|
+ "SwapFree", 0,
|
|
|
|
+ 0, 0};
|
|
|
|
+
|
|
|
|
+ line = buf;
|
|
|
|
+ max = buf + len;
|
|
|
|
+ while (line < max)
|
|
|
|
+ {
|
|
|
|
+ struct meminfo_t* i = &meminfo[0];
|
|
|
|
+ char* tmp2 = strchr(line, ' ');
|
|
|
|
+ *(--tmp2) = 0;
|
|
|
|
+
|
|
|
|
+ for (;i->tag; i++) {
|
|
|
|
+ if ( strcmp(line, i->tag) == 0 ) {
|
|
|
|
+ tmp2++; while (*tmp2 == ' ') tmp2++;
|
|
|
|
+ line = tmp2;
|
|
|
|
+ tmp2 = strchr(tmp2, '\n');
|
|
|
|
+ *tmp2 = 0;
|
|
|
|
+ i->val = atol(line);
|
|
|
|
+ line = tmp2 + 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (i->tag == 0)
|
|
|
|
+ line = strchr(tmp2 + 1, '\n') + 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ len = 0;
|
|
|
|
+ len+=fmt_str (buf+len," total used free shared buffers cached\n");
|
|
|
|
+
|
|
|
|
+ len+=fmt_str (buf+len, "Mem: ");
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[1].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,0,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[2].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[3].val,10);
|
|
|
|
+ buf[len]='\n'; ++len;
|
|
|
|
+
|
|
|
|
+ len += fmt_str (buf+len, "-/+ buffers/cache: ");
|
|
|
|
+ {
|
|
|
|
+ int bc = meminfo[2].val + meminfo[3].val;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val - bc,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[2].val + bc,10);
|
|
|
|
+ buf[len]='\n'; ++len;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ len+=fmt_str (buf+len, "Swap: ");
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[4].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[4].val - meminfo[5].val,10);
|
|
|
|
+ buf[len]=' '; ++len;
|
|
|
|
+ len+=fmt_ulongpadright(buf+len,meminfo[5].val,10);
|
|
|
|
+ buf[len] = 0;
|
|
|
|
+ puts(buf);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|