aboutsummaryrefslogtreecommitdiff
path: root/weed/server/master_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/server/master_server.go')
-rw-r--r--weed/server/master_server.go43
1 files changed, 36 insertions, 7 deletions
diff --git a/weed/server/master_server.go b/weed/server/master_server.go
index 8621708d2..32d6b76b1 100644
--- a/weed/server/master_server.go
+++ b/weed/server/master_server.go
@@ -45,13 +45,14 @@ type MasterOption struct {
VolumePreallocate bool
MaxParallelVacuumPerServer int
// PulseSeconds int
- DefaultReplicaPlacement string
- GarbageThreshold float64
- WhiteList []string
- DisableHttp bool
- MetricsAddress string
- MetricsIntervalSec int
- IsFollower bool
+ DefaultReplicaPlacement string
+ GarbageThreshold float64
+ WhiteList []string
+ DisableHttp bool
+ MetricsAddress string
+ MetricsIntervalSec int
+ IsFollower bool
+ SupportSeaweedFsWithMetrics bool
}
type MasterServer struct {
@@ -416,3 +417,31 @@ func (ms *MasterServer) Reload() {
util.StringSplit(v.GetString("guard.white_list"), ",")...),
)
}
+
+func (ms *MasterServer) startMetricsCollection() {
+ go func() {
+ ticker := time.NewTicker(30 * time.Second)
+ defer ticker.Stop()
+
+ for {
+ select {
+ case <-ticker.C:
+ if ms.Topo != nil {
+ stats.UpdateClusterMetrics(ms.Topo.ToTopologyInfo(), ms.option.VolumeSizeLimitMB)
+ // Push metrics to the gateway if enabled
+ if err := stats.PushMetrics(stats.GenerateClusterId(ms.Topo.ToTopologyInfo()), ms.option.SupportSeaweedFsWithMetrics); err != nil {
+ glog.Warningf("Failed to push metrics: %v", err)
+ }
+ }
+ }
+ }
+ }()
+}
+
+func (ms *MasterServer) Start() error {
+ // Start metrics collection
+ ms.startMetricsCollection()
+
+ // ... rest of existing code ...
+ return nil
+}