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 0000000..ccf20a2 Binary files /dev/null and b/rds_licenses-1.0.mkp differ 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" +)