Module: check_mk
Branch: master
Commit: 59663ff22b7966f23459e20891d2d855d7c5914e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=59663ff22b7966…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Mar 3 15:30:07 2015 +0100
The wmic_if.ps1 has been replaced by windows_if.ps1.
The latter one provides the same information as the previous version, but
does additionally report interface teaming information, if applicable.
---
.werks/2053 | 11 +++++
ChangeLog | 1 +
agents/windows/plugins/windows_if.ps1 | 69 ++++++++++++++++++++++++++++++
agents/windows/plugins/wmic_if.ps1 | 75 ---------------------------------
4 files changed, 81 insertions(+), 75 deletions(-)
diff --git a/.werks/2053 b/.werks/2053
new file mode 100644
index 0000000..8d348b1
--- /dev/null
+++ b/.werks/2053
@@ -0,0 +1,11 @@
+Title: New windows plugin: windows_if.ps1, renders wmic_if.ps1 obsolete
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1425392870
+Class: feature
+
+The wmic_if.ps1 has been replaced by windows_if.ps1.
+The latter one provides the same information as the previous version, but
+does additionally report interface teaming information, if applicable.
diff --git a/ChangeLog b/ChangeLog
index a799ab2..99bf3bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -104,6 +104,7 @@
* 1893 cisco_power: Now discovers all power supplies, not only redundant ones...
* 2052 winperf_if: Now able to automatically group teamed interfaces and more...
NOTE: Please refer to the migration notes!
+ * 2053 New windows plugin: windows_if.ps1, renders wmic_if.ps1 obsolete...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/agents/windows/plugins/windows_if.ps1
b/agents/windows/plugins/windows_if.ps1
new file mode 100644
index 0000000..14bdafb
--- /dev/null
+++ b/agents/windows/plugins/windows_if.ps1
@@ -0,0 +1,69 @@
+# runs on windows 2003 or newer
+if ([Environment]::OSVersion.Version.Major -ge "5"){
+ Write-Host "<<<winperf_if:sep(9)>>>"
+}
+
+# runs on windows 2012 or newer
+# [teaming_start]
+# TeamName TeamingMode LoadBalancingAlgorithm MemberMACAddresses
MemberNames MemberDescriptions Speed GUID
+# LAN Lacp Dynamic 5C:F3:FC:37:2A:34;5C:F3:FC:37:2A:30
Ethernet;Ethernet 2 QLogic 1/10GbE Server Adapter #2;QLogic 1/10GbE Server Adapter
10000000000;10000000000
{11477AB1-0A749C-8768-A17F47C02A1F};{2B232067-0EE5-41EE-B498-0CA2FE8715D0}
+# [teaming_end]
+if ((([Environment]::OSVersion.Version.Major -eq "6") -and
([Environment]::OSVersion.Version.Minor -ge "2")) -or
([Environment]::OSVersion.Version.Major -ge "7")){
+ $teams = Get-NetLbfoTeam
+ if ($teams){
+ Write-Host "[teaming_start]"
+ Write-Host
"TeamName`tTeamingMode`tLoadBalancingAlgorithm`tMemberMACAddresses`tMemberNames`tMemberDescriptions`tSpeed`tGUID"
+ foreach ($team in $teams){
+ Write-Host -NoNewline $team.Name`t
+ Write-Host -NoNewline $team.tm`t
+ Write-Host -NoNewline $team.lba`t
+ foreach ($slave in $team.members){
+ $membermacs += (Get-Netadapter $slave).MacAddress + ";"
+ $members += $slave + ";"
+ $netinterface += (Get-Netadapter $slave).InterfaceDescription + ";"
+ $netspeed += [String](Get-Netadapter $slave).Speed + ";"
+ $netguid += (Get-Netadapter $slave).InterfaceGuid + ";"
+ }
+ $membermacs = $membermacs.Replace("-",":")
+ $membermacs = $membermacs.TrimEnd(";") + "`t"
+ Write-Host -NoNewline $membermacs
+ $members = $members.TrimEnd(";") + "`t"
+ Write-Host -NoNewline $members
+ $netinterface = $netinterface.TrimEnd(";") + "`t"
+ Write-Host -NoNewline $netinterface
+ $netspeed = $netspeed.TrimEnd(";") + "`t"
+ Write-Host -NoNewline $netspeed
+ $netguid = $netguid.TrimEnd(";")
+ Write-Host $netguid
+ }
+ Write-Host "[teaming_end]"
+ }
+}
+
+# runs on windows 2003 or newer
+# Node MACAddress Name NetConnectionID NetConnectionStatus Speed GUID
+# NODE01 42:F2:E9:21:BE:D1 IBM USB Remote NDIS Network Device #2 Local Area
Connection 2 2 9728000 {A447D54F-0E4B-40B3-9FBA-228F7DCE8FC7}
+# NODE01 40:F2:E9:21:BE:D2 Intel(R) I350 Gigabit Network Connection
Ethernet 3 7 9223372036854775807 {1C656D16-F30D-4714-9A7E-B3D3F9AD52FA}
+# NODE01 40:F2:E9:21:BE:D3 Intel(R) I350 Gigabit Network Connection #2
Ethernet 4 7 9223372036854775807 {F9C89525-0500-4A6B-95AC-95F66BDA739A}
+# NODE01 40:F2:E9:21:BE:D4 Intel(R) I350 Gigabit Network Connection #3
Ethernet 5 7 9223372036854775807 {A0D28181-6DF8-4A80-9837-D2933D013510}
+# NODE01 40:F2:E9:21:BE:D5 Intel(R) I350 Gigabit Network Connection #4
Ethernet 6 7 9223372036854775807 {95CA2691-7AFA-4842-A769-F521FE6173B2}
+# NODE01 5C:F3:FC:37:2A:30 QLogic 1/10GbE Server Adapter Ethernet 2 2
{2B232067-0EE5-41EE-B498-0CA2FE8715D0}
+# NODE01 5C:F3:FC:37:2A:34 QLogic 1/10GbE Server Adapter Ethernet 2
{11477AB1-0A73-449C-8768-A17F47C02A1F}
+# NODE01 5C:F3:FC:37:2A:30 Microsoft Network Adapter Multiplexor Driver LAN
2 20000000000 {4FCE4C48-6217-465A-B807-B61499AE570C}
+if ([Environment]::OSVersion.Version.Major -ge "5"){
+ Write-Host
"Node`tMACAddress`tName`tNetConnectionID`tNetConnectionStatus`tSpeed`tGUID"
+ foreach ($net in Get-WmiObject Win32_NetworkAdapter)
+ {
+ if ($net.netconnectionid){
+ Write-Host -NoNewline $env:COMPUTERNAME`t
+ Write-Host -NoNewline $net.macaddress`t
+ Write-Host -NoNewline $net.name`t
+ Write-Host -NoNewline $net.netconnectionid`t
+ Write-Host -NoNewline $net.netconnectionstatus`t
+ Write-Host -NoNewline $net.speed`t
+ Write-Host $net.GUID
+ }
+ }
+}
+
+
diff --git a/agents/windows/plugins/wmic_if.ps1 b/agents/windows/plugins/wmic_if.ps1
deleted file mode 100644
index e51da8c..0000000
--- a/agents/windows/plugins/wmic_if.ps1
+++ /dev/null
@@ -1,75 +0,0 @@
-# Note: This plugin should only being used when the plugin wmic_if.bat does
-# deliver insufficient data. For example, teaming interfaces in Win2012
-# are not reported correctly (missing speed) by the wmic_if.bat script.
-#
-# This plugin extends the information reported by the performance counters
-# with the following fields:
-# Nodename
-# MACAddress
-# Interface Name
-# Interface NetConnectionID
-# Interface Driver Desription
-# Connection Status
-# Interface Speed
-
-try
-{
- $teams = Get-NetLbfoTeam
-} catch {}
-
-Function getSpeed($speed_text)
-{
- $value = 0
- $factor = 1
- $speed_tokens = $speed_text.split(" ")
- if ($speed_tokens.length -eq 2) {
- $value = [float]$speed_tokens[0]
- $unit = $speed_tokens[1]
- if ($unit.tolower() -eq "gbps")
- {
- $factor = 1000000000
- }
- elseif ($unit.tolower() -eq "mbps")
- {
- $factor = 1000000
- }
- elseif ($unit.tolower() -eq "kbps")
- {
- $factor = 1000
- }
- }
- return $($value * $factor)
-}
-
-Function getStatus($status_text)
-{
- if ($status_text.tolower() -eq "up")
- {
- return "2"
- }
- else
- {
- return "0"#
- }
-}
-
-Write-Host "<<<winperf_if:sep(9)>>>"
-
-Write-Host
"Node`tMACAddress`tName`tNetConnectionID`tInterfaceDescription`tNetConnectionStatus`tSpeed"
-foreach ($net in Get-Netadapter -IncludeHidden)
-{
- $address = $net.MacAddress -replace "-", ":"
- Write-Host -NoNewline "$env:COMPUTERNAME`t"
- Write-Host -NoNewline "$($address)`t"
- Write-Host -NoNewline "$($net.DriverDescription)`t"
- Write-Host -NoNewline "$($net.Name)`t"
- Write-Host -NoNewline "$($net.InterfaceDescription)`t"
-
- $status = "0"
- if ($net.Status) {
- $status = "$(getStatus($net.Status.tostring()))"
- }
- Write-Host -NoNewline "$status`t"
- Write-Host $(getSpeed($net.LinkSpeed))
-}
-