git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@4844 e7ae566f-a301-0410-adde-c780ea21d3b5
| ... | ... |
@@ -32,6 +32,7 @@ |
| 32 | 32 |
#include "event.h" |
| 33 | 33 |
#include "ps.h" |
| 34 | 34 |
#include "dhcp.h" |
| 35 |
+#include "common.h" |
|
| 35 | 36 |
|
| 36 | 37 |
#include "memdbg.h" |
| 37 | 38 |
|
| ... | ... |
@@ -39,6 +40,9 @@ |
| 39 | 39 |
#include "occ-inline.h" |
| 40 | 40 |
#include "ping-inline.h" |
| 41 | 41 |
|
| 42 |
+counter_type link_read_bytes_global; /* GLOBAL */ |
|
| 43 |
+counter_type link_write_bytes_global; /* GLOBAL */ |
|
| 44 |
+ |
|
| 42 | 45 |
/* show event wait debugging info */ |
| 43 | 46 |
|
| 44 | 47 |
#ifdef ENABLE_DEBUG |
| ... | ... |
@@ -704,6 +708,7 @@ process_incoming_link (struct context *c) |
| 704 | 704 |
if (c->c2.buf.len > 0) |
| 705 | 705 |
{
|
| 706 | 706 |
c->c2.link_read_bytes += c->c2.buf.len; |
| 707 |
+ link_read_bytes_global += c->c2.buf.len; |
|
| 707 | 708 |
c->c2.original_recv_size = c->c2.buf.len; |
| 708 | 709 |
#ifdef ENABLE_MANAGEMENT |
| 709 | 710 |
if (management) |
| ... | ... |
@@ -1103,6 +1108,7 @@ process_outgoing_link (struct context *c) |
| 1103 | 1103 |
{
|
| 1104 | 1104 |
c->c2.max_send_size_local = max_int (size, c->c2.max_send_size_local); |
| 1105 | 1105 |
c->c2.link_write_bytes += size; |
| 1106 |
+ link_write_bytes_global += size; |
|
| 1106 | 1107 |
#ifdef ENABLE_MANAGEMENT |
| 1107 | 1108 |
if (management) |
| 1108 | 1109 |
{
|
| ... | ... |
@@ -35,6 +35,7 @@ |
| 35 | 35 |
#include "integer.h" |
| 36 | 36 |
#include "misc.h" |
| 37 | 37 |
#include "ssl.h" |
| 38 |
+#include "common.h" |
|
| 38 | 39 |
#include "manage.h" |
| 39 | 40 |
|
| 40 | 41 |
#include "memdbg.h" |
| ... | ... |
@@ -75,6 +76,7 @@ man_help () |
| 75 | 75 |
msg (M_CLIENT, " release current hold and start tunnel."); |
| 76 | 76 |
msg (M_CLIENT, "kill cn : Kill the client instance(s) having common name cn."); |
| 77 | 77 |
msg (M_CLIENT, "kill IP:port : Kill the client instance connecting from IP:port."); |
| 78 |
+ msg (M_CLIENT, "load-stats : Show global server load stats."); |
|
| 78 | 79 |
msg (M_CLIENT, "log [on|off] [N|all] : Turn on/off realtime log display"); |
| 79 | 80 |
msg (M_CLIENT, " + show last N lines or 'all' for entire history."); |
| 80 | 81 |
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) |
| 948 | 948 |
#endif |
| 949 | 949 |
#endif |
| 950 | 950 |
|
| 951 |
+static void |
|
| 952 |
+man_load_stats (struct management *man) |
|
| 953 |
+{
|
|
| 954 |
+ extern counter_type link_read_bytes_global; |
|
| 955 |
+ extern counter_type link_write_bytes_global; |
|
| 956 |
+ int nclients = 0; |
|
| 957 |
+ |
|
| 958 |
+ if (man->persist.callback.n_clients) |
|
| 959 |
+ nclients = (*man->persist.callback.n_clients) (man->persist.callback.arg); |
|
| 960 |
+ msg (M_CLIENT, "SUCCESS: nclients=%d,bytesin=" counter_format ",bytesout=" counter_format, |
|
| 961 |
+ nclients, |
|
| 962 |
+ link_read_bytes_global, |
|
| 963 |
+ link_write_bytes_global); |
|
| 964 |
+} |
|
| 965 |
+ |
|
| 951 | 966 |
#define MN_AT_LEAST (1<<0) |
| 952 | 967 |
|
| 953 | 968 |
static bool |
| ... | ... |
@@ -1006,6 +1023,10 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch |
| 1006 | 1006 |
if (man_need (man, p, 1, 0)) |
| 1007 | 1007 |
man_signal (man, p[1]); |
| 1008 | 1008 |
} |
| 1009 |
+ else if (streq (p[0], "load-stats")) |
|
| 1010 |
+ {
|
|
| 1011 |
+ man_load_stats (man); |
|
| 1012 |
+ } |
|
| 1009 | 1013 |
else if (streq (p[0], "status")) |
| 1010 | 1014 |
{
|
| 1011 | 1015 |
int version = 0; |