mirror of
https://github.com/DullJZ/s3-balance.git
synced 2026-09-07 08:56:38 +08:00
feat: Add object count tracking and display for S3 buckets.
This commit is contained in:
@@ -32,6 +32,7 @@ type BucketInfo struct {
|
||||
Config config.BucketConfig
|
||||
Client *s3.Client
|
||||
UsedSize int64 // 已使用容量(字节)
|
||||
ObjectCount int64 // 对象数量
|
||||
Available bool // 是否可用(由health监控更新)
|
||||
LastChecked time.Time // 最后检查时间(由health监控更新)
|
||||
mu sync.RWMutex
|
||||
@@ -320,6 +321,13 @@ func (b *BucketInfo) GetUsedSize() int64 {
|
||||
return b.UsedSize
|
||||
}
|
||||
|
||||
// GetObjectCount 获取对象数量
|
||||
func (b *BucketInfo) GetObjectCount() int64 {
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
return b.ObjectCount
|
||||
}
|
||||
|
||||
// UpdateUsedSize 更新已使用容量
|
||||
func (b *BucketInfo) UpdateUsedSize(delta int64) {
|
||||
b.mu.Lock()
|
||||
|
||||
@@ -60,6 +60,7 @@ func (r *MetricsReporter) ReportStats(stats *health.Stats) {
|
||||
if exists {
|
||||
bucket.mu.Lock()
|
||||
bucket.UsedSize = stats.UsedSize
|
||||
bucket.ObjectCount = stats.ObjectCount
|
||||
bucket.mu.Unlock()
|
||||
|
||||
// 更新 Prometheus 指标
|
||||
|
||||
Reference in New Issue
Block a user