10 changed files with 132 additions and 33 deletions
@ -1,2 +1,17 @@
|
||||
# check_mk-rds_licenses |
||||
Monitor per user RDS licenses usage. |
||||
|
||||
The check for rds licenses usage is based on folowing plugins: |
||||
- rds_licenses_2008.ps1 |
||||
- rds_licenses_2012.ps1 |
||||
- elevate_shell.ps1 |
||||
If the Windows Server is 64 bit version the agent for x64 must be installed. |
||||
|
||||
Install procedure: |
||||
On Windows 2008 Server: copy the rds_licenses_2008.ps1 file in plugins |
||||
directory of check_mk agent folder. |
||||
On Windows 2012 Server: copy the elevate_shell.ps1 into plugins directory |
||||
of check_mk agent folder and the rds_licenses_2012.ps1 into check_mk agent folder. |
||||
The elevate_shell.ps1 will elevate de privileges for running rds_licences_2012.ps1 |
||||
and the user which run check_mk agent must have the rights to "run as |
||||
administrator". |
||||
|
@ -0,0 +1,42 @@
|
||||
# This code was published by Benjamin Armstrong on blogs.msdn.com |
||||
# This script will open an elevated powershell terminal and will run the specified script |
||||
# The script(s) that must be run with elevated privileges must be configured on the last lines |
||||
|
||||
# Get the ID and security principal of the current user account |
||||
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() |
||||
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) |
||||
|
||||
# Get the security principal for the Administrator role |
||||
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator |
||||
|
||||
# Check to see if we are currently running "as Administrator" |
||||
if ($myWindowsPrincipal.IsInRole($adminRole)) |
||||
{ |
||||
# We are running "as Administrator" - so change the title and background color to indicate this |
||||
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)" |
||||
$Host.UI.RawUI.BackgroundColor = "DarkBlue" |
||||
clear-host |
||||
} |
||||
else |
||||
{ |
||||
# We are not running "as Administrator" - so relaunch as administrator |
||||
|
||||
# Create a new process object that starts PowerShell |
||||
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; |
||||
|
||||
# Specify the current script path and name as a parameter |
||||
$newProcess.Arguments = $myInvocation.MyCommand.Definition; |
||||
|
||||
# Indicate that the process should be elevated |
||||
$newProcess.Verb = "runas"; |
||||
|
||||
# Start the new process |
||||
[System.Diagnostics.Process]::Start($newProcess); |
||||
|
||||
# Exit from the current, unelevated, process |
||||
exit |
||||
} |
||||
|
||||
# Run your code that needs to be elevated here |
||||
# Will run rds_licenses script from check_mk directory |
||||
& "C:\Program Files (x86)\check_mk\rds_licenses_2012.ps1" |
@ -0,0 +1,14 @@
|
||||
The check for rds licenses usage is based on folowing plugins: |
||||
- rds_licenses_2008.ps1 |
||||
- rds_licenses_2012.ps1 |
||||
- elevate_shell.ps1 |
||||
If the Windows Server is 64 bit version the agent for x64 must be installed. |
||||
|
||||
Install procedure: |
||||
On Windows 2008 Server: copy the rds_licenses_2008.ps1 file in plugins |
||||
directory of check_mk agent folder. |
||||
On Windows 2012 Server: copy the elevate_shell.ps1 into plugins directory |
||||
of check_mk agent folder and the rds_licenses_2012.ps1 into check_mk agent folder. |
||||
The elevate_shell.ps1 will elevate de privileges for running rds_licences_2012.ps1 |
||||
and the user which run check_mk agent must ghave the rights to "run as |
||||
administrator". |
@ -0,0 +1,17 @@
|
||||
# SpearHead Systems george.mocanu@sphs.ro |
||||
# Check for Windows 2012 Server |
||||
|
||||
Import-Module RemoteDesktopServices |
||||
|
||||
$path = "RDS:\LicenseServer\LicenseKeyPacks\" |
||||
|
||||
Write-Host "<<<rds_licenses>>>" |
||||
foreach($pack in Get-ChildItem $path) |
||||
{ |
||||
$checkName = $pack.Name -replace '\s','' |
||||
$newPath = Join-Path $path $pack |
||||
$total = (Get-Item $newPath\TotalLicenses).CurrentValue |
||||
$usage = (Get-Item $newPath\IssuedLicensesCount).CurrentValue |
||||
Write-Host $checkName " " $total " " $usage |
||||
} |
||||
exit |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue