|
@@ -7,6 +7,7 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
+ "github.com/go-ping/ping"
|
|
|
"imuslab.com/zoraxy/mod/utils"
|
|
|
)
|
|
|
|
|
@@ -82,6 +83,20 @@ func (m *Monitor) ExecuteUptimeCheck() {
|
|
|
var thisRecord Record
|
|
|
if target.Protocol == "http" || target.Protocol == "https" {
|
|
|
online, laterncy, statusCode := getWebsiteStatusWithLatency(target.URL)
|
|
|
+ if !online {
|
|
|
+ //Try ICMP ping as well
|
|
|
+ pinger, err := ping.NewPinger(target.URL)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("Unable to start uptime check pinger: " + err.Error())
|
|
|
+ } else {
|
|
|
+ pinger.Count = 2
|
|
|
+ err = pinger.Run()
|
|
|
+ if err != nil {
|
|
|
+ //Unable to ping it. Assume offline
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
thisRecord = Record{
|
|
|
Timestamp: time.Now().Unix(),
|
|
|
ID: target.ID,
|