Module: check_mk
Branch: master
Commit: 8a9d6e2e64542528fd3d703dfa879b721d6b97b3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8a9d6e2e645425…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jul 4 15:46:46 2018 +0200
6304 FIX sap_hana_filesystem, sap_hana_mem: Fixed wrong conversion of filesystem and
memory values
In order to get correct calculated values in the service details
and graphs you have to install the latest {{mk_sap_hana}} agent plugin.
The plugin now sends values in bytes and the check plugin can handle them
correctly.
Before the plugin reports these values as GB which were rounded to two
decimal places. In turn the check plugin converts these values to
bytes, applies parameters and finally converts them to a user friendly
format. This whole process may produce unprecise results.
Change-Id: Id4564477e3ffbe37f9b6c233a78bc18d4db42646
---
.werks/6304 | 20 ++++++++++++++++++++
agents/plugins/mk_sap_hana | 6 +++---
checks/sap_hana_filesystem | 4 ++--
checks/sap_hana_mem | 6 +++---
4 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/.werks/6304 b/.werks/6304
new file mode 100644
index 0000000..134847e
--- /dev/null
+++ b/.werks/6304
@@ -0,0 +1,20 @@
+Title: sap_hana_filesystem, sap_hana_mem: Fixed wrong conversion of filesystem and memory
values
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cre
+Version: 1.6.0i1
+Date: 1530711398
+Class: fix
+
+In order to get correct calculated values in the service details
+and graphs you have to install the latest {{mk_sap_hana}} agent plugin.
+The plugin now sends values in bytes and the check plugin can handle them
+correctly.
+
+Before the plugin reports these values as GB which were rounded to two
+decimal places. In turn the check plugin converts these values to
+bytes, applies parameters and finally converts them to a user friendly
+format. This whole process may produce unprecise results.
+
+
diff --git a/agents/plugins/mk_sap_hana b/agents/plugins/mk_sap_hana
index da945b3..acee074 100755
--- a/agents/plugins/mk_sap_hana
+++ b/agents/plugins/mk_sap_hana
@@ -101,9 +101,9 @@ function sap_hana_mem () {
echo "<<<sap_hana_mem:sep(44)>>>"
echo "[[[$sidadm_short]]]"
echo "[[[resident]]]"
- sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "SELECT HOST,
ROUND(SUM(PHYSICAL_MEMORY_SIZE/1024/1024/1024),2) FROM M_SERVICE_MEMORY GROUP BY
HOST;"
+ sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "SELECT HOST,
SUM(PHYSICAL_MEMORY_SIZE) FROM M_SERVICE_MEMORY GROUP BY HOST;"
echo "[[[database]]]"
- sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "select HOST,
round(INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE/(1024*1024*1024), 2),
round(ALLOCATION_LIMIT/(1024*1024*1024), 2), ROUND((USED_PHYSICAL_MEMORY +
FREE_PHYSICAL_MEMORY)/1024/1024/1024,2) from M_HOST_RESOURCE_UTILIZATION;"
+ sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "select HOST,
INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE, ALLOCATION_LIMIT, USED_PHYSICAL_MEMORY +
FREE_PHYSICAL_MEMORY from M_HOST_RESOURCE_UTILIZATION;"
}
@@ -116,7 +116,7 @@ function sap_hana_filesystem () {
local sidadm_short=$5
echo "<<<sap_hana_filesystem:sep(44)>>>"
echo "[[[$sidadm_short]]]"
- sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "select D1.HOST,
D1.USAGE_TYPE, ROUND(D2.USED_SIZE/1024/1024/1024,2),ROUND(D1.TOTAL_SIZE/1024/1024/1024,2)
FROM M_DISKS AS D1 INNER JOIN M_DISK_USAGE AS D2 ON D1.USAGE_TYPE = D2.USAGE_TYPE;"
+ sudo -i -u "${sidadm}" hdbsql -n localhost -i "${inst_nr}" -u
"${db_user}" -p "${db_password}" -j -a -x "select D1.HOST,
D1.USAGE_TYPE, D2.USED_SIZE, D1.TOTAL_SIZE FROM M_DISKS AS D1 INNER JOIN M_DISK_USAGE AS
D2 ON D1.USAGE_TYPE = D2.USAGE_TYPE;"
}
diff --git a/checks/sap_hana_filesystem b/checks/sap_hana_filesystem
index 45ca658..8bf864a 100644
--- a/checks/sap_hana_filesystem
+++ b/checks/sap_hana_filesystem
@@ -33,8 +33,8 @@ def parse_sap_hana_filesystem(info):
instance = line[0][3:-3]
continue
name, disk_type, used, size = [x.replace('"', '').strip()
for x in line]
- used_mb = float(used)
- size_mb = float(size)
+ used_mb = int(used) / (1024**2)
+ size_mb = int(size) / (1024**2)
avail_mb = size_mb - used_mb
itemname = ("%s %s %s" % (instance, name, disk_type)).strip()
parsed.append((itemname, size_mb, avail_mb, 0))
diff --git a/checks/sap_hana_mem b/checks/sap_hana_mem
index 9cdcaf6..06d2188 100644
--- a/checks/sap_hana_mem
+++ b/checks/sap_hana_mem
@@ -46,13 +46,13 @@ def parse_sap_hana_mem(info):
line = [x.replace('"', '').strip() for x in line]
inst_data = pparsed.setdefault("%s %s" % (instance, line[0]), {})
- # all memory values in MB
+ # all memory values in bytes
if section == 'resident':
# used
- data = float(line[1]) * 1024**2
+ data = int(line[1])
elif section == 'database':
# used, max, resident_max
- data = map(lambda x: float(x) * 1024**2, line[1:])
+ data = map(int, line[1:])
else:
continue
inst_data.setdefault(section, data)