Module: check_mk
Branch: master
Commit: e20a1493dcaa45a9c4d53e656d8e3ef8eff022be
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e20a1493dcaa45…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Sep 22 16:32:55 2014 +0200
#1117 agent_vsphere: now able to query license information from esx system
The agent_vsphere is now able to get the license usage from the LicenseManager instance.
Upon inventory each license will lead to an own check name esx_licenses.
The check parameters (absolute used, percentage used, all used) can be configured via the
WATO rule
<tt>Number of used VMware licenses</tt>
---
.werks/1117 | 12 +++++++
ChangeLog | 3 +-
agents/special/agent_vsphere | 53 ++++++++++++++++++++++---------
checks/citrix_licenses | 29 ++---------------
web/plugins/wato/check_parameters.py | 28 ++++++++++++----
web/plugins/wato/datasource_programs.py | 1 +
6 files changed, 77 insertions(+), 49 deletions(-)
diff --git a/.werks/1117 b/.werks/1117
new file mode 100644
index 0000000..5e1a9b4
--- /dev/null
+++ b/.werks/1117
@@ -0,0 +1,12 @@
+Title: agent_vsphere: now able to query license information from esx system
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411396124
+Class: feature
+
+The agent_vsphere is now able to get the license usage from the LicenseManager instance.
+Upon inventory each license will lead to an own check name esx_licenses.
+The check parameters (absolute used, percentage used, all used) can be configured via the
WATO rule
+<tt>Number of used VMware licenses</tt>
diff --git a/ChangeLog b/ChangeLog
index a9cc965..657b134 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,8 +60,10 @@
* 1111 vCenter monitoring: greatly improved performance (at least 40 times
faster)...
* 1112 esx_vsphere_hostsystem.mem_usage_cluster: allows to monitor total RAM usage of
all nodes in a cluster...
* 0658 brocade_info: new check to retrieve informational data about Brocade switches
+ * 1385 oracle_instance: new WATO rules for archivelog, logging, login and uptime...
* 1403 kernel.util: allow levels for the total CPU utilization...
NOTE: Please refer to the migration notes!
+ * 1117 agent_vsphere: now able to query license information from esx system...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
@@ -148,7 +150,6 @@
check:
* 1384 oracle_jobs: new WATO rules, changed service name to SID.OWNER.NAME...
NOTE: Please refer to the migration notes!
- * 1385 oracle_instance: WATO rules for archivelog, logging, login and uptime
1.2.5i5:
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index 97fd671..80cea63 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -130,6 +130,10 @@ 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>',
+
"perfcountersummary":
'<ns1:QueryPerfProviderSummary
xsi:type="ns1:QueryPerfProviderSummaryRequestType">'\
'<ns1:_this
type="PerformanceManager">%(perfManager)</ns1:_this>'\
@@ -423,7 +427,7 @@ host_address = None
user = None
secret = None
tracefile = None
-query_objects = [ 'hostsystem', 'virtualmachine', 'datastore',
'counters' ]
+query_objects = [ 'hostsystem', 'virtualmachine', 'datastore',
'counters', 'licenses' ]
try:
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
@@ -523,13 +527,17 @@ def get_agent_info_tcp(hostname):
# Globals of ESX System. These settings are available after the first
"systeminfo" query
-systeminfo = {
- "apiVersion" : None,
- "name" : None,
- "rootFolder" : None,
- "perfManager" : None,
- "sessionManager" : None,
-}
+systemfields = [
+ ("apiVersion", float),
+ ("name", None),
+ ("rootFolder", None),
+ ("perfManager", None),
+ ("sessionManager", None),
+ ("licenseManager", None),
+ ("propertyCollector", None)
+]
+
+systeminfo = {}
if opt_tracefile:
tracefile_dir = os.path.dirname(opt_tracefile) or "."
@@ -632,12 +640,7 @@ try:
reply_code, reply_msg, reply_headers, reply_data = query_server(payload)
if name == "systeminfo":
- for entry, function in [ ("name", None),
- ("apiVersion", float),
- ("rootFolder", None),
- ("propertyCollector", None),
- ("sessionManager", None),
- ("perfManager", None) ]:
+ for entry, function in systemfields:
element =
get_pattern("<%(entry)s.*>(.*)</%(entry)s>" % { "entry":
entry }, reply_data)
systeminfo[entry] = function and function(element[0]) or element[0]
elif name == "login":
@@ -645,6 +648,7 @@ try:
if "InvalidLogin" in reply_data:
raise Exception("Login response is not 'OK'. Please check
the credentials")
+
except Exception, e:
if opt_debug:
raise
@@ -662,6 +666,25 @@ if not error:
print "Version: %.1f" % systeminfo["apiVersion"]
print "AgentOs: %s" % systeminfo["name"]
+ ###########################
+ # Licenses
+ ###########################
+ 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:
+ key, name, total, used =
get_pattern("<licenseKey>(.*?)</licenseKey>.*?<name>(.*?)</name><total>(.*?)</total><used>(.*?)</used>",
host)[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)
+
+ print "<<<esx_vsphere_licenses:sep(9)>>>"
+ for license, values in licenses.items():
+ print "%s\t%s %s" % (license, values["used"],
values["total"])
+
#############################
# Determine available host systems
#############################
@@ -670,10 +693,10 @@ if not error:
reply_code, reply_msg, reply_headers, hostsystems_response =
query_server(telegram_list["hostsystems"])
elements = get_pattern('<obj
type="HostSystem">(.*?)</obj>.*?<val
xsi:type="xsd:string">(.*?)</val>', hostsystems_response)
-
for hostsystem, name in elements:
hostsystems[hostsystem] = name
+
###########################
# Datastores
###########################
diff --git a/checks/citrix_licenses b/checks/citrix_licenses
index 7188edc..62d6e08 100644
--- a/checks/citrix_licenses
+++ b/checks/citrix_licenses
@@ -51,33 +51,7 @@ def check_citrix_licenses(item, params, info):
if not have:
return 3, "No licenses of that type found"
- if params == None:
- warn = have
- crit = have
- elif type(params[0]) == int:
- warn = max(0, have - params[0])
- crit = max(0, have - params[1])
- else:
- warn = have * (1 - params[0]/100)
- crit = have * (1 - params[1]/100)
-
- perfdata = [ ( "licenses", used, warn, crit, 0, have )]
- if used <= have:
- infotext = "used %d out of %d licenses" % (used, have)
- else:
- infotext = "used %d licenses, but you have only %d" % (used, have)
-
- if used >= have:
- status = 2
- elif used >= warn:
- status = 1
- else:
- status = 0
-
- if status:
- infotext += " (levels at %d/%d)" % (warn, crit)
-
- return status, infotext, perfdata
+ return license_check_levels(have, used, params)
check_info["citrix_licenses"] = {
'check_function' : check_citrix_licenses,
@@ -85,4 +59,5 @@ check_info["citrix_licenses"] = {
'service_description' : 'Citrix Licenses %s',
'has_perfdata' : True,
'group' : "citrix_licenses",
+ 'includes' : [ "license.include" ]
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 265975d..da1c3dd 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -5990,11 +5990,8 @@ register_check_parameters(
"first"
)
-register_check_parameters(
- subgroup_applications,
- "citrix_licenses",
- _("Number of used Citrix licenses"),
- Alternative(
+
+vs_license = Alternative(
style = "dropdown",
default_value = None,
elements = [
@@ -6017,8 +6014,27 @@ register_check_parameters(
totext = _("critical if all are used"),
title = _("Go critical if all licenses are used"),
),
- ]
+ ]
+ )
+
+register_check_parameters(
+ subgroup_applications,
+ "esx_licenses",
+ _("Number of used VMware licenses"),
+ vs_license,
+ TextAscii(
+ title = _("Name of the license"),
+ help = _("For example <tt>VMware vSphere 5
Standard</tt>"),
+ allow_empty = False,
),
+ "dict"
+)
+
+register_check_parameters(
+ subgroup_applications,
+ "citrix_licenses",
+ _("Number of used Citrix licenses"),
+ vs_license,
TextAscii(
title = _("ID of the license, e.g. <tt>PVSD_STD_CCS</tt>"),
allow_empty = False,
diff --git a/web/plugins/wato/datasource_programs.py
b/web/plugins/wato/datasource_programs.py
index c30483a..00538f0 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -89,6 +89,7 @@ register_rule(group,
( "virtualmachine", _("Virtual
Machines") ),
( "datastore", _("Datastores") ),
( "counters", _("Performance
Counters") ),
+ ( "licenses", _("License Usage")
),
],
default_value = [ "hostsystem",
"virtualmachine", "datastore", "counters" ],
allow_empty = False,