Skip to content

Commit

Permalink
feat: Monitor document cache
Browse files Browse the repository at this point in the history
#17
Signed-off-by: Ricky Moorhouse <MOORH@uk.ibm.com>
  • Loading branch information
rickymoorhouse committed Oct 31, 2022
1 parent 4f91710 commit bbafc55
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions datapower_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def gather_metrics(self):
self.fetch_data('TCPSummary', 'tcp', '_total')
self.fetch_data('LogTargetStatus', 'logtarget')
self.object_counts()
self.fetch_document_cache_summary()
if self.v5c:
self.fetch_data('WSMAgentStatus', 'wsm')
# Needs statistics enabled:
Expand Down Expand Up @@ -278,6 +279,46 @@ def object_counts(self):
logger.info("Failed to get object count: {} (Check rest-mgmt is enabled and you have network connectivity)".format(e.strerror))


def fetch_document_cache_summary(self, suffix=''):
""" fetch data from a status provider """
if self.v5c:
provider = "DocumentCachingSummary"
key = "XMLManager"
else:
provider = "APIDocumentCachingSummary"
key = "APIGateway"
try:
logger.debug("Retrieving cache summary")
url = "https://{}:{}/mgmt/status/{}/{}".format(
self.ip,
self.port,
self.domain,
provider)
status = requests.get(url,
auth=(self.username, self.password),
verify=False, timeout=1).json()
logger.debug(status)
data = status.get(provider, {})
if type(data) is not list:
data = [data]

for item in data:
try:
name = item[key]['value']
if name in ['webapi', 'webapi-internal', 'apiconnect']:
del item[key]
logger.debug(item)
for key in item:
self.trawler.set_gauge(
'datapower',
"{}.{}.{}{}".format("documentcache", name, key, suffix), item[key],
pod_name=self.name, labels=self.labels)
except KeyError:
logger.warning('Failed to parse response for document cache summary')
logger.info(item)
except requests.exceptions.RequestException as e:
logger.info("{}: {} (Check rest-mgmt is enabled and you have network connectivity)".format(provider, e.strerror))



# https://localhost:5554/mgmt/status/apiconnect/GatewayPeeringStatus
Expand Down

0 comments on commit bbafc55

Please sign in to comment.