aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2009-08-23 22:03:16 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2009-08-23 22:03:16 +0000
commit16322c78ff4805ae5848541fd3b9a8dcdb077310 (patch)
tree057f8155debf6d3e5ec987fffdfd891bcb3ec2f9
parentAdded --remote-random-hostname option. (diff)
downloadopenvpn-16322c78ff4805ae5848541fd3b9a8dcdb077310.tar.xz
Added "load-stats" management interface command to get global
server load statistics. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@4844 e7ae566f-a301-0410-adde-c780ea21d3b5
-rw-r--r--forward.c6
-rw-r--r--manage.c21
2 files changed, 27 insertions, 0 deletions
diff --git a/forward.c b/forward.c
index e4063d2..2c26927 100644
--- a/forward.c
+++ b/forward.c
@@ -32,6 +32,7 @@
#include "event.h"
#include "ps.h"
#include "dhcp.h"
+#include "common.h"
#include "memdbg.h"
@@ -39,6 +40,9 @@
#include "occ-inline.h"
#include "ping-inline.h"
+counter_type link_read_bytes_global; /* GLOBAL */
+counter_type link_write_bytes_global; /* GLOBAL */
+
/* show event wait debugging info */
#ifdef ENABLE_DEBUG
@@ -704,6 +708,7 @@ process_incoming_link (struct context *c)
if (c->c2.buf.len > 0)
{
c->c2.link_read_bytes += c->c2.buf.len;
+ link_read_bytes_global += c->c2.buf.len;
c->c2.original_recv_size = c->c2.buf.len;
#ifdef ENABLE_MANAGEMENT
if (management)
@@ -1103,6 +1108,7 @@ process_outgoing_link (struct context *c)
{
c->c2.max_send_size_local = max_int (size, c->c2.max_send_size_local);
c->c2.link_write_bytes += size;
+ link_write_bytes_global += size;
#ifdef ENABLE_MANAGEMENT
if (management)
{
diff --git a/manage.c b/manage.c
index 37663bd..97d69b4 100644
--- a/manage.c
+++ b/manage.c
@@ -35,6 +35,7 @@
#include "integer.h"
#include "misc.h"
#include "ssl.h"
+#include "common.h"
#include "manage.h"
#include "memdbg.h"
@@ -75,6 +76,7 @@ man_help ()
msg (M_CLIENT, " release current hold and start tunnel.");
msg (M_CLIENT, "kill cn : Kill the client instance(s) having common name cn.");
msg (M_CLIENT, "kill IP:port : Kill the client instance connecting from IP:port.");
+ msg (M_CLIENT, "load-stats : Show global server load stats.");
msg (M_CLIENT, "log [on|off] [N|all] : Turn on/off realtime log display");
msg (M_CLIENT, " + show last N lines or 'all' for entire history.");
msg (M_CLIENT, "mute [n] : Set log mute level to n, or show level if n is absent.");
@@ -948,6 +950,21 @@ man_client_pf (struct management *man, const char *cid_str)
#endif
#endif
+static void
+man_load_stats (struct management *man)
+{
+ extern counter_type link_read_bytes_global;
+ extern counter_type link_write_bytes_global;
+ int nclients = 0;
+
+ if (man->persist.callback.n_clients)
+ nclients = (*man->persist.callback.n_clients) (man->persist.callback.arg);
+ msg (M_CLIENT, "SUCCESS: nclients=%d,bytesin=" counter_format ",bytesout=" counter_format,
+ nclients,
+ link_read_bytes_global,
+ link_write_bytes_global);
+}
+
#define MN_AT_LEAST (1<<0)
static bool
@@ -1006,6 +1023,10 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
if (man_need (man, p, 1, 0))
man_signal (man, p[1]);
}
+ else if (streq (p[0], "load-stats"))
+ {
+ man_load_stats (man);
+ }
else if (streq (p[0], "status"))
{
int version = 0;