Browse Source

Initial commit.

master
George Mocanu 9 years ago
parent
commit
488720de1e
  1. 20
      agents/windows/plugins/rds_licenses.ps1
  2. 25
      checkman/rds_licenses
  3. 51
      checks/rds_licenses
  4. 17
      info
  5. BIN
      rds_licenses-1.0.mkp
  6. 33
      web/plugins/wato/rds_licenses.py

20
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 "<<<rds_licenses>>>"
Write-Host "PerUserLicenses " $total " " $used

25
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.

51
checks/rds_licenses

@ -0,0 +1,51 @@
#!/usr/bin/python
# Author: George Mocanu <george.mocanu@sphs.ro>
# SpearHead Systems
# EXAMPLE DATA FROM:
# fomat: PerUserLicenses 20 15
#
#<<<rds_licenses>>>
#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",
}

17
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'}

BIN
rds_licenses-1.0.mkp

Binary file not shown.

33
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"
)
Loading…
Cancel
Save