Merge pull request #9515 from swordqiu/hotfix/qj-telegraf-use-local-ipv4-address-explicitly

fix(host): telegraf listen on local ipv4 address explicitly
This commit is contained in:
Zexi Li
2020-12-19 18:11:34 +08:00
committed by GitHub
3 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ import (
)
const (
TelegrafServer = "http://localhost:8087/write"
TelegrafServer = "http://127.0.0.1:8087/write"
MeasurementsPrefix = "vm_"
)
@@ -100,6 +100,8 @@ func (s *SBaseSystemService) reloadConf(conf, conFile string) (bool, error) {
oldConf := string(output)
if strings.TrimSpace(conf) != strings.TrimSpace(oldConf) {
log.Debugf("Reload service %s ...", s.name)
log.Debugf("oldConf: [%s]", oldConf)
log.Debugf("newConf: [%s]", conf)
err := procutils.NewRemoteCommandAsFarAsPossible("rm", "-f", conFile).Run()
if err != nil {
return false, err
+2 -2
View File
@@ -177,7 +177,7 @@ func (s *STelegraf) GetConfig(kwargs map[string]interface{}) string {
conf += " collect_memstats = false\n"
conf += "\n"
conf += "[[inputs.http_listener]]\n"
conf += " service_address = \"localhost:8087\"\n"
conf += " service_address = \"127.0.0.1:8087\"\n"
conf += "\n"
return conf
}
@@ -211,7 +211,7 @@ func (s *STelegraf) BgReloadConf(kwargs map[string]interface{}) {
func (s *STelegraf) ReloadTelegraf() error {
log.Infof("Start reolad telegraf...")
telegrafReoladUrl := "http://localhost:8087/reload"
telegrafReoladUrl := "http://127.0.0.1:8087/reload"
_, _, err := httputils.JSONRequest(
httputils.GetDefaultClient(), context.Background(),
"POST", telegrafReoladUrl, nil, nil, false,