Module: check_mk
Branch: master
Commit: 8f98f990348cb84d59842606df40544b6b0eb86b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8f98f990348cb8…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Tue Jul 8 12:01:50 2014 +0200
win_disks: hardware inventory for physical disks in windows
---
.werks/630 | 8 +++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.ps1 | 6 +--
inventory/win_disks | 88 +++++++++++++++++++++++++++++++
web/plugins/views/inventory.py | 12 ++++-
5 files changed, 111 insertions(+), 4 deletions(-)
diff --git a/.werks/630 b/.werks/630
new file mode 100644
index 0000000..f556323
--- /dev/null
+++ b/.werks/630
@@ -0,0 +1,8 @@
+Title: win_disks: hardware inventory for physical disks in windows
+Level: 1
+Component: inv
+Version: 1.2.5i5
+Date: 1404813662
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index a0e167b..31a4a12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -70,6 +70,7 @@
* 0625 hw/sw inventory now reads the kernel version and architecture for linux and
windows
* 0627 lnx_video, win_video: added inventory function and agent for linux video
cards, modified windows inventory function
* 0629 improvements to windows sw/hw inventory (encoding, more details for sw
inventory)
+ * 0630 win_disks: hardware inventory for physical disks in windows
* 0167 FIX: mk_inventory.linux: Changed field separator from pipe to tab...
* 1005 FIX: Fix exception when using pretty-print output format
* 0946 FIX: hw/sw inventory: fixed display bug for byte fields with the value 0...
diff --git a/agents/windows/plugins/mk_inventory.ps1
b/agents/windows/plugins/mk_inventory.ps1
index 48f1657..e828b30 100644
--- a/agents/windows/plugins/mk_inventory.ps1
+++ b/agents/windows/plugins/mk_inventory.ps1
@@ -43,8 +43,8 @@ write-host
"<<<win_system:sep(58):persist($until)>>>"
Get-WmiObject Win32_SystemEnclosure -ComputerName $name | Select
Manufacturer,Name,Model,HotSwappable,InstallDate,PartNumber,SerialNumber
# Hard-Disk
-write-host "<<<win_disk:sep(58):persist($until)>>>"
-Get-WmiObject win32_diskDrive -ComputerName $name | select
Manufacturer,Model,Name,SerialNumber,InterfaceType,Size,Partitions
+write-host "<<<win_disks:sep(58):persist($until)>>>"
+Get-WmiObject win32_diskDrive -ComputerName $name | select
Manufacturer,InterfaceType,Model,Name,SerialNumber,Size,MediaType
# Graphics Adapter
write-host "<<<win_video:sep(58):persist($until)>>>"
@@ -64,7 +64,7 @@ foreach ($path in $paths) {
foreach-object { write-host -separator $separator $_.DisplayName, $_.Publisher,
$_.PSParentPath, $_.PSChildName, $_.DisplayVersion, $_.EstimatedSize, $_.InstallDate }}
}
-## Search exes
+# Search exes
write-host "<<<win_exefiles:sep(124):persist($until)>>>"
$paths = @("d:\", "c:\Program Files", "c:\Program Files
(x86)", "c:\Progs")
foreach ($item in $paths)
diff --git a/inventory/win_disks b/inventory/win_disks
new file mode 100644
index 0000000..096d91f
--- /dev/null
+++ b/inventory/win_disks
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Example output:
+# <<<win_disks:sep(58)>>>
+# DeviceID : \\.\PHYSICALDRIVE0
+# Partitions : 2
+# InterfaceType : IDE
+# Size : 32210196480
+# Caption : VBOX HARDDISK ATA Device
+# Description : Laufwerk
+# Manufacturer : (Standardlaufwerke)
+# MediaType : Fixed hard disk media
+# Model : VBOX HARDDISK ATA Device
+# Name : \\.\PHYSICALDRIVE0
+# SerialNumber : 42566539323537333930652d3836636263352065
+
+# CapabilityDescriptions : {Random Access, Supports Writing}
+# BytesPerSector : 512
+# Index : 0
+# FirmwareRevision : 1.0
+# MediaLoaded : True
+# Status : OK
+# SectorsPerTrack : 63
+# TotalCylinders : 3916
+# TotalHeads : 255
+# TotalSectors : 62910540
+# TotalTracks : 998580
+# TracksPerCylinder : 255
+# Capabilities : {3, 4}
+# Signature : 645875120
+# SCSIBus : 0
+# SCSILogicalUnit : 0
+# SCSIPort : 2
+# SCSITargetId : 0
+
+def inv_win_disks(info):
+ print info
+ node = inv_tree("hardware.storage.disks:")
+ array = {}
+ for varname, value in info:
+ varname = re.sub(" *","", varname)
+ value = re.sub("^ ", "", value)
+ value = value.decode("cp437")
+ if varname == "Manufacturer":
+ array["vendor"] = value
+ elif varname == "InterfaceType":
+ array["bus"] = value
+ elif varname == "Model":
+ array["product"] = value
+ elif varname == "Name":
+ array["fsnode"] = value
+ elif varname == "SerialNumber":
+ array["serial"] = value
+ elif varname == "Size":
+ array["size"] = int(value)
+ elif varname == "MediaType":
+ array["type"] = value
+ array["local"] = True
+ node.append(array)
+
+
+inv_info['win_disks'] = {
+ "inv_function" : inv_win_disks,
+}
diff --git a/web/plugins/views/inventory.py b/web/plugins/views/inventory.py
index 1437ff4..ddb0ee5 100644
--- a/web/plugins/views/inventory.py
+++ b/web/plugins/views/inventory.py
@@ -571,7 +571,17 @@ inventory_displayhints.update({
".hardware.memory.arrays:*.devices:*.size" : { "title" :
_("Size"), "paint" : "bytes", },
".hardware.memory.arrays:*.devices:*.speed" : { "title" :
_("Speed"), "paint" : "hz", },
".hardware.system." : { "title" :
_("System") },
- ".hardware.harddisks." : { "title" :
_("Hard Disks") },
+ ".hardware.storage." : { "title" :
_("Storage") },
+ ".hardware.storage.disks:" : { "title" :
_("Block Devices") },
+ ".hardware.storage.disks:*." : { "title" :
_("Block Device %d") },
+ ".hardware.storage.disks:*.vendor" : { "title" :
_("Vendor") },
+ ".hardware.storage.disks:*.local" : { "title" :
_("Local") },
+ ".hardware.storage.disks:*.bus" : { "title" :
_("Bus") },
+ ".hardware.storage.disks:*.product" : { "title" :
_("Product") },
+ ".hardware.storage.disks:*.fsnode" : { "title" :
_("Filesystem Node") },
+ ".hardware.storage.disks:*.serial" : { "title" :
_("Serial Number") },
+ ".hardware.storage.disks:*.size" : { "title" :
_("Size") },
+ ".hardware.storage.disks:*.type" : { "title" :
_("Type") },
".hardware.video:" : { "title" :
_("Graphic Cards") },
".hardware.video:*." : { "title" :
_("Graphic Card %d") },
".hardware.video:*.name" : { "title" :
_("Graphic Card Name"), "short" : _("Card Name") },