// initOnlineNodesGauge counts all nodes with status Online and initializes the // OnlineNode Gauge with it. It also register a callback with the database to be notified // of nodes going offline. func initOnlineNodesGauge(store data.Nodeinfostore) { OnlineNodes.Set(0.0) for _, status := range store.GetNodeStatusInfos() { if status.Online { OnlineNodes.Inc() } } store.NotifyNodeOffline(decrementOnlineNodes) }
// ProcessStoredValues needs to be called at startup as soon as the data store is // ready. This methods takes care if initializing all Metrics with values based on // the last saved values. func ProcessStoredValues(store data.Nodeinfostore) { TotalNodes.Set(float64(len(store.GetNodeStatusInfos()))) initTotalClientsGauge(store) initTrafficCounter(store) initOnlineNodesGauge(store) }