status: add uptime and established times

This commit is contained in:
Matthias Schiffer 2014-09-15 16:35:34 +02:00
parent 7ebbe05f46
commit 316180d885
5 changed files with 11 additions and 0 deletions

View file

@ -478,6 +478,9 @@ static inline void init(int argc, char *argv[]) {
pr_info("fastd " FASTD_VERSION " starting");
fastd_update_time();
ctx.started = ctx.now;
fastd_cap_init();
init_sockets();

View file

@ -257,6 +257,8 @@ struct fastd_context {
char *ifname; /**< The actual interface name */
int64_t started; /**< The timestamp when fastd was started */
int64_t now; /**< The current monotonous timestamp in microseconds after an arbitrary point in time */
uint64_t next_peer_id; /**< An monotonously increasing ID peers are identified with in some components */

View file

@ -843,6 +843,7 @@ void fastd_peer_set_established(fastd_peer_t *peer) {
return;
peer->state = STATE_ESTABLISHED;
peer->established = ctx.now;
on_establish(peer);
pr_info("connection with %P established.", peer);
}

View file

@ -89,6 +89,7 @@ struct fastd_peer {
fastd_timeout_t last_handshake_response_timeout; /**< All handshakes from last_handshake_address will be ignored until this timeout has occured */
fastd_peer_address_t last_handshake_response_address; /**< The address the last handshake was received from */
int64_t established; /**< The time this peer connection has been established */
fastd_timeout_t establish_handshake_timeout; /**< A timeout during which all handshakes for this peer will be ignored after a new connection has been established */
const char *config_source_dir; /**< The directory this peer's configuration was loaded from */

View file

@ -115,6 +115,8 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
if (fastd_peer_is_established(peer)) {
connection = json_object_new_object();
json_object_object_add(connection, "established", json_object_new_int64(ctx.now - peer->established));
struct json_object *method = NULL;
const fastd_method_info_t *method_info = conf.protocol->get_current_method(peer);
@ -158,6 +160,8 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
static void dump_status(int fd) {
struct json_object *json = json_object_new_object();
json_object_object_add(json, "uptime", json_object_new_int64(ctx.now - ctx.started));
json_object_object_add(json, "statistics", dump_stats(&ctx.stats));
struct json_object *peers = json_object_new_object();