Module: check_mk
Branch: master
Commit: 066a6b59e6d9a3dc308c9fb5657119fce0a30768
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=066a6b59e6d9a3…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Feb 18 15:55:51 2016 +0100
#2995 esx_vsphere_licenses: now compatible with esx 6.0
Furthermore, this check now reports the number of keys for each license.
---
.werks/2995 | 10 +++++++++
ChangeLog | 1 +
agents/special/agent_vsphere | 47 +++++++++++++++++++++++++-----------------
checks/esx_vsphere_licenses | 33 +++++++++++++++++++----------
4 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/.werks/2995 b/.werks/2995
new file mode 100644
index 0000000..cf2f865
--- /dev/null
+++ b/.werks/2995
@@ -0,0 +1,10 @@
+Title: esx_vsphere_licenses: now compatible with esx 6.0
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1455807287
+Class: feature
+
+Furthermore, this check now reports the number of keys for each license.
+
diff --git a/ChangeLog b/ChangeLog
index e141031..b9cf1f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
* 3184 varnish, varnish.backend, varnish.backend_success_ratio, varnish.cache,
varnish.cache_hit_ratio, varnish.client, varnish.esi, varnish.fetch, varnish.objects,
varnish.worker, varnish.worker_thread_ratio: new checks which monitor HTTP Accelerator
Statistics via varnishstat on Linux
* 2994 brocade.temp: increased temperature default levels from 35/40 to 55/60
* 3078 mssql_transactionlogs: new check to monitor the size of mssql transaction
logs
+ * 2995 esx_vsphere_licenses: now compatible with esx 6.0...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index 201b4de..2a32224 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -31,6 +31,7 @@
# reduces the CPU load for this agent
import httplib, pprint, sys, os, getopt, socket, time, datetime, re
+from xml.dom import minidom
# Great article how to get additional information
#
http://www.veeam.com/kb1007
@@ -133,9 +134,22 @@ telegram_list = {
'<ns1:path>vm</ns1:path><ns1:skip>false</ns1:skip></ns1:selectSet>'\
'</ns1:objectSet></ns1:specSet><ns1:options></ns1:options></ns1:RetrievePropertiesEx>',
- "licenseassigned":
- '<ns1:QueryAssignedLicenses
xsi:type="ns1:QueryAssignedLicensesRequestType">'\
- '<ns1:_this
type="LicenseAssignmentManager">LicenseAssignmentManager</ns1:_this></ns1:QueryAssignedLicenses>',
+ "licensesused": """
+ <ns1:RetrievePropertiesEx
xsi:type="ns1:RetrievePropertiesExRequestType">
+ <ns1:_this
type="PropertyCollector">%(propertyCollector)s</ns1:_this>
+ <ns1:specSet>
+ <ns1:propSet>
+ <ns1:type>LicenseManager</ns1:type>
+ <all>0</all>
+ <ns1:pathSet>licenses</ns1:pathSet>
+ </ns1:propSet>
+ <ns1:objectSet>
+ <ns1:obj
type="LicenseManager">%(licenseManager)s</ns1:obj>
+ </ns1:objectSet>
+ </ns1:specSet>
+ <ns1:options/>
+ </ns1:RetrievePropertiesEx>
+ """,
"perfcountersummary":
'<ns1:QueryPerfProviderSummary
xsi:type="ns1:QueryPerfProviderSummaryRequestType">'\
@@ -1198,24 +1212,19 @@ if not error:
# Licenses
###########################
if "licenses" in query_objects:
- reply_code, reply_msg, reply_headers, licenses_response =
query_server(telegram_list["licenseassigned"])
- license_hosts =
get_pattern('<returnval>(.*?)</returnval>', licenses_response)
- licenses = {}
- for host in license_hosts:
- license_info =
get_pattern("<licenseKey>(.*?)</licenseKey>.*?<name>(.*?)</name><total>(.*?)</total><used>(.*?)</used>",
host)
- if not license_info:
- continue
- key, name, total, used = license_info[0]
- # We merge all entries with the same name, duplicate keys are ignored
since they provide the same data
- licenses.setdefault(name, {"used_keys": [],
"total": 0, "used": 0})
- if key not in licenses[name]["used_keys"]:
- licenses[name]["total"] += int(total)
- licenses[name]["used"] += int(used)
- licenses[name]["used_keys"].append(key)
+ reply_code, reply_msg, reply_headers, licenses_response =
query_server(telegram_list["licensesused"])
output("<<<esx_vsphere_licenses:sep(9)>>>")
- for license, values in licenses.items():
- output("%s\t%s %s" % (license, values["used"],
values["total"]))
+ root_node = minidom.parseString(licenses_response)
+ licenses_node =
root_node.getElementsByTagName("LicenseManagerLicenseInfo")
+ for license_node in licenses_node:
+ total =
license_node.getElementsByTagName("total")[0].firstChild.data
+ if total == "0":
+ continue
+ name =
license_node.getElementsByTagName("name")[0].firstChild.data
+ used =
license_node.getElementsByTagName("used")[0].firstChild.data
+ output("%s\t%s %s" % (name, used, total))
+
###########################
# Datastores
diff --git a/checks/esx_vsphere_licenses b/checks/esx_vsphere_licenses
index 81ca094..58e4177 100644
--- a/checks/esx_vsphere_licenses
+++ b/checks/esx_vsphere_licenses
@@ -28,24 +28,35 @@
#esx_vsphere_licenses:sep(9)>>>
#VMware vSphere 5 Standard 100 130
#VMware vSphere 5 Enterprise 86 114
+#VMware vSphere 5 Enterprise 22 44 # Licenses may appear multiple times (keys different)
#vCenter Server 5 Standard 1 1
-def inventory_esx_vsphere_licenses(info):
- return [ (line[0], None) for line in info ]
+def parse_esx_vsphere_licenses(info):
+ parsed = {}
+ for line in info:
+ name, values = line
+ parsed.setdefault(name, {"used": 0, "total": 0,
"keys": 0})
+ used, total = values.split()
+ parsed[name]["used"] += int(used)
+ parsed[name]["total"] += int(total)
+ parsed[name]["keys"] += 1
+ return parsed
-def check_esx_vsphere_licenses(item, params, info):
- # Transform: VMware vSphere 5 Standard 100 13
- # Into dict: 'VMware vSphere 5 Standard': (100, 130)
- licenses = dict(map(
- lambda x: (x[0], tuple(map(lambda y: int(y), x[1].split()))),
- info))
- if item not in licenses:
+def inventory_esx_vsphere_licenses(parsed):
+ return [(key, None) for key in parsed.keys()]
+
+def check_esx_vsphere_licenses(item, params, parsed):
+ license = parsed.get(item)
+ if not license:
return 3, "License not found in agent output"
- used, have = licenses[item]
- return license_check_levels(have, used, params)
+ status, infotext, perfdata = license_check_levels(license["total"],
license["used"], params)
+ infotext = "%s Key(s), " % license["keys"] + infotext
+ return status, infotext, perfdata
+
check_info['esx_vsphere_licenses'] = {
+ "parse_function" : parse_esx_vsphere_licenses,
"inventory_function" : inventory_esx_vsphere_licenses,
"check_function" : check_esx_vsphere_licenses,
"service_description" : "License %s",