gofmt
This commit is contained in:
parent
ceabd1d76b
commit
b10c025860
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
Copyright 2023 Laurent Ulrich (laurentu@gmail.com)
|
||||
Copyright 2023 Laurent Ulrich (laurentu@gmail.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package main
|
||||
|
||||
|
@ -47,7 +47,6 @@ type Group struct {
|
|||
Check Check `yaml:"check"`
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
log.Println("Starting")
|
||||
|
||||
|
@ -112,7 +111,7 @@ func checkGroup(name string, group Group, waitGroup *sync.WaitGroup, stopChannel
|
|||
break
|
||||
case status := <-channel:
|
||||
log.Println("Status for ", host, "is", status, "in group", name)
|
||||
updateTables( host, status, group.Tables )
|
||||
updateTables(host, status, group.Tables)
|
||||
default:
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ func checkGroup(name string, group Group, waitGroup *sync.WaitGroup, stopChannel
|
|||
}
|
||||
}
|
||||
|
||||
func updateTables( host string, status int, tables []string ) {
|
||||
func updateTables(host string, status int, tables []string) {
|
||||
for _, table := range tables {
|
||||
op := "add"
|
||||
if status != 0 {
|
||||
|
@ -165,14 +164,13 @@ func checkHost(status chan<- int, group string, host string, check Check, waitGr
|
|||
status <- 0
|
||||
}
|
||||
}
|
||||
time.Sleep(300*time.Millisecond)
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CheckHTTP(host string, check Check) error {
|
||||
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: time.Duration(check.Timeout) * time.Second,
|
||||
}
|
||||
|
@ -194,7 +192,7 @@ func CheckHTTP(host string, check Check) error {
|
|||
}
|
||||
|
||||
func CheckTCP(host string, check Check) error {
|
||||
cnx, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, check.Port), time.Duration(check.Timeout) * time.Second)
|
||||
cnx, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, check.Port), time.Duration(check.Timeout)*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -249,7 +247,7 @@ func validateConfiguration(conf map[string]Group) error {
|
|||
}
|
||||
|
||||
default:
|
||||
return errors.New(fmt.Sprintf("Check type should be http, smtp or tcp in group %s",name))
|
||||
return errors.New(fmt.Sprintf("Check type should be http, smtp or tcp in group %s", name))
|
||||
}
|
||||
if group.Check.Interval == 0 {
|
||||
group.Check.Interval = 5
|
||||
|
|
Loading…
Reference in New Issue