Configurable interval for nodata checks
This commit is contained in:
parent
c45724f5d8
commit
9eecf946f8
@ -1,5 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
type SmonConfiguration struct {
|
type SmonConfiguration struct {
|
||||||
LogFile string
|
LogFile string
|
||||||
|
NodataInterval int `json:"nodata_interval"` // in seconds
|
||||||
}
|
}
|
||||||
|
6
main.go
6
main.go
@ -38,6 +38,7 @@ var (
|
|||||||
parsedTemplates map[string]*template.Template
|
parsedTemplates map[string]*template.Template
|
||||||
componentFilenames []string
|
componentFilenames []string
|
||||||
notificationManager notification.Manager
|
notificationManager notification.Manager
|
||||||
|
smonConf SmonConfiguration
|
||||||
|
|
||||||
//go:embed sql
|
//go:embed sql
|
||||||
sqlFS embed.FS
|
sqlFS embed.FS
|
||||||
@ -88,7 +89,6 @@ func main() { // {{{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
smonConf := SmonConfiguration{}
|
|
||||||
j, _ := json.Marshal(service.Config.Application)
|
j, _ := json.Marshal(service.Config.Application)
|
||||||
json.Unmarshal(j, &smonConf)
|
json.Unmarshal(j, &smonConf)
|
||||||
logFile, err = os.OpenFile(smonConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
logFile, err = os.OpenFile(smonConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
||||||
@ -96,6 +96,10 @@ func main() { // {{{
|
|||||||
logger.Error("application", "error", err)
|
logger.Error("application", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if smonConf.NodataInterval < 10 {
|
||||||
|
logger.Error("application → nodata_interval has to be larger or equal to 10.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
service.SetDatabase(sqlProvider)
|
service.SetDatabase(sqlProvider)
|
||||||
service.SetStaticFS(staticFS, "static")
|
service.SetStaticFS(staticFS, "static")
|
||||||
|
@ -25,7 +25,7 @@ func nodataLoop() {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
// TODO - should be configurable
|
// TODO - should be configurable
|
||||||
ticker := time.NewTicker(time.Second * 5)
|
ticker := time.NewTicker(time.Second * time.Duration(smonConf.NodataInterval))
|
||||||
for {
|
for {
|
||||||
<-ticker.C
|
<-ticker.C
|
||||||
datapoints, err = nodataDatapoints()
|
datapoints, err = nodataDatapoints()
|
||||||
|
Loading…
Reference in New Issue
Block a user