mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 09:32:32 +08:00
Merge pull request #2006 from gravitl/GRA-1136/rm_pinger
rm unused pinger func
This commit is contained in:
commit
d412287aed
1 changed files with 0 additions and 28 deletions
|
@ -1,12 +1,9 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-ping/ping"
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
)
|
||||
|
||||
|
@ -84,28 +81,3 @@ func ResetMetricForNode(server, peerKey, peerID string) {
|
|||
|
||||
// MetricCollectionInterval - collection interval for metrics
|
||||
const MetricCollectionInterval = time.Second * 25
|
||||
|
||||
// PeerConnectionStatus - get peer connection status by pinging
|
||||
func PeerConnectionStatus(address string) (connected bool) {
|
||||
fmt.Println("PINGER ADDR: ", address)
|
||||
pinger, err := ping.NewPinger(address)
|
||||
if err != nil {
|
||||
logger.Log(0, "could not initiliaze ping peer address", address, err.Error())
|
||||
connected = false
|
||||
} else {
|
||||
pinger.Timeout = time.Second * 2
|
||||
err = pinger.Run()
|
||||
if err != nil {
|
||||
logger.Log(0, "failed to ping on peer address", address, err.Error())
|
||||
return false
|
||||
} else {
|
||||
pingStats := pinger.Statistics()
|
||||
if pingStats.PacketsRecv > 0 {
|
||||
connected = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue