websocket_demo: Re-work net stats acquisition

The previous commit 5b83b60 ("websocket_demo: Re-work network interface
stats acquisition") removed the reading form /proc/net/dev and switched
to getifaddrs(3) for both the discovery of the network interface to use
and the acquisition of the rx and tx bytes.

This worked fine, however getifaddrs is limited to returning the
statistics in the rtnl_link_stats structure which defines its members as
32bit unsigned integers which wrap after about 4GiB.

The options to solve this are to use {rt}netlink(7) which can use the
rtnl_link_stats64 structure which defines its members as 64bit unsigned
integers or to take the values from /proc/net/dev

So we now use a mixture of getifaddrs and /proc/net/dev, we use
getifaddrs to find a suitable interface then pull out the rx and tx
bytes values for it from /proc/net/dev

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
websocket_demo: Use gethostname(2) instead of /etc/hostname

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
websocket_demo: Split up do_response()

Split out the actual gathering of data from do_response.

We now keep the hostname and network interface as global variables that
we setup once at startup.

We move the gathering of the uptime and network stats to their own
function get_stats() and now do_response simply calls this function,
builds the JSON and sends the data to the client.

This makes do_response easuer to read and reduces the amount of work
done when updating the client.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
websocket_demo: Use IFF_RUNNING instead of IFF_UP

When looking for a currently active interface for reporting stats on,
use one that has the IFF_RUNNING flag set and not just IFF_UP. An
interface can have IFF_UP set but not actually be in use. Looking for
IFF_RUNNING seems to produce better results.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>