Skip to content

Commit

Permalink
GROUNDWORK-3736 improve SNMP LastOK
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Sumkin committed Nov 29, 2024
1 parent 993a9e4 commit e74b92f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions connectors/snmp/clients/nediClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ type Device struct {
Name string
IP string
Community string
LastOK float64
LastOK int64
}

type Monitoring struct {
Name string
IP string
Device string
LastOK float64
LastOK int64
}

type Interface struct {
Expand Down Expand Up @@ -331,7 +331,7 @@ func (client *NediClient) getMonitoredDevices() (map[string]Monitoring, error) {
var monitor Monitoring
monitor.Name = fields[colName].(string)
monitor.Device = fields[colDevice].(string)
monitor.LastOK = fields[colLastOK].(float64)
monitor.LastOK = int64(fields[colLastOK].(float64))

ip := fields[colMonIP]
ipVal, err := getInt(ip)
Expand Down
5 changes: 2 additions & 3 deletions connectors/snmp/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,11 @@ func (device *DeviceExt) retrieveMonitoredServices(metricDefinitions map[string]
return mServices
}

func calculateHostStatus(lastOk float64) transit.MonitorStatus {
func calculateHostStatus(lastOk int64) transit.MonitorStatus {
now := time.Now().Unix() // in seconds
if (float64(now) - lastOk) < FiveMinutes {
if (now - lastOk) < FiveMinutes {
return transit.HostUp
}

return transit.HostUnreachable
}

Expand Down

0 comments on commit e74b92f

Please sign in to comment.