netmaker/logic/status.go
Abhishek K 31c2311bef
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>
2024-12-10 10:46:05 +04:00

26 lines
471 B
Go

package logic
import (
"time"
"github.com/gravitl/netmaker/models"
)
var GetNodeStatus = getNodeStatus
func getNodeStatus(node *models.Node, t bool) {
// On CE check only last check-in time
if node.IsStatic {
if !node.StaticNode.Enabled {
node.Status = models.OfflineSt
return
}
node.Status = models.OnlineSt
return
}
if time.Since(node.LastCheckIn) > time.Minute*10 {
node.Status = models.OfflineSt
return
}
node.Status = models.OnlineSt
}