diff --git a/conf.yaml b/conf.yaml index c41ea02..d64ea4f 100644 --- a/conf.yaml +++ b/conf.yaml @@ -2,5 +2,12 @@ IDE: tables: - ide hosts: + - 172.17.4.30 + - 172.17.4.31 + +PLOOPI: + tables: + - ploopi + hosts: + - 172.17.4.40 - 172.17.4.20 - - 172.17.4.21 diff --git a/main.go b/main.go index dac9b35..7ed4c90 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import "io" import "io/ioutil" import "log" import "gopkg.in/yaml.v3" +import "time" type Group struct { Name string `yaml:"group"` @@ -25,13 +26,21 @@ func main() { log.Fatalf("Configuration read error #%v", err) } - resp, err := http.Head("http://example.com") - if err != nil { - fmt.Println("Failed") - } else { - _, _ = io.ReadAll(resp.Body) - resp.Body.Close() - fmt.Println("status", resp.StatusCode) + for name, group := range conf { + fmt.Println("Checking group", name ) + for _, host := range group.Hosts { + client := &http.Client{ + Timeout: time.Second * 5, + } + resp, err := client.Head(fmt.Sprintf("http://%s", host)) + if err != nil { + fmt.Println(host, "Failed") + } else { + _, _ = io.ReadAll(resp.Body) + resp.Body.Close() + fmt.Println(host, "Status", resp.StatusCode) + } + } } }