NET-1782: Fetch Node Connection Status from metrics (#3237)

* add live status of node

* handle static node status

* add public IP field to server configuration

* get public Ip from config

* improve node status logic

* improvise status check

* use only checkin status on old nodes

---------

Co-authored-by: the_aceix <aceixsmartx@gmail.com>
This commit is contained in:
Abhishek K
2024-12-10 10:46:05 +04:00
committed by GitHub
parent 496d541822
commit 31c2311bef
12 changed files with 293 additions and 34 deletions

View File

@@ -11,6 +11,19 @@ import (
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
type NodeStatus string
const (
OnlineSt NodeStatus = "online"
OfflineSt NodeStatus = "offline"
WarningSt NodeStatus = "warning"
ErrorSt NodeStatus = "error"
UnKnown NodeStatus = "unknown"
)
// LastCheckInThreshold - if node's checkin more than this threshold,then node is declared as offline
const LastCheckInThreshold = time.Minute * 10
const (
// NODE_SERVER_NAME - the default server name
NODE_SERVER_NAME = "netmaker"
@@ -103,6 +116,7 @@ type Node struct {
IsStatic bool `json:"is_static"`
IsUserNode bool `json:"is_user_node"`
StaticNode ExtClient `json:"static_node"`
Status NodeStatus `json:"node_status"`
}
// LegacyNode - legacy struct for node model