parent
eddd658b7f
commit
3739671503
7
event.go
7
event.go
|
@ -1,9 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DropletT) Start() {
|
func (d *DropletT) Start() {
|
||||||
log.Info("a new virtual machine is running")
|
log.Info("a new virtual machine is running")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *HyperT) RestartDaemon() {
|
||||||
|
url := "http://" + h.Hostname + ":2520/kill"
|
||||||
|
s := shell.Wget(url)
|
||||||
|
log.Info("EVENT RestartDaemon", url, s)
|
||||||
|
}
|
||||||
|
|
9
poll.go
9
poll.go
|
@ -73,9 +73,11 @@ func findDroplet(name string) *DropletT {
|
||||||
// that is intended to be sent to an uptime monitor like Kuma
|
// that is intended to be sent to an uptime monitor like Kuma
|
||||||
func clusterHealthy() (bool, string) {
|
func clusterHealthy() (bool, string) {
|
||||||
var good bool = true
|
var good bool = true
|
||||||
|
var total int
|
||||||
var working int
|
var working int
|
||||||
var failed int
|
var failed int
|
||||||
for _, d := range me.droplets {
|
for _, d := range me.droplets {
|
||||||
|
total += 1
|
||||||
if d.State != "ON" {
|
if d.State != "ON" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -87,6 +89,7 @@ func clusterHealthy() (bool, string) {
|
||||||
if d.CurrentState != "ON" {
|
if d.CurrentState != "ON" {
|
||||||
log.Info("BAD STATE", d.State, d.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
|
log.Info("BAD STATE", d.State, d.Hostname, d.hname, "CurrentState =", d.CurrentState, shell.FormatDuration(dur))
|
||||||
good = false
|
good = false
|
||||||
|
failed += 1
|
||||||
} else {
|
} else {
|
||||||
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
dur := time.Since(d.lastpoll) // Calculate the elapsed time
|
||||||
if dur > time.Minute {
|
if dur > time.Minute {
|
||||||
|
@ -106,12 +109,14 @@ func clusterHealthy() (bool, string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var summary string = "("
|
var summary string = "("
|
||||||
|
summary += fmt.Sprintf("total = %d ", total)
|
||||||
if working > 0 {
|
if working > 0 {
|
||||||
summary += fmt.Sprintf("working = %d", working)
|
summary += fmt.Sprintf("working = %d ", working)
|
||||||
}
|
}
|
||||||
if failed > 0 {
|
if failed > 0 {
|
||||||
summary += fmt.Sprintf("failed = %d", failed)
|
summary += fmt.Sprintf("failed = %d ", failed)
|
||||||
}
|
}
|
||||||
|
summary = strings.TrimSpace(summary)
|
||||||
summary += ")"
|
summary += ")"
|
||||||
if good {
|
if good {
|
||||||
return good, "GOOD=true " + summary
|
return good, "GOOD=true " + summary
|
||||||
|
|
Loading…
Reference in New Issue