2022-07-11 22:55:33 +08:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2022-07-12 12:57:03 +08:00
|
|
|
"log"
|
2022-07-11 22:55:33 +08:00
|
|
|
|
2022-07-12 12:57:03 +08:00
|
|
|
coreconfig "flashcat.cloud/categraf/config"
|
2022-07-11 22:55:33 +08:00
|
|
|
"flashcat.cloud/categraf/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (a *Agent) startPrometheusScrape() {
|
|
|
|
if coreconfig.Config == nil ||
|
2022-07-13 11:43:03 +08:00
|
|
|
coreconfig.Config.Prometheus == nil ||
|
2022-07-11 22:55:33 +08:00
|
|
|
!coreconfig.Config.Prometheus.Enable {
|
2022-07-14 16:49:20 +08:00
|
|
|
log.Println("I! prometheus scraping disabled!")
|
2022-07-11 22:55:33 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
go prometheus.Start()
|
2022-07-14 16:49:20 +08:00
|
|
|
log.Println("I! prometheus scraping started!")
|
2022-07-11 22:55:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Agent) stopPrometheusScrape() {
|
|
|
|
if coreconfig.Config == nil ||
|
2022-07-13 11:43:03 +08:00
|
|
|
coreconfig.Config.Prometheus == nil ||
|
2022-07-11 22:55:33 +08:00
|
|
|
!coreconfig.Config.Prometheus.Enable {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
prometheus.Stop()
|
2022-07-12 12:57:03 +08:00
|
|
|
log.Println("I! prometheus scraping stopped!")
|
2022-07-11 22:55:33 +08:00
|
|
|
}
|