-
Notifications
You must be signed in to change notification settings - Fork 7
/
collector.go
419 lines (377 loc) · 19 KB
/
collector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"gitlab.com/NebulousLabs/Sia/modules"
"gitlab.com/NebulousLabs/Sia/node/api"
sia "gitlab.com/NebulousLabs/Sia/node/api/client"
"gitlab.com/NebulousLabs/errors"
)
var (
// ErrAPICallNotRecognized is returned by API client calls made to modules that
// are not yet loaded.
ErrAPICallNotRecognized = errors.New("API call not recognized")
// Define the metrics we wish to expose
// Renter Metrics
renterModuleLoaded = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_module_loaded", Help: "Is the renter module loaded. 0=not loaded. 1=loaded"})
renterAggregateNumFiles = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_aggregate_num_files", Help: "Shows the number of files uploaded to Sia by the renter"})
renterAggregateNumStuckChunks = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_aggregate_num_stuck_chunks", Help: "The aggregate number of stuck chunks"})
renterAggregateSize = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_aggregate_size", Help: "The aggregate size of data stored on Sia"})
renterMaxHealth = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_max_health", Help: "The max health"})
renterMaxHealthAggregatedPercentage = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_max_health_aggregated_percentage", Help: "The max health aggregated in percentage"})
renterMinRedundancy = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_min_redundancy", Help: "The min redundancy"})
renterMinRedundancyAggregated = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_min_redundancy_aggregated", Help: "The min redundancy aggregated"})
renterRateLimitDownload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_rate_limit_download", Help: "renter download ratelimit (bytes-per-second)"})
renterRateLimitUpload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_rate_limit_upload", Help: "renter upload ratelimit (bytes-per-second)"})
// Contracts
renterNumActiveContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_active_contracts", Help: "Number of active contracts"})
renterNumDisabledContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_disabled_contracts", Help: "Number of disabled contracts"})
renterNumRefreshedContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_refreshed_contracts", Help: "Number of refreshed contracts"})
renterNumPassiveContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_passive_contracts", Help: "Number of passive contracts"})
renterNumExpiredContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_expired_contracts", Help: "Number of expired contracts"})
renterNumExpiredRefreshedContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_num_expired_refreshed_contracts", Help: "Number of expired refreshed contracts"})
// Allowance
renterAllowanceAmount = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_amount", Help: "Renter allowance Amount (siacoins)"})
renterAllowancePeriod = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_period", Help: "Renter allowance period length (blocks)"})
renterAllowanceRenewWindow = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_renew_window", Help: "Renter allowance renew window (blocks)"})
renterAllowanceHosts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_hosts", Help: "Renter allowance hosts"})
renterAllowanceCurrentSpent = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_spent", Help: "Amount of allowance in Siacoins spent in the current period"})
renterAllowanceCurrentUnspent = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_unspent", Help: "Unspent amount of allowance in Siacoins in the current period"})
renterAllowanceCurrentStorage = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_storage", Help: "Amount of allowance in Siacoins spent in the current period on storage"})
renterAllowanceCurrentUpload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_upload", Help: "Amount of allowance in Siacoins spent in the current period on upload bandwidth"})
renterAllowanceCurrentDownload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_download", Help: "Amount of allowance in Siacoins spent in the current period on download bandwidth"})
renterAllowanceCurrentFees = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_fees", Help: "Amount of allowance in Siacoins spent in the current period on fees"})
renterAllowanceCurrentUnspentAllocated = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_unspent_allocated", Help: "Amount of allocated unspent allowance in Siacoins"})
renterAllowanceCurrentUnspentUnallocated = promauto.NewGauge(prometheus.GaugeOpts{
Name: "renter_allowance_current_unspent_unallocated", Help: "Amount of unallocated unspent allowance in Siacoins"})
// Consensus Metrics
consensusModuleLoaded = promauto.NewGauge(prometheus.GaugeOpts{
Name: "consensus_module_loaded", Help: "Is the consensus module loaded. 0=not loaded. 1=loaded"})
consensusSynced = promauto.NewGauge(prometheus.GaugeOpts{
Name: "consensus_synced", Help: "Consensus sync status, 0=not synced. 1=synced"})
consensusHeight = promauto.NewGauge(prometheus.GaugeOpts{
Name: "consensus_height", Help: "Consensus block height"})
consensusDifficulty = promauto.NewGauge(prometheus.GaugeOpts{
Name: "consensus_difficulty", Help: "Consensus difficulty"})
// Daemon Metrics
// daemonAggregateNumAlerts = promauto.NewGauge(prometheus.GaugeOpts{
// Name: "daemon_aggregate_num_alerts", Help: "Total number of daemon Alerts"})
daemonRateLimitDownload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "global_rate_limit_download", Help: "global download ratelimit (bytes-per-second)"})
daemonRateLimitUpload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "global_rate_limit_upload", Help: "global upload ratelimit (bytes-per-second)"})
// Wallet Metrics
walletModuleLoaded = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_module_loaded", Help: "Is the wallet module loaded. 0=not loaded. 1=loaded"})
walletLocked = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_locked", Help: "Is the wallet locked. 0=not locked. 1=locked"})
walletConfirmedSiacoinBalanceHastings = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_confirmed_siacoin_balance_hastings", Help: "Wallet confirmed Siacoin balance (Hastings)"})
walletConfirmedSiacoinBalance = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_confirmed_siacoin_balance", Help: "Wallet confirmed Siacoin balance (Siacoins)"})
walletSiafundBalance = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_siafund_balance", Help: "Wallet Siafund balance"})
walletSiafundClaimBalance = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_siafund_claim_balance", Help: "Wallet Siafund claim balance"})
walletNumAddresses = promauto.NewGauge(prometheus.GaugeOpts{
Name: "wallet_num_addresses", Help: "Number of wallet addresses being tracked by Sia"})
// Gateway Metrics
gatewayModuleLoaded = promauto.NewGauge(prometheus.GaugeOpts{
Name: "gateway_module_loaded", Help: "Is the gateway module loaded. 0=not loaded. 1=loaded"})
gatewayNumPeers = promauto.NewGauge(prometheus.GaugeOpts{
Name: "gateway_num_peers", Help: "gateway number of peers"})
gatewayRateLimitDownload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "gateway_rate_limit_download", Help: "gateway download ratelimit (bytes-per-second)"})
gatewayRateLimitUpload = promauto.NewGauge(prometheus.GaugeOpts{
Name: "gateway_rate_limit_upload", Help: "gateway upload ratelimit (bytes-per-second)"})
// Hostdb Metrics
hostdbNumAllHosts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "hostdb_num_all_hosts", Help: "Total number of hosts in hostdb"})
hostdbNumActiveHosts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "hostdb_num_active_hosts", Help: "Number of active hosts in hostdb"})
hostdbNumInactiveHosts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "hostdb_num_inactive_hosts", Help: "Number of inactive hosts in hostdb"})
hostdbNumOfflineHosts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "hostdb_num_offline_hosts", Help: "Number of offline hosts in hostdb"})
// Host Metrics
hostAcceptingContracts = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_accepting_contracts", Help: "Is the host accepting contracts 0=no, 1=yes"})
hostMaxDuration = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_max_duration", Help: "max duration in weeks"})
hostMaxDownloadBatchSize = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_max_download_batch_size", Help: "Max Download Batch Size"})
hostMaxReviseBatchSize = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_max_revise_batch_size", Help: "Max revise Batch Size"})
hostWindowSize = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_window_size", Help: "Window Size in hours"})
hostCollateral = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_collateral", Help: "Host Collateral in Siacoins"})
hostCollateralBudget = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_collateral_budget", Help: "Host Collateral budget in Siacoins"})
hostMaxCollateral = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_max_collateral", Help: "Max collateral per contract"})
hostContractCount = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_contract_count", Help: "number of host contracts"})
hostTotalStorage = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_total_storage", Help: "total amount of storage available on the host in bytes"})
hostRemainingStorage = promauto.NewGauge(prometheus.GaugeOpts{
Name: "host_remaining_storage", Help: "amount of storage remaining on the host in bytes"})
)
const (
moduleNotReadyStatus = "Module not loaded or still starting up"
)
func hostMetrics(sc *sia.Client) {
hg, err := sc.HostGet()
if errors.Contains(err, ErrAPICallNotRecognized) {
// Assume module is not loaded if status command is not recognized.
log.Info("Host module is not loaded")
return
} else if err != nil {
log.Info("Could not fetch host settings")
}
sg, err := sc.HostStorageGet()
if err != nil {
log.Info("Could not fetch storage info")
}
es := hg.ExternalSettings
fm := hg.FinancialMetrics
is := hg.InternalSettings
// nm := hg.NetworkMetrics
// calculate total storage available and remaining
var totalstorage, storageremaining uint64
for _, folder := range sg.Folders {
totalstorage += folder.Capacity
storageremaining += folder.CapacityRemaining
}
// convert price from bytes/block to TB/Month
// price := is.MinStoragePrice.Mul(modules.BlockBytesPerMonthTerabyte)
// calculate total revenue
// totalRevenue := fm.ContractCompensation.
// Add(fm.StorageRevenue).
// Add(fm.DownloadBandwidthRevenue).
// Add(fm.UploadBandwidthRevenue)
// totalPotentialRevenue := fm.PotentialContractCompensation.
// Add(fm.PotentialStorageRevenue).
// Add(fm.PotentialDownloadBandwidthRevenue).
// Add(fm.PotentialUploadBandwidthRevenue)
// Host Internal Settings
hostAcceptingContracts.Set(boolToFloat64(is.AcceptingContracts))
hostTotalStorage.Set(float64(es.TotalStorage))
hostRemainingStorage.Set(float64(es.RemainingStorage))
hostMaxDuration.Set(float64(is.MaxDuration))
hostMaxDownloadBatchSize.Set(float64(is.MaxDownloadBatchSize))
hostMaxReviseBatchSize.Set(float64(is.MaxReviseBatchSize))
hostWindowSize.Set(float64(is.WindowSize / 6))
hostCollateralFloat, _ := is.Collateral.Mul(modules.BlockBytesPerMonthTerabyte).Float64()
hostCollateral.Set(hostCollateralFloat / 1e24)
hostCollateralBudgetFloat, _ := is.CollateralBudget.Float64()
hostCollateralBudget.Set(hostCollateralBudgetFloat / 1e24)
hostMaxCollateralFloat, _ := is.MaxCollateral.Float64()
hostMaxCollateral.Set(hostMaxCollateralFloat / 1e24)
hostContractCount.Set(float64(fm.ContractCount))
}
func renterMetrics(sc *sia.Client) {
// Renter Get Dir Metrics
rg, err := sc.RenterDirGet(modules.RootSiaPath())
if errors.Contains(err, ErrAPICallNotRecognized) {
log.Info("Renter module is not loaded")
renterModuleLoaded.Set(boolToFloat64(false))
return
} else if err != nil {
log.Info("Could not get Renter metrics")
return
}
renterModuleLoaded.Set(boolToFloat64(true))
renterAggregateNumFiles.Set(float64(rg.Directories[0].AggregateNumFiles))
renterAggregateNumStuckChunks.Set(float64(rg.Directories[0].AggregateNumStuckChunks))
renterAggregateSize.Set(float64(rg.Directories[0].AggregateSize))
renterMaxHealth.Set(float64(rg.Directories[0].MaxHealth))
renterMaxHealthAggregatedPercentage.Set(float64(rg.Directories[0].AggregateMaxHealthPercentage))
renterMinRedundancy.Set(float64(rg.Directories[0].MinRedundancy))
renterMinRedundancyAggregated.Set(float64(rg.Directories[0].AggregateMinRedundancy))
// Contract Metrics
rc, err := sc.RenterDisabledContractsGet()
if err != nil {
log.Info("Could not get renter contracts")
}
renterNumActiveContracts.Set(float64(len(rc.ActiveContracts)))
renterNumPassiveContracts.Set(float64(len(rc.PassiveContracts)))
renterNumRefreshedContracts.Set(float64(len(rc.RefreshedContracts)))
renterNumDisabledContracts.Set(float64(len(rc.DisabledContracts)))
rce, err := sc.RenterDisabledContractsGet()
if err != nil {
log.Info("Could not get renter expired contracts")
}
renterNumExpiredContracts.Set(float64(len(rce.ExpiredContracts)))
renterNumExpiredRefreshedContracts.Set(float64(len(rce.ExpiredRefreshedContracts)))
// Allowance Metrics
ra, err := sc.RenterGet()
if err != nil {
log.Info("Could not get renter allowance info")
}
allowance := ra.Settings.Allowance
funds, _ := allowance.Funds.Float64()
renterAllowanceAmount.Set(float64(funds / 1e24))
renterAllowancePeriod.Set(float64(allowance.Period))
renterAllowanceRenewWindow.Set(float64(allowance.RenewWindow))
renterAllowanceHosts.Set(float64(allowance.Hosts))
fm := ra.FinancialMetrics
totalSpent := fm.ContractFees.Add(fm.UploadSpending).Add(fm.DownloadSpending).Add(fm.StorageSpending)
totalSpentFloat, _ := totalSpent.Float64()
renterAllowanceCurrentSpent.Set(totalSpentFloat / 1e24)
storageSpendingFloat, _ := fm.StorageSpending.Float64()
renterAllowanceCurrentStorage.Set(storageSpendingFloat / 1e24)
uploadSpendingFloat, _ := fm.UploadSpending.Float64()
renterAllowanceCurrentUpload.Set(uploadSpendingFloat / 1e24)
downloadSpendingFloat, _ := fm.DownloadSpending.Float64()
renterAllowanceCurrentDownload.Set(downloadSpendingFloat / 1e24)
contractFeesFloat, _ := fm.ContractFees.Float64()
renterAllowanceCurrentFees.Set(contractFeesFloat / 1e24)
unspentFloat, _ := fm.Unspent.Float64()
renterAllowanceCurrentUnspent.Set(unspentFloat / 1e24)
unspentAllocatedFloat, _ := fm.TotalAllocated.Sub(totalSpent).Float64()
renterAllowanceCurrentUnspentAllocated.Set(unspentAllocatedFloat / 1e24)
unspentUnallocatedFloat, _ := fm.Unspent.Sub(fm.TotalAllocated.Sub(totalSpent)).Float64()
renterAllowanceCurrentUnspentUnallocated.Set(unspentUnallocatedFloat / 1e24)
renterRateLimitUpload.Set(float64(ra.Settings.MaxUploadSpeed))
renterRateLimitDownload.Set(float64(ra.Settings.MaxDownloadSpeed))
}
// consensuMetrics retrieves and sets the Prometheus metrics related to the
// consensus module
func consensusMetrics(sc *sia.Client) {
cs, err := sc.ConsensusGet()
if errors.Contains(err, ErrAPICallNotRecognized) {
log.Info("Consensus module is not loaded")
consensusModuleLoaded.Set(boolToFloat64(false))
return
} else if err != nil {
log.Info("Could not get Consensus metrics")
return
}
consensusModuleLoaded.Set(boolToFloat64(true))
consensusSynced.Set(boolToFloat64(cs.Synced))
consensusHeight.Set(float64(cs.Height))
Difficulty, _ := cs.Difficulty.Float64()
consensusDifficulty.Set(Difficulty)
}
// daemonMetrics retrieves and sets the Prometheus metrics related to the
// Sia daemon
func daemonMetrics(sc *sia.Client) {
//al, err := sc.DaemonAlertsGet()
//if err != nil {
// log.Info("Could not get Daemon metrics")
// return
//}
//daemonAggregateNumAlerts.Set(float64(len(al.Alerts)))
// Global Daemon Rate Limits
dg, err := sc.DaemonSettingsGet()
if err != nil {
log.Info("Could not get daemon metrics")
return
}
daemonRateLimitUpload.Set(float64(dg.MaxUploadSpeed))
daemonRateLimitDownload.Set(float64(dg.MaxDownloadSpeed))
}
// walletMetrics retrieves and sets the Prometheus metrics related to the
// Sia wallet
func walletMetrics(sc *sia.Client) {
status, err := sc.WalletGet()
if errors.Contains(err, ErrAPICallNotRecognized) {
log.Info("Wallet module is not loaded")
walletModuleLoaded.Set(boolToFloat64(false))
return
} else if err != nil {
log.Info("Could not get Wallet metrics")
return
}
walletModuleLoaded.Set(boolToFloat64(true))
if !status.Unlocked {
walletLocked.Set(boolToFloat64(false))
}
walletLocked.Set(boolToFloat64(true))
ConfirmedBalance, _ := status.ConfirmedSiacoinBalance.Float64()
walletConfirmedSiacoinBalanceHastings.Set(ConfirmedBalance)
walletConfirmedSiacoinBalance.Set(ConfirmedBalance / 1e24)
SiafundBalance, _ := status.SiafundBalance.Float64()
walletSiafundBalance.Set(SiafundBalance)
SiafundClaimBalance, _ := status.SiacoinClaimBalance.Float64()
walletSiafundClaimBalance.Set(SiafundClaimBalance)
addresses, err := sc.WalletAddressesGet()
if err != nil {
log.Info("Could not get wallet addresses")
}
walletNumAddresses.Set(float64(len(addresses.Addresses)))
}
// gatewayMetrics retrieves and sets the Prometheus metrics related to the
// Sia gateway
func gatewayMetrics(sc *sia.Client) {
gateway, err := sc.GatewayGet()
if errors.Contains(err, ErrAPICallNotRecognized) {
log.Info("Gateway module is not loaded")
gatewayModuleLoaded.Set(boolToFloat64(false))
return
} else if err != nil {
log.Info("Could not get Gateway metrics")
return
}
gatewayModuleLoaded.Set(boolToFloat64(true))
gatewayNumPeers.Set(float64(len(gateway.Peers)))
gatewayRateLimitUpload.Set(float64(gateway.MaxUploadSpeed))
gatewayRateLimitDownload.Set(float64(gateway.MaxDownloadSpeed))
}
// hostdbMetrics retrieves and sets the Prometheus metrics related to the
// Sia hostdb
func hostdbMetrics(sc *sia.Client) {
hostdb, err := sc.HostDbAllGet()
if errors.Contains(err, ErrAPICallNotRecognized) {
log.Info("HostDB module is not loaded")
return
} else if err != nil {
log.Info("Could not get Gateway metrics")
return
}
// Iterate through the hosts and divide by category.
var activeHosts, inactiveHosts, offlineHosts []api.ExtendedHostDBEntry
for _, host := range hostdb.Hosts {
if host.AcceptingContracts && len(host.ScanHistory) > 0 && host.ScanHistory[len(host.ScanHistory)-1].Success {
activeHosts = append(activeHosts, host)
continue
}
if len(host.ScanHistory) > 0 && host.ScanHistory[len(host.ScanHistory)-1].Success {
inactiveHosts = append(inactiveHosts, host)
continue
}
offlineHosts = append(offlineHosts, host)
}
hostdbNumAllHosts.Set(float64(len(hostdb.Hosts)))
hostdbNumActiveHosts.Set(float64(len(activeHosts)))
hostdbNumInactiveHosts.Set(float64(len(inactiveHosts)))
hostdbNumOfflineHosts.Set(float64(len(offlineHosts)))
}