mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-08 06:04:20 +08:00
check last check in against metrics interval
This commit is contained in:
parent
088b4ef82b
commit
739f6ade90
2 changed files with 20 additions and 0 deletions
|
@ -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) {
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue