diff --git a/alert/alert.go b/alert/alert.go index d4cc1cc..ff59d20 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -8,16 +8,24 @@ import ( "github.com/gadost/telescope/conf" ) +const ( + at = "🔭 Telescope \\| " + urgent = at + "Urgent 🔴" + warning = at + "Warning ⚠ī¸" + info = at + "Info ℹī¸" + ok = at + "OK ✅" + gh = at + "Repo Monitor 🔎" +) + // wgAlert is wait group for alerts gorutines var wgAlert sync.WaitGroup var alertSystems = &conf.MainConfig -var at = "🔭 Telescope \\| " var Importance = importance{ - Urgent: at + "Urgent 🔴", - Warning: at + "Warning ⚠ī¸", - Info: at + "Info ℹī¸", - OK: at + "OK ✅", - GH: at + "Repo Monitor 🔎", + Urgent: urgent, + Warning: warning, + Info: info, + OK: ok, + GH: gh, } // importance struct is struct for alert types diff --git a/event/event.go b/event/event.go index 8d1075c..2aae95a 100644 --- a/event/event.go +++ b/event/event.go @@ -86,14 +86,8 @@ func Unknown(s string) string { } // HealthCheck check node health -func HealthCheck( - moniker, - network, - rpc string, - counter int, - timeDelta time.Duration, - lastSeenAt time.Time, - lastStatus bool) (bool, bool) { +func HealthCheck(moniker, network, rpc string, counter int, + timeDelta time.Duration, lastSeenAt time.Time, lastStatus bool) (bool, bool) { var resolved = false if counter == 5 { alert.NewAlertAccessDelays(Unknown(moniker), Unknown(network), rpc).Send() @@ -101,12 +95,7 @@ func HealthCheck( } else if counter > 5 { return true, resolved } else if counter == 0 && lastStatus { - alert.NewAlertAccessRestored( - Unknown(moniker), - Unknown(network), - lastSeenAt, - timeDelta, - ).Send() + alert.NewAlertAccessRestored(Unknown(moniker), Unknown(network), lastSeenAt, timeDelta).Send() resolved = true return false, resolved } else if counter == 0 && !lastStatus { diff --git a/watcher/github.go b/watcher/github.go index 232df12..ca231f3 100644 --- a/watcher/github.go +++ b/watcher/github.go @@ -95,9 +95,9 @@ func CheckNewRealeases() { if ri.Domain == "github.com" { lRR := new(latestReleaseResponse) wgGithub.Add(1) - go Monitor(ri, lRR) + go lRR.Monitor(ri) } else { - log.Printf("Repo %s Not Found of can't be parsed", k.Info.Github) + log.Printf("Repo %s Not Found or can't be parsed", k.Info.Github) } } } @@ -130,7 +130,7 @@ func Parse(u string) repoInfo { } // Monitor check github releases -func Monitor(ri repoInfo, target *latestReleaseResponse) { +func (target *latestReleaseResponse) Monitor(ri repoInfo) { defer wgGithub.Done() for { eP := fmt.Sprintf("https://api.github.com/repos/" + ri.Owner + "/" + ri.RepoName + "/releases/latest")