aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-16 02:44:20 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-16 02:44:20 -0700
commit0fdb1e705d21a5be1ddca8f1cdc64a5c5b65d413 (patch)
tree6aeea7ffff19cc70bd8f779fa479f47232b640b5
parent289fd7eb39a9150b392a8e29596f9b85ace0534c (diff)
downloadseaweedfs-0fdb1e705d21a5be1ddca8f1cdc64a5c5b65d413.tar.xz
seaweedfs-0fdb1e705d21a5be1ddca8f1cdc64a5c5b65d413.zip
collect volume disk usage metrics
-rw-r--r--weed/stats/metrics.go16
-rw-r--r--weed/storage/store.go5
-rw-r--r--weed/storage/store_ec.go8
3 files changed, 29 insertions, 0 deletions
diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go
index fccf64d19..2408b607a 100644
--- a/weed/stats/metrics.go
+++ b/weed/stats/metrics.go
@@ -63,6 +63,20 @@ var (
Name: "ecShards",
Help: "Number of EC shards.",
})
+ VolumeServerVolumeSizeGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "SeaweedFS",
+ Subsystem: "volumeServer",
+ Name: "totalVolumeSize",
+ Help: "Actual disk size used by volumes.",
+ })
+ VolumeServerEcShardSizeGauge = prometheus.NewGauge(
+ prometheus.GaugeOpts{
+ Namespace: "SeaweedFS",
+ Subsystem: "volumeServer",
+ Name: "totalEcShardSize",
+ Help: "Actual disk size used by ec shards.",
+ })
)
func init() {
@@ -74,6 +88,8 @@ func init() {
VolumeServerGather.MustRegister(VolumeServerRequestHistogram)
VolumeServerGather.MustRegister(VolumeServerVolumeCounter)
VolumeServerGather.MustRegister(VolumeServerEcShardCounter)
+ VolumeServerGather.MustRegister(VolumeServerVolumeSizeGauge)
+ VolumeServerGather.MustRegister(VolumeServerEcShardSizeGauge)
}
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 2138041a4..1f1337e59 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -6,6 +6,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
+ "github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
. "github.com/chrislusf/seaweedfs/weed/storage/types"
"google.golang.org/grpc"
@@ -161,6 +162,7 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
var volumeMessages []*master_pb.VolumeInformationMessage
maxVolumeCount := 0
var maxFileKey NeedleId
+ var totalVolumeSize uint64
for _, location := range s.Locations {
maxVolumeCount = maxVolumeCount + location.MaxVolumeCount
location.Lock()
@@ -178,9 +180,12 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
glog.V(0).Infoln("volume", v.Id, "is expired.")
}
}
+ fileSize, _, _ := v.FileStat()
+ totalVolumeSize += fileSize
}
location.Unlock()
}
+ stats.VolumeServerVolumeSizeGauge.Set(float64(totalVolumeSize))
return &master_pb.Heartbeat{
Ip: s.Ip,
diff --git a/weed/storage/store_ec.go b/weed/storage/store_ec.go
index fb7735263..d5e361041 100644
--- a/weed/storage/store_ec.go
+++ b/weed/storage/store_ec.go
@@ -12,6 +12,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
+ "github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
"github.com/klauspost/reedsolomon"
@@ -19,14 +20,21 @@ import (
func (s *Store) CollectErasureCodingHeartbeat() *master_pb.Heartbeat {
var ecShardMessages []*master_pb.VolumeEcShardInformationMessage
+ var totalEcShardSize int64
for _, location := range s.Locations {
location.ecVolumesLock.RLock()
for _, ecShards := range location.ecVolumes {
ecShardMessages = append(ecShardMessages, ecShards.ToVolumeEcShardInformationMessage()...)
+
+ for _, ecShard := range ecShards.Shards {
+ totalEcShardSize += ecShard.Size()
+ }
}
location.ecVolumesLock.RUnlock()
}
+ stats.VolumeServerEcShardSizeGauge.Set(float64(totalEcShardSize))
+
return &master_pb.Heartbeat{
EcShards: ecShardMessages,
HasNoEcShards: len(ecShardMessages) == 0,