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 + + * .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 * 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 +#include + +#include + +#include + +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); }