2021-01-01 09:26:49 -09:00
|
|
|
package check
|
2020-08-20 08:44:56 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2021-01-01 09:26:49 -09:00
|
|
|
type AlrmCheck interface {
|
|
|
|
Parse(string) (bool, error)
|
2021-01-02 06:29:12 -09:00
|
|
|
Check(int) error
|
2021-01-01 09:26:49 -09:00
|
|
|
}
|
|
|
|
|
2020-08-20 08:44:56 -08:00
|
|
|
func NewCheck(name string, addr string) (AlrmCheck, error) {
|
|
|
|
switch name {
|
|
|
|
case "ping":
|
2021-01-02 13:21:57 -09:00
|
|
|
return NewCheckPing(addr), nil
|
2020-08-20 08:44:56 -08:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown check name \"%s\"", name)
|
|
|
|
}
|
|
|
|
}
|