A simple monitoring solution written in Go (work in progress)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
693 B

package check
import (
"alrm/check/ping"
"fmt"
"time"
)
type CheckPing struct {
Type string
Address string
Count int
Timeout time.Duration
}
func (c *CheckPing) Check(debuglvl int) error {
if debuglvl > 0 {
fmt.Printf("Pinging %s .. \n", c.Address)
}
p, err := ping.NewPinger(c.Address)
if err != nil {
return err
}
p.Count = 1
p.Timeout = time.Second * 5
err = p.Run()
if err != nil {
return err
}
stats := p.Statistics()
if len(stats.Rtts) < 1 {
return fmt.Errorf("ping failure")
}
if debuglvl > 0 {
fmt.Printf("Ping RTT: %s\n", stats.Rtts[0])
}
return nil
}
func (c *CheckPing) Parse(tk string) (bool, error) {
return false, nil
}