Module: check_mk
Branch: master
Commit: 7d7503a9963d9b1bfcb9ad5115c52d41f1204814
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7d7503a9963d9b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 8 14:35:00 2014 +0100
#1711 FIX win_printers.ps1: ignore temporary printers created by RDP terminal sessions
Thanks to Ruben Bosch.
---
.werks/1711 | 9 +++++++++
ChangeLog | 1 +
agents/windows/plugins/win_printers.ps1 | 21 +++++++++++----------
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/.werks/1711 b/.werks/1711
new file mode 100644
index 0000000..f02f219
--- /dev/null
+++ b/.werks/1711
@@ -0,0 +1,9 @@
+Title: win_printers.ps1: ignore temporary printers created by RDP terminal sessions
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1418045670
+Class: fix
+
+Thanks to Ruben Bosch.
diff --git a/ChangeLog b/ChangeLog
index 7f1614a..3b8444f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -127,6 +127,7 @@
* 1658 FIX: agent_vsphere: no longer crashes when decommissioned vms report no
hardware information...
* 1708 FIX: cups_queues: fix outputting of current printer jobs if printer daemon is
CUPS...
* 1710 FIX: omd_status: Fix totally missing section in Linux agent...
+ * 1711 FIX: win_printers.ps1: ignore temporary printers created by RDP terminal
sessions...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/windows/plugins/win_printers.ps1
b/agents/windows/plugins/win_printers.ps1
index 2e8cd0f..3213c62 100644
--- a/agents/windows/plugins/win_printers.ps1
+++ b/agents/windows/plugins/win_printers.ps1
@@ -1,5 +1,5 @@
####
-#
+#
#
http://blogs.msdn.com/b/powershell/archive/2012/07/13/join-object.aspx
#
####
@@ -20,6 +20,7 @@ $pswindow.buffersize = $newsize
Write-Host -NoNewLine "<<<win_printers>>>"
$Data_Set1 = Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue | Select Name,
@{Expression={$_.jobs};Label="CurrentJobs"}
$Data_Set2 = Get-WmiObject win32_printer | select name, printerstatus,
detectederrorstate
+$Data_Set2 = Get-WmiObject win32_printer | ?{$_.PortName -notmatch '^TS'} |
Select name, printerstatus, detectederrorstate
function AddItemProperties($item, $properties, $output)
@@ -34,18 +35,18 @@ function AddItemProperties($item, $properties, $output)
$hashName=$propertyHash["name"] -as [string]
if($hashName -eq $null)
{
- throw "there should be a string Name"
+ throw "there should be a string Name"
}
-
+
$expression=$propertyHash["expression"] -as [scriptblock]
if($expression -eq $null)
{
- throw "there should be a ScriptBlock Expression"
+ throw "there should be a ScriptBlock Expression"
}
-
+
$_=$item
$expressionValue=& $expression
-
+
$output | add-member -MemberType "NoteProperty" -Name $hashName
-Value $expressionValue
}
else
@@ -63,7 +64,7 @@ function AddItemProperties($item, $properties, $output)
}
}
-
+
function WriteJoinObjectOutput($leftItem, $rightItem, $leftProperties, $rightProperties,
$Type)
{
$output = new-object psobject
@@ -158,7 +159,7 @@ function Join-Object
# a list of the matches in right for each object in left
$leftMatchesInRight = new-object System.Collections.ArrayList
- # the count for all matches
+ # the count for all matches
$rightMatchesCount = New-Object "object[]" $Right.Count
for($i=0;$i -lt $Right.Count;$i++)
@@ -205,7 +206,7 @@ function Join-Object
$null = $leftItemMatchesInRight.Add($rightItem)
$rightMatchesCount[$i]++
}
-
+
}
}
@@ -214,7 +215,7 @@ function Join-Object
{
$leftItemMatchesInRight=$leftMatchesInRight[$i]
$leftItem=$left[$i]
-
+
if($leftItemMatchesInRight.Count -eq 0)
{
if($Type -ne "OnlyIfInBoth")