Skip to content

Commit

Permalink
check last check in against metrics interval
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Jan 7, 2025
1 parent 088b4ef commit 739f6ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pro/logic/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/servercfg"
)

func getNodeStatusOld(node *models.Node) {
Expand All @@ -30,6 +31,10 @@ func GetNodeStatus(node *models.Node, defaultEnabledPolicy bool) {
node.Status = models.OfflineSt
return
}
if time.Since(node.LastCheckIn) < servercfg.GetMetricIntervalInMinutes() {
node.Status = models.OnlineSt
return
}
if node.IsStatic {
if !node.StaticNode.Enabled {
node.Status = models.OfflineSt
Expand Down
15 changes: 15 additions & 0 deletions servercfg/serverconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,21 @@ func GetMqUserName() string {
return password
}

// GetMetricInterval - get the publish metric interval
func GetMetricIntervalInMinutes() time.Duration {
//default 15 minutes
mi := "15"
if os.Getenv("PUBLISH_METRIC_INTERVAL") != "" {
mi = os.Getenv("PUBLISH_METRIC_INTERVAL")
}
interval, err := strconv.Atoi(mi)
if err != nil {
interval = 15
}

return time.Duration(interval) * time.Minute
}

// GetMetricInterval - get the publish metric interval
func GetMetricInterval() string {
//default 15 minutes
Expand Down

0 comments on commit 739f6ad

Please sign in to comment.