storagenode: monitor available space and bandwidth

Change-Id: I5763597327c5b32982faab8910c136c6c8dc18c5
This commit is contained in:
Jeff Wendling 2020-02-08 17:04:23 -07:00 committed by Egon Elbre
parent ab660ccc80
commit 05a240050e
3 changed files with 9 additions and 3 deletions

2
go.mod
View File

@ -93,7 +93,7 @@ require (
github.com/tidwall/gjson v1.1.3 // indirect
github.com/tidwall/match v0.0.0-20171002075945-1731857f09b1 // indirect
github.com/vivint/infectious v0.0.0-20190108171102-2455b059135b
github.com/zeebo/admission/v2 v2.0.0-20191108235419-c7982d45d29a
github.com/zeebo/admission/v2 v2.0.0
github.com/zeebo/errs v1.2.2
github.com/zeebo/structs v1.0.2
go.uber.org/zap v1.10.0

4
go.sum
View File

@ -451,8 +451,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 h1:SZPG5w7Qxq7bMcMVl6e3Ht2X7f+AAGQdzjkbyOnNNZ8=
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
github.com/zeebo/admission/v2 v2.0.0-20191108235419-c7982d45d29a h1:ycSw8pJ2MFGraixL9hFv5bknnIH7wQZ76S7h/4sLGcI=
github.com/zeebo/admission/v2 v2.0.0-20191108235419-c7982d45d29a/go.mod h1:gSeHGelDHW7Vq6UyJo2boeSt/6Dsnqpisv0i4YZSOyM=
github.com/zeebo/admission/v2 v2.0.0 h1:220NPZzKmyfklysKFO95L7E2Gt5NwlxTWGE14VP8heE=
github.com/zeebo/admission/v2 v2.0.0/go.mod h1:gSeHGelDHW7Vq6UyJo2boeSt/6Dsnqpisv0i4YZSOyM=
github.com/zeebo/assert v0.0.0-20181109011804-10f827ce2ed6 h1:bs7mSHVrLRQHxqWcm0hyez0sA23YuXb8Pwnq5NhyZ8A=
github.com/zeebo/assert v0.0.0-20181109011804-10f827ce2ed6/go.mod h1:yssERNPivllc1yU3BvpjYI5BUW+zglcz6QWqeVRL5t0=
github.com/zeebo/assert v1.0.0 h1:qw3LXzO7lbptWIQ6DsemJIUOoaqyKbgY3M8b8yvlaaY=

View File

@ -186,6 +186,11 @@ func (service *Service) AvailableSpace(ctx context.Context) (_ int64, err error)
return 0, Error.Wrap(err)
}
allocatedSpace := service.allocatedDiskSpace
mon.IntVal("allocated_space").Observe(allocatedSpace)
mon.IntVal("used_space").Observe(usedSpace)
mon.IntVal("available_space").Observe(allocatedSpace - usedSpace)
return allocatedSpace - usedSpace, nil
}
@ -200,6 +205,7 @@ func (service *Service) AvailableBandwidth(ctx context.Context) (_ int64, err er
mon.IntVal("allocated_bandwidth").Observe(allocatedBandwidth) //locked
mon.IntVal("used_bandwidth").Observe(usage) //locked
mon.IntVal("available_bandwidth").Observe(allocatedBandwidth - usage)
return allocatedBandwidth - usage, nil
}