]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added "load-stats" management interface command to get global
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sun, 23 Aug 2009 22:03:16 +0000 (22:03 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Sun, 23 Aug 2009 22:03:16 +0000 (22:03 +0000)
server load statistics.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@4844 e7ae566f-a301-0410-adde-c780ea21d3b5

forward.c
manage.c

index e4063d21b94a265d08a233487988ba27341f7b15..2c26927e1f758dec525736cf98a598786fd0cba8 100644 (file)
--- 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)
                {
index 37663bd1f1ec635ec17ca3b8d5b64209e3e34b53..97d69b45bc3d394a60f085123c5defa5b3f74d65 100644 (file)
--- 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;