added number of services in cache for stats

This commit is contained in:
Adolfo Gómez García 2021-05-17 12:41:35 +02:00
parent 1b4060a727
commit 13ec1877de
2 changed files with 7 additions and 2 deletions

View File

@ -47,8 +47,8 @@ CounterClass = typing.TypeVar('CounterClass', Provider, Service, ServicePool, Au
# Posible counters, note that not all are used by every posible type
# FIRST_COUNTER_TYPE, LAST_COUNTER_TYPE are just a placeholder for sanity checks
(
CT_LOAD, CT_STORAGE, CT_ASSIGNED, CT_INUSE, CT_AUTH_USERS, CT_AUTH_USERS_WITH_SERVICES, CT_AUTH_SERVICES
) = range(7)
CT_LOAD, CT_STORAGE, CT_ASSIGNED, CT_INUSE, CT_AUTH_USERS, CT_AUTH_USERS_WITH_SERVICES, CT_AUTH_SERVICES, CT_CACHED
) = range(8)
__caRead: typing.Dict = {}
__caWrite: typing.Dict = {}

View File

@ -63,8 +63,13 @@ class DeployedServiceStatsCollector(Job):
)
assigned = fltr.count()
inUse = fltr.filter(in_use=True).count()
# Cached user services
cached = servicePool.cachedUserServices().exclude(
state__in=State.INFO_STATES
).count()
counters.addCounter(servicePool, counters.CT_ASSIGNED, assigned)
counters.addCounter(servicePool, counters.CT_INUSE, inUse)
counters.addCounter(servicePool, counters.CT_CACHED, cached)
except Exception:
logger.exception(
'Getting counters for service pool %s', servicePool.name