summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2005-12-12 13:23:54 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2005-12-12 13:23:54 +0000
commit52fa57a39bf5d46cff7e0a53047bce5892eab85e (patch)
treee6b449fbcdff6f30bcab8777ad056c85415db846
parentaa5ac8fc10d5c04fbdf78145aa5d933685ec796d (diff)
downloadlibgtop-52fa57a39bf5d46cff7e0a53047bce5892eab85e.tar.gz
Added quick example for glibtop_get_proclist() and updated procmap example
* .cvsignore: * Makefile.am: * proclist.c: (main): * procmap.c: (main): Added quick example for glibtop_get_proclist() and updated procmap example to display smap.
-rw-r--r--examples/.cvsignore1
-rw-r--r--examples/ChangeLog10
-rw-r--r--examples/Makefile.am5
-rw-r--r--examples/proclist.c28
-rw-r--r--examples/procmap.c12
5 files changed, 55 insertions, 1 deletions
diff --git a/examples/.cvsignore b/examples/.cvsignore
index 236bbd67..48a0598b 100644
--- a/examples/.cvsignore
+++ b/examples/.cvsignore
@@ -18,6 +18,7 @@ pprint
pprint_static
procargs
procargs_static
+proclist
df
df_static
netlist
diff --git a/examples/ChangeLog b/examples/ChangeLog
index 0941da80..d1dcfc3b 100644
--- a/examples/ChangeLog
+++ b/examples/ChangeLog
@@ -1,3 +1,13 @@
+2005-12-12 Benoît Dejean <benoit@placenet.org>
+
+ * .cvsignore:
+ * Makefile.am:
+ * proclist.c: (main):
+ * procmap.c: (main):
+
+ Added quick example for glibtop_get_proclist()
+ and updated procmap example to display smap.
+
2005-08-02 Benoît Dejean <TazForEver@dlfp.org>
* pprint.c: (pprint_get_cpu), (pprint_get_loadavg),
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 698692fc..28fea5f5 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -8,7 +8,7 @@ DEFS = @DEFS@
noinst_PROGRAMS = first second pprint procargs df netlist \
mountlist procmap netload sysdeps timings \
- openfiles smp
+ openfiles smp proclist
first_SOURCES = first.c
first_LDADD = $(top_builddir)/lib/libgtop-2.0.la
@@ -48,3 +48,6 @@ netlist_LDADD = $(top_builddir)/lib/libgtop-2.0.la
openfiles_SOURCES = openfiles.c
openfiles_LDADD = $(top_builddir)/lib/libgtop-2.0.la
+
+proclist_SOURCES = proclist.c
+proclist_LDADD = $(top_builddir)/lib/libgtop-2.0.la
diff --git a/examples/proclist.c b/examples/proclist.c
new file mode 100644
index 00000000..209a5f5f
--- /dev/null
+++ b/examples/proclist.c
@@ -0,0 +1,28 @@
+#include <glibtop.h>
+#include <glibtop/proclist.h>
+
+#include <glib.h>
+
+#include <stdio.h>
+
+int main()
+{
+ unsigned *pids;
+ unsigned i;
+ glibtop_proclist buf;
+
+ glibtop_init();
+
+ pids = glibtop_get_proclist(&buf, 0, 0);
+
+ for (i = 0; i < buf.number; ++i)
+ printf("%u ", pids[i]);
+
+ putchar('\n');
+
+ g_free(pids);
+
+ glibtop_close();
+
+ return 0;
+}
diff --git a/examples/procmap.c b/examples/procmap.c
index 17501125..f28df1be 100644
--- a/examples/procmap.c
+++ b/examples/procmap.c
@@ -157,6 +157,18 @@ main (int argc, char *argv [])
perm);
}
+
+ g_print("smaps flags:%#llx size:%llu rss:%llu "
+ "shared_clean:%llu shared_dirty:%llu "
+ "private_clean:%llu private_dirty: %llu\n",
+ maps[i].flags,
+ maps[i].size >> 10,
+ maps[i].rss >> 10,
+ maps[i].shared_clean >> 10,
+ maps[i].shared_dirty >> 10,
+ maps[i].private_clean >> 10,
+ maps[i].private_dirty >> 10);
+
if (filename && (filename != maps [i].filename))
g_free ((void*)filename);
}