2022-04-13 14:09:33 +08:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2022-04-13 14:19:02 +08:00
|
|
|
"log"
|
2022-04-13 16:24:12 +08:00
|
|
|
|
2022-07-03 22:01:41 +08:00
|
|
|
"flashcat.cloud/categraf/traces"
|
|
|
|
|
2022-04-13 20:12:20 +08:00
|
|
|
// auto registry
|
2022-06-21 10:15:45 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/conntrack"
|
2022-04-15 12:35:45 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/cpu"
|
2022-04-15 13:58:46 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/disk"
|
2022-04-15 16:44:57 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/diskio"
|
2022-07-17 15:00:46 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/dns_query"
|
2022-06-07 10:40:00 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/docker"
|
2022-06-29 07:16:54 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/elasticsearch"
|
2022-04-18 14:23:00 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/exec"
|
2022-05-14 16:26:52 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/http_response"
|
2022-07-12 16:08:38 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/jolokia_agent"
|
|
|
|
_ "flashcat.cloud/categraf/inputs/jolokia_proxy"
|
2022-07-03 22:01:41 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/kafka"
|
2022-04-16 23:14:48 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/kernel"
|
2022-05-14 16:31:30 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/kernel_vmstat"
|
2022-06-14 17:12:58 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/kubernetes"
|
2022-05-14 16:31:30 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/linux_sysctl_fs"
|
2022-07-12 09:17:57 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/logstash"
|
2022-04-15 11:00:18 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/mem"
|
2022-07-13 11:19:49 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/mongodb"
|
2022-04-26 11:39:56 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/mysql"
|
2022-04-15 23:06:13 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/net"
|
2022-05-14 16:35:10 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/net_response"
|
2022-04-16 22:45:20 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/netstat"
|
2022-06-01 11:58:12 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/nginx_upstream_check"
|
2022-04-20 23:45:02 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/ntp"
|
2022-05-14 16:35:10 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/nvidia_smi"
|
2022-04-18 17:35:16 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/oracle"
|
2022-04-19 17:36:45 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/ping"
|
2022-04-17 10:50:02 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/processes"
|
2022-04-21 16:39:53 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/procstat"
|
2022-04-28 15:20:57 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/prometheus"
|
2022-04-29 16:36:57 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/rabbitmq"
|
2022-04-13 16:24:12 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/redis"
|
2022-07-13 13:17:12 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/redis_sentinel"
|
2022-05-25 15:38:49 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/switch_legacy"
|
2022-04-14 18:34:27 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/system"
|
2022-04-28 10:14:49 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/tomcat"
|
2022-06-14 18:09:22 +08:00
|
|
|
_ "flashcat.cloud/categraf/inputs/zookeeper"
|
2022-04-13 14:09:33 +08:00
|
|
|
)
|
|
|
|
|
2022-04-15 12:35:45 +08:00
|
|
|
type Agent struct {
|
2022-06-28 16:33:27 +08:00
|
|
|
InputFilters map[string]struct{}
|
|
|
|
InputReaders map[string]*InputReader
|
|
|
|
TraceCollector *traces.Collector
|
2022-04-15 12:35:45 +08:00
|
|
|
}
|
2022-04-13 14:09:33 +08:00
|
|
|
|
2022-04-15 12:35:45 +08:00
|
|
|
func NewAgent(filters map[string]struct{}) *Agent {
|
|
|
|
return &Agent{
|
|
|
|
InputFilters: filters,
|
2022-06-24 17:00:49 +08:00
|
|
|
InputReaders: make(map[string]*InputReader),
|
2022-04-13 14:09:33 +08:00
|
|
|
}
|
|
|
|
}
|
2022-04-13 14:19:02 +08:00
|
|
|
|
|
|
|
func (a *Agent) Start() {
|
|
|
|
log.Println("I! agent starting")
|
2022-06-02 16:35:28 +08:00
|
|
|
a.startLogAgent()
|
2022-06-24 16:35:46 +08:00
|
|
|
a.startMetricsAgent()
|
2022-06-28 16:33:27 +08:00
|
|
|
a.startTracesAgent()
|
2022-07-11 22:55:33 +08:00
|
|
|
a.startPrometheusScrape()
|
2022-06-24 16:35:46 +08:00
|
|
|
log.Println("I! agent started")
|
2022-04-13 14:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Agent) Stop() {
|
|
|
|
log.Println("I! agent stopping")
|
2022-06-24 16:35:46 +08:00
|
|
|
a.stopLogAgent()
|
|
|
|
a.stopMetricsAgent()
|
2022-06-28 16:33:27 +08:00
|
|
|
a.stopTracesAgent()
|
2022-07-11 22:55:33 +08:00
|
|
|
a.stopPrometheusScrape()
|
2022-04-15 12:43:17 +08:00
|
|
|
log.Println("I! agent stopped")
|
2022-04-13 14:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Agent) Reload() {
|
|
|
|
log.Println("I! agent reloading")
|
2022-04-13 17:16:16 +08:00
|
|
|
a.Stop()
|
|
|
|
a.Start()
|
2022-06-24 16:35:46 +08:00
|
|
|
log.Println("I! agent reloaded")
|
2022-04-13 16:24:12 +08:00
|
|
|
}
|