2021-01-01 09:26:49 -09:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2021-02-03 05:59:31 -09:00
|
|
|
"git.binarythought.com/cdramey/alrm/check"
|
2021-01-01 09:26:49 -09:00
|
|
|
)
|
|
|
|
|
2021-01-17 09:04:08 -09:00
|
|
|
type Host struct {
|
2021-01-01 09:26:49 -09:00
|
|
|
Name string
|
|
|
|
Address string
|
2021-01-17 09:04:08 -09:00
|
|
|
Checks []check.Check
|
2021-01-01 09:26:49 -09:00
|
|
|
}
|
|
|
|
|
2021-01-17 09:04:08 -09:00
|
|
|
func (ah *Host) GetAddress() string {
|
2021-01-01 09:26:49 -09:00
|
|
|
if ah.Address != "" {
|
|
|
|
return ah.Address
|
|
|
|
}
|
|
|
|
return ah.Name
|
|
|
|
}
|
|
|
|
|
2021-01-17 09:04:08 -09:00
|
|
|
func (ah *Host) NewCheck(name string) (check.Check, error) {
|
2021-01-01 09:26:49 -09:00
|
|
|
chk, err := check.NewCheck(name, ah.GetAddress())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ah.Checks = append(ah.Checks, chk)
|
|
|
|
return chk, nil
|
|
|
|
}
|