From 488720de1e56859ea45495082d16f4056b03c70e Mon Sep 17 00:00:00 2001 From: George Mocanu Date: Mon, 2 Feb 2015 09:41:00 +0200 Subject: [PATCH] Initial commit. --- agents/windows/plugins/rds_licenses.ps1 | 20 ++++++++++ checkman/rds_licenses | 25 ++++++++++++ checks/rds_licenses | 51 ++++++++++++++++++++++++ info | 17 ++++++++ rds_licenses-1.0.mkp | Bin 0 -> 2274 bytes web/plugins/wato/rds_licenses.py | 33 +++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 agents/windows/plugins/rds_licenses.ps1 create mode 100644 checkman/rds_licenses create mode 100644 checks/rds_licenses create mode 100644 info create mode 100644 rds_licenses-1.0.mkp create mode 100644 web/plugins/wato/rds_licenses.py diff --git a/agents/windows/plugins/rds_licenses.ps1 b/agents/windows/plugins/rds_licenses.ps1 new file mode 100644 index 0000000..1e62e5b --- /dev/null +++ b/agents/windows/plugins/rds_licenses.ps1 @@ -0,0 +1,20 @@ +# SpearHead Systems george.mocanu@sphs.ro + +Import-Module RemoteDesktopServices +(cd RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports) | out-null + +# Remove all old reports +Remove-Item * -Recurse + +# Generate a new report +(New-Item -Name 'check' -Scope DOM) | out-null + +# Total installed licenses +$total = (Get-Item .\*\W*\InstalledCount).CurrentValue + +# Total used licenses +$used = (Get-Item .\*\W*\IssuedCount).CurrentValue + +# check_mk output +Write-Host "<<>>" +Write-Host "PerUserLicenses " $total " " $used diff --git a/checkman/rds_licenses b/checkman/rds_licenses new file mode 100644 index 0000000..ed985fc --- /dev/null +++ b/checkman/rds_licenses @@ -0,0 +1,25 @@ +title: Check for RDS licenses usage state +agents: windows +catalog: os/windows +license: GPL +distribution: +description: + This check return usage of RDS licenses. + You need to install the plugin {rds_licenses.ps1} + into the {plugins} directory of your windows agent. + This check was tested with Windows 2008 Server + and must have PowerShell installed. On Windows x64 is + recommended to use x64 agent. As always you must set + "set-executionpolicy remotesigned" on monitored host. + + The check gets critical if the usage percentage is above + 90 percents and warning if the usage percentage is above + 80 percents. + Both limits are definable in Wato under "Parameters for + Inventorized Checks", "Applications, Processes & Services". + +inventory: + One service will be created for each host running the plugin. + +perfdata: + Licenses usage. diff --git a/checks/rds_licenses b/checks/rds_licenses new file mode 100644 index 0000000..aee26f7 --- /dev/null +++ b/checks/rds_licenses @@ -0,0 +1,51 @@ +#!/usr/bin/python +# Author: George Mocanu +# SpearHead Systems + +# EXAMPLE DATA FROM: +# fomat: PerUserLicenses 20 15 +# +#<<>> +#PerUserLicenses 20 15 + +factory_settings["rds_licenses_default_values"] = { + "levels": (80, 90), +} + +def inventory_rds_licenses(info): + inventory = [] + for line in info: + checkName = line[0] + inventory.append( (checkName, {} ) ) + return inventory + + +def check_rds_licenses(item, params, info): + if type(params) != dict: + params = { "levels": params } + warn, crit = params["levels"] + for line in info: + if line[0] == item: + total = int(line[1]) + used = int(line[2]) + usedPerc = int(((used*100)/total)) + perfdata = [ ( "usage", usedPerc, warn, crit ) ] + if total != 0: + if usedPerc > crit: + return (2, "License use level: %d percents" %usedPerc, perfdata) + elif usedPerc > warn: + return (1, "License use level: %d percents" %usedPerc, perfdata) + else: + return (0, "License use level: %d percents" %usedPerc, perfdata) + else: + return (0, "No licenses installed") + return(3, "Plugin not running on host") + +check_info["rds_licenses"] = { + "check_function" :check_rds_licenses, + "inventory_function" :inventory_rds_licenses, + "service_description" :"%s", + "default_levels_variable" :"rds_licenses_default_values", + "has_perfdata" :True, + "group" :"rds_licenses", +} diff --git a/info b/info new file mode 100644 index 0000000..f328401 --- /dev/null +++ b/info @@ -0,0 +1,17 @@ +{'author': 'SpearHead Systems george.mocanu@sphs.ro', + 'description': 'Check for RDS licenses usage', + 'download_url': 'https://github.com/spearheadsys/check_mk-rds_licenses/', + 'files': {'agents': ['windows/plugins/rds_licenses.ps1'], + 'checkman': ['rds_licenses'], + 'checks': ['rds_licenses'], + 'doc': [], + 'inventory': [], + 'notifications': [], + 'pnp-templates': [], + 'web': ['plugins/wato/rds_licenses.py']}, + 'name': 'rds_licenses', + 'num_files': 4, + 'title': 'rds_licenses', + 'version': '1.0', + 'version.min_required': '1.2.6b5', + 'version.packaged': '1.2.6b5'} \ No newline at end of file diff --git a/rds_licenses-1.0.mkp b/rds_licenses-1.0.mkp new file mode 100644 index 0000000000000000000000000000000000000000..ccf20a281d6c378940305f87c2f0311522cc8887 GIT binary patch literal 2274 zcmZvcc{me}1BZponXiOUB)LOMj@TrLVw5v%Da2fJ#-tjNvxLl%@J-*5qmkuKlQra8 zTFh+BeZ&sLV$84K|2@z9&*%O3eV&hUrm%2?3ekmsKhiJCJ0#HeE4m!i+qFXBM2E z#RY4ts;}dgLdw0a!Ht1qS*=+vxkZ;ny?zmrZIthvlKF^?6AwHb@wznyf;G@zowxrl zmw<<$n>xP~+DnczB7D@ht#xuqO-+N2^>IKlqu0&k)g#)C_eyS?jZoJ&r{)z_E|Pm7 zN4Xo(@%h3bmzuGL${LrNR|uX(%#bqQVKpj-rzMREpFq5M{fTrsKc~^d4*W&!zUIgS ztI}+Bc{M4l)m!7afRohES9_iOe^>0vc1UjK1(BT^5(wcQ4gclG~neWBDKn>b}D^uP~_H8r_+A=hG}% zW+FX!pT(rmYq-c}I<<0dAN1B@ksi&9C+u=KTmpU42e_K@XT);vRMHvKyR)8S?Tg#Q zyr&zz@a|#;vv2=u+;2NGa`nTUv>2nFqy)B7SE8Ae_!KIhi&x}qrB*6R3J`~R(|Dvf;UO2uK&WgLO3&_l;32|k;J7FQZ4)_i0 z$?|g9{Hy4ZvV?k)6jo=9#Zsh-(*3b1w) zcoZiTakvQm#yaIVdVDD_-F+yiI}gUM#1;3HF|9-`L-7fN1s$mY#LoMsZ_E5UZShXE zMpEkGDJ2`-8J3th2$AK(OVSo_w{`IsN(3WlBKRv**Ktk8SZ6-Dmo-D zY?Mn**Z}AZQm3QzW?G)qU|n#j)}s5;Ve{)2hs;H0PovGZRvaDbGyQFt|B54+ zLMX9BFCp6l(p3`U_X$`(ImS!<=_=NCZ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s&DuDTV`S|_^ Dx|4=2 literal 0 HcmV?d00001 diff --git a/web/plugins/wato/rds_licenses.py b/web/plugins/wato/rds_licenses.py new file mode 100644 index 0000000..27861fa --- /dev/null +++ b/web/plugins/wato/rds_licenses.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# 2015 george.mocanu@sphs.ro +# SpearHead Systems + +register_check_parameters( + subgroup_applications, + "rds_licenses", + _("RDS Licenses Usage Status"), + Dictionary( + elements = [ + ("levels", # Name of your parameters + Tuple( + title = "Levels for RDS Licenses Usage check", # Specify a title for this parameters + elements = [ + Integer( + title = _("Warning if above"), + unit = _("Percent"), + default_value = 80 + ), + Integer( + title = _("Critical if above"), + unit = _("Percent"), + default_value = 90 + ), + ] + ) + ), + ], + optional_keys = None, # Always show this subgroup + ), + TextAscii( title = "Service name"), + "dict" +)