Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve unexpected errors when statuses other than 'running' or 'idle' is received #9428

Merged
merged 8 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions sap_hana/datadog_checks/sap_hana/sap_hana.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from __future__ import division

import traceback
from collections import defaultdict
from contextlib import closing
from itertools import chain
Expand Down Expand Up @@ -97,6 +98,7 @@ def check(self, instance):
continue
except Exception as e:
self.log.error('Unexpected error running `%s`: %s', query_method.__name__, str(e))
self.log.error(traceback.format_exc())
continue
finally:
if self._connection_lost:
Expand Down Expand Up @@ -183,8 +185,9 @@ def query_licenses(self):
self.gauge('license.utilized', utilized, tags=tags, hostname=host)

def query_connection_overview(self):
# https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.02/en-US/20abcf1f75191014a254a82b3d0f66bf.html
db_counts = defaultdict(lambda: {'running': 0, 'idle': 0})
# https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.05/en-US/20abcf1f75191014a254a82b3d0f66bf.html
# Documented statuses: RUNNING, IDLE, QUEUING, EMPTY
db_counts = defaultdict(lambda: defaultdict(int))
for conn in self.iter_rows(queries.GlobalSystemConnectionsStatus):
db_counts[(conn['db_name'], conn['host'], conn['port'])][conn['status'].lower()] += conn['total']

Expand All @@ -196,10 +199,14 @@ def query_connection_overview(self):
host = self.get_hana_hostname(host)
running = counts['running']
idle = counts['idle']
queuing = counts['queuing']
empty = counts['empty']

self.gauge('connection.running', running, tags=tags, hostname=host)
self.gauge('connection.idle', idle, tags=tags, hostname=host)
self.gauge('connection.open', running + idle, tags=tags, hostname=host)
self.gauge('connection.queuing', queuing, tags=tags, hostname=host)
self.gauge('connection.empty', empty, tags=tags, hostname=host)

def query_disk_usage(self):
# https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.02/en-US/a2aac2ee72b341699fa8eb3988d8cecb.html
Expand Down
2 changes: 2 additions & 0 deletions sap_hana/metadata.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ sap_hana.backup.latest,gauge,,second,,The time elapsed since the latest database
sap_hana.connection.idle,gauge,,connection,,The current number of idle connections.,0,sap_hana,
sap_hana.connection.open,gauge,,connection,,The current number of connections.,0,sap_hana,
sap_hana.connection.running,gauge,,connection,,The current number of running connections.,0,sap_hana,
sap_hana.connection.queuing,gauge,,connection,,The current number of queued connections.,0,sap_hana,
sap_hana.connection.empty,gauge,,connection,,Historic connections that are removed after a period of time.,0,sap_hana,
sap_hana.cpu.service.utilized,gauge,,percent,,The CPU utilization of services as a percentage.,0,sap_hana,
sap_hana.disk.free,gauge,,byte,,The total free size of the disk in bytes.,1,sap_hana,
sap_hana.disk.size,gauge,,byte,,The total size of the disk in bytes.,0,sap_hana,
Expand Down
2 changes: 2 additions & 0 deletions sap_hana/tests/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
'sap_hana.connection.idle',
'sap_hana.connection.open',
'sap_hana.connection.running',
'sap_hana.connection.queuing',
'sap_hana.connection.empty',
'sap_hana.cpu.service.utilized',
'sap_hana.disk.free',
'sap_hana.disk.size',
Expand Down