cmd/collector: add free_space and database_size

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
Ciro S. Costa 2021-08-03 18:39:11 -04:00
parent 6e7afaebeb
commit c61a0f32d3
3 changed files with 24 additions and 1 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.16
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b
github.com/cirocosta/go-monero v0.0.5-0.20210731140604-e84b32b615af
github.com/cirocosta/go-monero v0.0.5
github.com/go-logr/logr v0.4.0
github.com/go-logr/zapr v0.4.0
github.com/golangci/golangci-lint v1.41.1

2
go.sum
View File

@ -108,6 +108,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cirocosta/go-monero v0.0.5-0.20210731140604-e84b32b615af h1:3KIUbswishjkyOM0rYfprGjMTWh+64VcXMOIQTnRcxE=
github.com/cirocosta/go-monero v0.0.5-0.20210731140604-e84b32b615af/go.mod h1:B62WVZVEggXr+Kg5wKPNgfDw/BGplrgLjk7hJYIR3FU=
github.com/cirocosta/go-monero v0.0.5 h1:HmLexJM3+/YepFXkqhu/WZbqyTyYQS709bqxjqRGzHc=
github.com/cirocosta/go-monero v0.0.5/go.mod h1:B62WVZVEggXr+Kg5wKPNgfDw/BGplrgLjk7hJYIR3FU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=

View File

@ -158,6 +158,27 @@ func (c *OverallCollector) collect() {
prometheus.GaugeValue,
float64(c.info.RPCConnectionsCount),
)
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_database_size_bytes",
"size of the monero database",
nil, nil,
),
prometheus.GaugeValue,
float64(c.info.DatabaseSize),
)
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_free_space_bytes",
"amount of free space in the partition where "+
"monero's database is in",
nil, nil,
),
prometheus.GaugeValue,
float64(c.info.FreeSpace),
)
}
func boolToFloat64(b bool) float64 {