From ffea644ce62a67ea06e375c17277cea4e9cb9873 Mon Sep 17 00:00:00 2001 From: James Yonan Date: Tue, 18 Oct 2011 08:12:51 +0000 Subject: Added "memstats" option to maintain real-time operating stats in a memory-mapped file. Version 2.1.16 git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7653 e7ae566f-a301-0410-adde-c780ea21d3b5 --- init.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'init.c') diff --git a/init.c b/init.c index 82c1000..a225c26 100644 --- a/init.c +++ b/init.c @@ -36,6 +36,7 @@ #include "ps.h" #include "lladdr.h" #include "ping.h" +#include "mstats.h" #include "memdbg.h" @@ -815,6 +816,22 @@ init_static (void) } #endif +#ifdef MSTATS_TEST + { + int i; + mstats_open("/dev/shm/mstats.dat"); + for (i = 0; i < 30; ++i) + { + mmap_stats->n_clients += 1; + mmap_stats->link_write_bytes += 8; + mmap_stats->link_read_bytes += 16; + sleep(1); + } + mstats_close(); + return false; + } +#endif + return true; } @@ -1014,6 +1031,11 @@ do_uid_gid_chroot (struct context *c, bool no_delay) msg (M_INFO, "NOTE: UID/GID downgrade %s", why_not); } +#ifdef ENABLE_MEMSTATS + if (c->options.memstats_fn) + mstats_open(c->options.memstats_fn); +#endif + #ifdef HAVE_SETCON /* Apply a SELinux context in order to restrict what OpenVPN can do * to _only_ what it is supposed to do after initialization is complete -- cgit