[Libwebsockets] file stats

Andy Green andy at warmcat.com
Thu Feb 2 06:43:28 CET 2017

On 02/02/2017 01:36 PM, Joel Winarske wrote:
> Where would a good place be to store stats on files served, per type?  
> JS, and all others - for example.

There's already a bunch of stats kept in private-libwebsockets.h here

struct lws_conn_stats {
         unsigned long long rx, tx;
         unsigned long conn, trans, ws_upg, http2_upg, rejected;

These can be converted to JSON and rendered by JS via a persistent ws 
link like this


(the plugin defaults to reporting by vhosts, but I disabled it on my 
server).  Notice

lws_sum_stats(const struct lws_context *ctx, struct lws_conn_stats *cs)

in libwebsockets.c, this provides a way to report per-vhost and tally 
the numbers up for the whole server as well.  If you add things they 
should also be added there.

lws_json_dump_vhost() further down provides a way to add them to the 
JSON received by the server status plugin.


> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list