mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
[metrics] Add the ability to control bind ip (#4012)
This commit is contained in:
parent
15284e2bee
commit
4b0430e71d
|
@ -162,7 +162,7 @@ func runFiler(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
|
|
||||||
go stats_collect.StartMetricsServer(*f.metricsHttpPort)
|
go stats_collect.StartMetricsServer(*f.bindIp, *f.metricsHttpPort)
|
||||||
|
|
||||||
filerAddress := util.JoinHostPort(*f.ip, *f.port)
|
filerAddress := util.JoinHostPort(*f.ip, *f.port)
|
||||||
startDelay := time.Duration(2)
|
startDelay := time.Duration(2)
|
||||||
|
|
|
@ -43,6 +43,7 @@ type SyncOptions struct {
|
||||||
bFromTsMs *int64
|
bFromTsMs *int64
|
||||||
aProxyByFiler *bool
|
aProxyByFiler *bool
|
||||||
bProxyByFiler *bool
|
bProxyByFiler *bool
|
||||||
|
metricsHttpIp *string
|
||||||
metricsHttpPort *int
|
metricsHttpPort *int
|
||||||
concurrency *int
|
concurrency *int
|
||||||
clientId int32
|
clientId int32
|
||||||
|
@ -86,6 +87,7 @@ func init() {
|
||||||
syncOptions.concurrency = cmdFilerSynchronize.Flag.Int("concurrency", DefaultConcurrencyLimit, "The maximum number of files that will be synced concurrently.")
|
syncOptions.concurrency = cmdFilerSynchronize.Flag.Int("concurrency", DefaultConcurrencyLimit, "The maximum number of files that will be synced concurrently.")
|
||||||
syncCpuProfile = cmdFilerSynchronize.Flag.String("cpuprofile", "", "cpu profile output file")
|
syncCpuProfile = cmdFilerSynchronize.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
syncMemProfile = cmdFilerSynchronize.Flag.String("memprofile", "", "memory profile output file")
|
syncMemProfile = cmdFilerSynchronize.Flag.String("memprofile", "", "memory profile output file")
|
||||||
|
syncOptions.metricsHttpIp = cmdFilerSynchronize.Flag.String("metricsIp", "", "metrics listen ip")
|
||||||
syncOptions.metricsHttpPort = cmdFilerSynchronize.Flag.Int("metricsPort", 0, "metrics listen port")
|
syncOptions.metricsHttpPort = cmdFilerSynchronize.Flag.Int("metricsPort", 0, "metrics listen port")
|
||||||
syncOptions.clientId = util.RandomInt32()
|
syncOptions.clientId = util.RandomInt32()
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
|
||||||
filerB := pb.ServerAddress(*syncOptions.filerB)
|
filerB := pb.ServerAddress(*syncOptions.filerB)
|
||||||
|
|
||||||
// start filer.sync metrics server
|
// start filer.sync metrics server
|
||||||
go statsCollect.StartMetricsServer(*syncOptions.metricsHttpPort)
|
go statsCollect.StartMetricsServer(*syncOptions.metricsHttpIp, *syncOptions.metricsHttpPort)
|
||||||
|
|
||||||
// read a filer signature
|
// read a filer signature
|
||||||
aFilerSignature, aFilerErr := replication.ReadFilerSignature(grpcDialOption, filerA)
|
aFilerSignature, aFilerErr := replication.ReadFilerSignature(grpcDialOption, filerA)
|
||||||
|
|
|
@ -119,7 +119,7 @@ func runMaster(cmd *Command, args []string) bool {
|
||||||
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
|
||||||
}
|
}
|
||||||
|
|
||||||
go stats_collect.StartMetricsServer(*m.metricsHttpPort)
|
go stats_collect.StartMetricsServer(*m.ipBind, *m.metricsHttpPort)
|
||||||
startMaster(m, masterWhiteList)
|
startMaster(m, masterWhiteList)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -144,7 +144,7 @@ func runS3(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
|
|
||||||
go stats_collect.StartMetricsServer(*s3StandaloneOptions.metricsHttpPort)
|
go stats_collect.StartMetricsServer(*s3StandaloneOptions.bindIp, *s3StandaloneOptions.metricsHttpPort)
|
||||||
|
|
||||||
return s3StandaloneOptions.startS3Server()
|
return s3StandaloneOptions.startS3Server()
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
webdavOptions.filer = &filerAddress
|
webdavOptions.filer = &filerAddress
|
||||||
mqBrokerOptions.filerGroup = filerOptions.filerGroup
|
mqBrokerOptions.filerGroup = filerOptions.filerGroup
|
||||||
|
|
||||||
go stats_collect.StartMetricsServer(*serverMetricsHttpPort)
|
go stats_collect.StartMetricsServer(*serverBindIp, *serverMetricsHttpPort)
|
||||||
|
|
||||||
folders := strings.Split(*volumeDataFolders, ",")
|
folders := strings.Split(*volumeDataFolders, ",")
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ func runVolume(cmd *Command, args []string) bool {
|
||||||
grace.SetupProfiling(*v.cpuProfile, *v.memProfile)
|
grace.SetupProfiling(*v.cpuProfile, *v.memProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
go stats_collect.StartMetricsServer(*v.metricsHttpPort)
|
go stats_collect.StartMetricsServer(*v.bindIp, *v.metricsHttpPort)
|
||||||
|
|
||||||
minFreeSpaces := util.MustParseMinFreeSpace(*minFreeSpace, *minFreeSpacePercent)
|
minFreeSpaces := util.MustParseMinFreeSpace(*minFreeSpace, *minFreeSpacePercent)
|
||||||
v.masters = pb.ServerAddresses(*v.mastersString).ToAddresses()
|
v.masters = pb.ServerAddresses(*v.mastersString).ToAddresses()
|
||||||
|
|
|
@ -282,12 +282,12 @@ func LoopPushingMetric(name, instance, addr string, intervalSeconds int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartMetricsServer(port int) {
|
func StartMetricsServer(ip string, port int) {
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.Handle("/metrics", promhttp.HandlerFor(Gather, promhttp.HandlerOpts{}))
|
http.Handle("/metrics", promhttp.HandlerFor(Gather, promhttp.HandlerOpts{}))
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", ip, port), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SourceName(port uint32) string {
|
func SourceName(port uint32) string {
|
||||||
|
|
Loading…
Reference in a new issue