Skip to content

Commit

Permalink
Merge pull request #7 from gadost/fixes
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
gadost authored Jul 22, 2022
2 parents 1c9e5fa + d791342 commit 3f5e15c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
20 changes: 14 additions & 6 deletions alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 3 additions & 14 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,16 @@ 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()
return true, resolved
} 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 {
Expand Down
6 changes: 3 additions & 3 deletions watcher/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 3f5e15c

Please sign in to comment.