summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorJames Yonan <james@openvpn.net>2011-10-18 08:12:51 +0000
committerDavid Sommerseth <davids@redhat.com>2011-12-14 17:03:24 +0100
commitffea644ce62a67ea06e375c17277cea4e9cb9873 (patch)
treef9d897b7b3b6d54474d846de9a54ffc1b1c7cc60 /init.c
parent359adbf136e07011ad6733c3ba679b2d5cc47fdc (diff)
downloadopenvpn-ffea644ce62a67ea06e375c17277cea4e9cb9873.tar.gz
openvpn-ffea644ce62a67ea06e375c17277cea4e9cb9873.tar.xz
openvpn-ffea644ce62a67ea06e375c17277cea4e9cb9873.zip
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
Diffstat (limited to 'init.c')
-rw-r--r--init.c22
1 files changed, 22 insertions, 0 deletions
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