mirror of
https://github.com/neocturne/fastd.git
synced 2025-05-14 20:25:08 +02:00
status: add uptime and established times
This commit is contained in:
parent
7ebbe05f46
commit
316180d885
5 changed files with 11 additions and 0 deletions
|
@ -478,6 +478,9 @@ static inline void init(int argc, char *argv[]) {
|
||||||
|
|
||||||
pr_info("fastd " FASTD_VERSION " starting");
|
pr_info("fastd " FASTD_VERSION " starting");
|
||||||
|
|
||||||
|
fastd_update_time();
|
||||||
|
ctx.started = ctx.now;
|
||||||
|
|
||||||
fastd_cap_init();
|
fastd_cap_init();
|
||||||
|
|
||||||
init_sockets();
|
init_sockets();
|
||||||
|
|
|
@ -257,6 +257,8 @@ struct fastd_context {
|
||||||
|
|
||||||
char *ifname; /**< The actual interface name */
|
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 */
|
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 */
|
uint64_t next_peer_id; /**< An monotonously increasing ID peers are identified with in some components */
|
||||||
|
|
|
@ -843,6 +843,7 @@ void fastd_peer_set_established(fastd_peer_t *peer) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
peer->state = STATE_ESTABLISHED;
|
peer->state = STATE_ESTABLISHED;
|
||||||
|
peer->established = ctx.now;
|
||||||
on_establish(peer);
|
on_establish(peer);
|
||||||
pr_info("connection with %P established.", peer);
|
pr_info("connection with %P established.", peer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_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 */
|
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 */
|
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 */
|
const char *config_source_dir; /**< The directory this peer's configuration was loaded from */
|
||||||
|
|
|
@ -115,6 +115,8 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
|
||||||
if (fastd_peer_is_established(peer)) {
|
if (fastd_peer_is_established(peer)) {
|
||||||
connection = json_object_new_object();
|
connection = json_object_new_object();
|
||||||
|
|
||||||
|
json_object_object_add(connection, "established", json_object_new_int64(ctx.now - peer->established));
|
||||||
|
|
||||||
struct json_object *method = NULL;
|
struct json_object *method = NULL;
|
||||||
|
|
||||||
const fastd_method_info_t *method_info = conf.protocol->get_current_method(peer);
|
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) {
|
static void dump_status(int fd) {
|
||||||
struct json_object *json = json_object_new_object();
|
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));
|
json_object_object_add(json, "statistics", dump_stats(&ctx.stats));
|
||||||
|
|
||||||
struct json_object *peers = json_object_new_object();
|
struct json_object *peers = json_object_new_object();
|
||||||
|
|
Loading…
Add table
Reference in a new issue