mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge branch 'astoll/module_rewrite' into testing
This commit is contained in:
commit
9e79e4f937
16 changed files with 1740 additions and 0 deletions
125
lib/provider/bios/Icinga_ProviderBios.psm1
Normal file
125
lib/provider/bios/Icinga_ProviderBios.psm1
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
function Get-IcingaBios()
|
||||
{
|
||||
<# Collects the most important BIOS informations,
|
||||
e.g. name, version, manufacturer#>
|
||||
$BIOSInformation = Get-CimInstance Win32_BIOS;
|
||||
[hashtable]$BIOSCharacteristics = @{};
|
||||
[hashtable]$BIOSData = @{};
|
||||
|
||||
foreach ($id in $BIOSInformation.BiosCharacteristics) {
|
||||
$BIOSCharacteristics.Add([string]$id, $ProviderEnums.BiosCharacteristics.Item([int]$id));
|
||||
}
|
||||
|
||||
$BIOSData.Add(
|
||||
'bios', @{
|
||||
'metadata' = @{
|
||||
'Name' = $BIOSInformation.Name;
|
||||
'Caption' = $BIOSInformation.Caption;
|
||||
'Manufacturer' = $BIOSInformation.Manufacturer;
|
||||
'PrimaryBIOS' = $BIOSInformation.PrimaryBIOS;
|
||||
'SerialNumber' = $BIOSInformation.SerialNumber;
|
||||
'SMBIOSBIOSVersion' = $BIOSInformation.SMBIOSBIOSVersion;
|
||||
'SoftwareElementID' = $BIOSInformation.SoftwareElementID;
|
||||
'Status' = $BIOSInformation.Status;
|
||||
'Version' = $BIOSInformation.Version;
|
||||
'BiosCharacteristics' = $BIOSCharacteristics;
|
||||
}
|
||||
}
|
||||
);
|
||||
return $BIOSData;
|
||||
}
|
||||
|
||||
|
||||
function Get-IcingaBiosCharacteristics()
|
||||
{
|
||||
param([switch]$Sorted);
|
||||
|
||||
$bios = Get-CimInstance WIN32_BIOS;
|
||||
[hashtable]$BIOSCharacteristics = @{};
|
||||
|
||||
foreach ($id in $bios.BiosCharacteristics) {
|
||||
$BIOSCharacteristics.Add([string]$id, $ProviderEnums.BiosCharacteristics.Item([int]$id));
|
||||
}
|
||||
|
||||
$output = $BIOSCharacteristics;
|
||||
|
||||
if ($sorted) {
|
||||
$output = $BIOSCharacteristics.GetEnumerator() | Sort-Object name;
|
||||
}
|
||||
|
||||
return @{'value' = $output; 'name' = 'BiosCharacteristics'};
|
||||
}
|
||||
function Get-IcingaBiosCharacteristics()
|
||||
{
|
||||
param([switch]$Sorted);
|
||||
|
||||
$bios = Get-CimInstance WIN32_BIOS;
|
||||
[hashtable]$BIOSCharacteristics = @{};
|
||||
|
||||
foreach ($id in $bios.BiosCharacteristics) {
|
||||
$BIOSCharacteristics.Add([string]$id, $ProviderEnums.BiosCharacteristics.Item([int]$id));
|
||||
}
|
||||
|
||||
$output = $BIOSCharacteristics;
|
||||
|
||||
if ($sorted) {
|
||||
$output = $BIOSCharacteristics.GetEnumerator() | Sort-Object name;
|
||||
}
|
||||
|
||||
return @{'value' = $output; 'name' = 'BiosCharacteristics'};
|
||||
}
|
||||
function Get-IcingaBiosSerialNumber()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.SerialNumber; 'name' = 'SerialNumber'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosVersion()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.Version; 'name' = 'Version'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosManufacturer()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.Manufacturer; 'name' = 'Manufacturer'};
|
||||
}
|
||||
|
||||
# Primary Bios might be more relevant in dual bios context
|
||||
function Get-IcingaBiosPrimaryBios()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.PrimaryBIOS; 'name' = 'PrimaryBIOS'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosName()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.Name; 'name' = 'Name'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosStatus()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.Status; 'name' = 'Status'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosCaption()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.Caption; 'name' = 'Caption'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosSMBIOSBIOSVersion()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.SMBIOSBIOSVersion; 'name' = 'SMBIOSBIOSVersion'};
|
||||
}
|
||||
|
||||
function Get-IcingaBiosSoftwareElementID()
|
||||
{
|
||||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.SoftwareElementID; 'name' = 'SoftwareElementID'};
|
||||
}
|
||||
13
lib/provider/bios/Show-IcingaBiosData.psm1
Normal file
13
lib/provider/bios/Show-IcingaBiosData.psm1
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function Show-IcingaBiosData()
|
||||
{
|
||||
$BIOSInformation = Get-CimInstance Win32_BIOS;
|
||||
[hashtable]$BIOSData = @{};
|
||||
|
||||
foreach ($bios_properties in $BIOSInformation) {
|
||||
foreach($bios in $bios_properties.CimInstanceProperties) {
|
||||
$BIOSData.Add($bios.Name, $bios.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return $BIOSData;
|
||||
}
|
||||
279
lib/provider/cpu/Icinga_ProviderCpu.psm1
Normal file
279
lib/provider/cpu/Icinga_ProviderCpu.psm1
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
function Get-IcingaCPUs()
|
||||
{
|
||||
<# Collects the most important CPU informations,
|
||||
e.g. name, version, manufacturer#>
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
[hashtable]$CPUData = @{};
|
||||
|
||||
foreach ($cpu in $CPUInformation) {
|
||||
|
||||
$CPUData.Add(
|
||||
$cpu.DeviceID.trim('CPU'), @{
|
||||
'metadata' = @{
|
||||
'Name' = $cpu.Name;
|
||||
'DeviceID' = $cpu.DeviceID;
|
||||
'ProcessorID' = $cpu.ProcessorId;
|
||||
'UniqueID' = $cpu.UniqueId;
|
||||
'Description' = $cpu.Description;
|
||||
'OtherFamilyDescription' = $cpu.OtherFamilyDescription;
|
||||
'Caption' = $cpu.Caption;
|
||||
'Version' = $cpu.Version;
|
||||
'SerialNumber' = $cpu.SerialNumber;
|
||||
'Manufacturer' = $cpu.Manufacturer;
|
||||
'NumberOfCores' = $cpu.NumberOfCores;
|
||||
'PartNumber' = $cpu.PartNumber;
|
||||
'Status' = $cpu.Status;
|
||||
'CPUStatus' = $cpu.CpuStatus;
|
||||
'Revision' = $cpu.Revision;
|
||||
'NumberOfLogicalProcessors' = $cpu.NumberOfLogicalProcessors;
|
||||
'Level'= $cpu.Level;
|
||||
'AddressWidth' = $cpu.AddressWidth;
|
||||
'Stepping' = $cpu.Stepping;
|
||||
'SocketDesignation' = $cpu.SocketDesignation;
|
||||
'Family' = @{
|
||||
'raw' = $cpu.Family;
|
||||
'value' = $ProviderEnums.CPUFamily[[int]$cpu.Family];
|
||||
};
|
||||
'Architecture' = @{
|
||||
'raw' = $cpu.Architecture;
|
||||
'value' = $ProviderEnums.CPUArchitecture[[int]$cpu.Architecture];
|
||||
};
|
||||
'ProcessorType' = @{
|
||||
'raw' = $cpu.ProcessorType;
|
||||
'value' = $ProviderEnums.CPUProcessorType[[int]$cpu.ProcessorType];
|
||||
};
|
||||
'StatusInfo' = @{
|
||||
'raw' = $cpu.StatusInfo;
|
||||
'value' = $ProviderEnums.CPUStatusInfo[[int]$cpu.StatusInfo];
|
||||
};
|
||||
'Availability' = @{
|
||||
'raw' = $cpu.Availability;
|
||||
'value' = $ProviderEnums.CPUAvailability[[int]$cpu.Availability];
|
||||
};
|
||||
'PowerManagementCapabilities' = @{
|
||||
'raw' = $cpu.PowerManagementCapabilities;
|
||||
'value' = $ProviderEnums.CPUPowerManagementCapabilities[[int]$cpu.PowerManagementCapabilities];
|
||||
}
|
||||
};
|
||||
'errors' = @{
|
||||
'LastErrorCode' = $cpu.LastErrorCode;
|
||||
'ErrorCleared' = $cpu.ErrorCleared;
|
||||
'ErrorDescription' = $cpu.ErrorDescription;
|
||||
'ConfigManagerErrorCode' = @{
|
||||
'raw' = [int]$cpu.ConfigManagerErrorCode;
|
||||
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$cpu.ConfigManagerErrorCode);
|
||||
}
|
||||
};
|
||||
'specs' = @{
|
||||
'LoadPercentage' = $cpu.LoadPercentage;
|
||||
'CurrentVoltage' = $cpu.CurrentVoltage;
|
||||
'ThreadCount' = $cpu.ThreadCount;
|
||||
'L3CacheSize' = $cpu.L3CacheSize;
|
||||
'L2CacheSpeed' = $cpu.L2CacheSpeed;
|
||||
'L2CacheSize' = $cpu.L2CacheSize;
|
||||
'VoltageCaps' = $cpu.VoltageCaps;
|
||||
'CurrentClockSpeed' = $cpu.CurrentClockSpeed;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return $CPUData;
|
||||
}
|
||||
|
||||
function Get-IcingaCPUInformation()
|
||||
{
|
||||
<# Fetches the information for other more specific Get-IcingaCPU-functions
|
||||
e.g. Get-IcingaCPUThreadCount; Get-IcingaCPULoadPercentage.
|
||||
Can be used to fetch information regarding a value of your choice. #>
|
||||
param(
|
||||
[string]$Parameter
|
||||
);
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
[hashtable]$CPUData = @{};
|
||||
|
||||
foreach ($cpu in $CPUInformation) {
|
||||
$CPUData.Add($cpu.DeviceID.trim('CPU'), $cpu.$Parameter);
|
||||
}
|
||||
|
||||
return $CPUData;
|
||||
}
|
||||
|
||||
function Get-IcingaCPUInformationWithEnums()
|
||||
{ <# Fetches the information of other more specific Get-IcingaCPU-functions,
|
||||
which require a enums key-value pair to resolve their code
|
||||
e.g Get-IcingaCPUFamily, e.g. Get-IcingaCPUArchitecture#>
|
||||
param(
|
||||
[string]$Parameter
|
||||
);
|
||||
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
$Prefix = "CPU";
|
||||
|
||||
[hashtable]$CPUData = @{};
|
||||
|
||||
foreach ($cpu in $CPUInformation) {
|
||||
$CPUData.Add(
|
||||
$cpu.DeviceID.trim('CPU'), @{
|
||||
'raw' = $cpu.$Parameter;
|
||||
'value' = $ProviderEnums."$Prefix$Parameter"[[int]$cpu.$Parameter]
|
||||
}
|
||||
);
|
||||
}
|
||||
return $CPUData;
|
||||
}
|
||||
|
||||
function Get-IcingaCPUErrors()
|
||||
{
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
[hashtable]$CPUData = @{};
|
||||
|
||||
foreach ($cpu in $CPUInformation) {
|
||||
$CPUData.Add(
|
||||
$cpu.trim('CPU'), @{
|
||||
'errors' = @{
|
||||
'LastErrorCode' = $cpu.LastErrorCode;
|
||||
'ErrorCleared' = $cpu.ErrorCleared;
|
||||
'ErrorDescription' = $cpu.ErrorDescription;
|
||||
'ConfigManagerErrorCode' = @{
|
||||
'raw' = [int]$cpu.ConfigManagerErrorCode;
|
||||
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$cpu.ConfigManagerErrorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return $CPUData;
|
||||
}
|
||||
|
||||
function Get-IcingaCPUArchitecture()
|
||||
{
|
||||
$CPUArchitecture = Get-IcingaCPUInformationWithEnums -Parameter Architecture;
|
||||
|
||||
return @{'value' = $CPUArchitecture; 'name' = 'Architecture'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUProcessorType()
|
||||
{
|
||||
$CPUProcessorType = Get-IcingaCPUInformationWithEnums -Parameter ProcessorType;
|
||||
|
||||
return @{'value' = $CPUProcessorType; 'name' = 'ProcessorType'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUStatusInfo()
|
||||
{
|
||||
$CPUStatusInfo = Get-IcingaCPUInformationWithEnums -Parameter StatusInfo;
|
||||
|
||||
return @{'value' = $CPUStatusInfo; 'name' = 'StatusInfo'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUFamily()
|
||||
{
|
||||
$CPUFamily = Get-IcingaCPUInformationWithEnums -Parameter Family;
|
||||
|
||||
return @{'value' = $CPUFamily; 'name' = 'Family'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUConfigManagerErrorCode()
|
||||
{
|
||||
$CPUConfigManagerErrorCode = Get-IcingaCPUInformationWithEnums -Parameter ConfigManagerErrorCode;
|
||||
|
||||
return @{'value' = $CPUConfigManagerErrorCode; 'name' = 'ConfigManagerErrorCode'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUAvailability()
|
||||
{
|
||||
$CPUAvailability = Get-IcingaCPUInformationWithEnums -Parameter Availability;
|
||||
|
||||
return @{'value' = $CPUAvailability; 'name' = 'Availability'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUPowerManagementCapabilities()
|
||||
{
|
||||
$CPUPowerManagementCapabilities = Get-IcingaCPUInformationWithEnums -Parameter PowerManagementCapabilities;
|
||||
|
||||
return @{'value' = $CPUPowerManagementCapabilities; 'name' = 'PowerManagementCapabilities'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPULoadPercentage()
|
||||
{
|
||||
$CPULoadPercentage = Get-IcingaCPUInformation -Parameter LoadPercentage;
|
||||
|
||||
return @{'value' = $CPULoadPercentage; 'name' = 'LoadPercentage'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUCurrentVoltage()
|
||||
{
|
||||
$CPUCurrentVoltage = Get-IcingaCPUInformation -Parameter CurrentVoltage;
|
||||
|
||||
return @{'value' = $CPUCurrentVoltage; 'name' = 'CurrentVoltage'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUThreadCount()
|
||||
{
|
||||
$CPUThreadCount = Get-IcingaCPUInformation -Parameter ThreadCount;
|
||||
|
||||
return @{'value' = $CPUThreadCount; 'name' = 'ThreadCount'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUL3CacheSize()
|
||||
{
|
||||
$CPUL3CacheSize = Get-IcingaCPUInformation -Parameter L3CacheSize;
|
||||
|
||||
return @{'value' = $CPUL3CacheSize; 'name' = 'L3CacheSize'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUL2CacheSize()
|
||||
{
|
||||
$CPUL2CacheSize = Get-IcingaCPUInformation -Parameter L2CacheSize;
|
||||
|
||||
return @{'value' = $CPUL2CacheSize; 'name' = 'L2CacheSize'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUL2CacheSpeed()
|
||||
{
|
||||
$CPUL2CacheSpeed = Get-IcingaCPUInformation -Parameter L2CacheSpeed;
|
||||
|
||||
return @{'value' = $CPUL2CacheSpeed; 'name' = 'L2CacheSpeed'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUVoltageCaps()
|
||||
{
|
||||
$CPUVoltageCaps = Get-IcingaCPUInformation -Parameter VoltageCaps;
|
||||
|
||||
return @{'value' = $CPUVoltageCaps; 'name' = 'VoltageCaps'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUCurrentClockSpeed()
|
||||
{
|
||||
$CPUCurrentClockSpeed = Get-IcingaCPUInformation -Parameter CurrentClockSpeed;
|
||||
|
||||
return @{'value' = $CPUCurrentClockSpeed; 'name' = 'CurrentClockSpeed'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUNumberOfLogicalProcessors()
|
||||
{
|
||||
$CPUNumberOfLogicalProcessors = Get-IcingaCPUInformation -Parameter NumberOfLogicalProcessors;
|
||||
|
||||
return @{'value' = $CPUNumberOfLogicalProcessors; 'name' = 'NumberOfLogicalProcessors'};
|
||||
}
|
||||
|
||||
function Get-IcingaCPUCount()
|
||||
{
|
||||
<# Compares whether NumberofLogicalCores, NumberofCores or Threadcount across all CPUs is the highest,
|
||||
this function is used in provider/memory/Icinga_ProviderMemory.psm1#>
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
|
||||
foreach ($cpu in $CPUInformation) {
|
||||
$NumberOfCoresValue += $cpu.NumberOfCores;
|
||||
$NumberOfLogicalProcessorsValue += $cpu.NumberOfLogicalProcessors;
|
||||
$ThreadCountValue += $cpu.ThreadCount;
|
||||
}
|
||||
|
||||
If (($NumberOfCoresValue -ge $NumberOfLogicalProcessorsValue) -and ($NumberOfCoresValue -ge $ThreadCountValue)) {
|
||||
return $NumberOfCoresValue;
|
||||
} elseif ($NumberOfLogicalProcessorsValue -ge $ThreadCountValue) {
|
||||
return $NumberOfLogicalProcessorsValue;
|
||||
}
|
||||
return $ThreadCountValue;
|
||||
}
|
||||
16
lib/provider/cpu/Show-IcingaCPUData.psm1
Normal file
16
lib/provider/cpu/Show-IcingaCPUData.psm1
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function Show-IcingaCPUData()
|
||||
{
|
||||
|
||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||
[hashtable]$PhysicalCPUData = @{};
|
||||
|
||||
foreach ($cpu_properties in $CPUInformation) {
|
||||
$cpu_datails = @{};
|
||||
foreach($cpu_core in $cpu_properties.CimInstanceProperties) {
|
||||
$cpu_datails.Add($cpu_core.Name, $cpu_core.Value);
|
||||
}
|
||||
$PhysicalCPUData.Add($cpu_datails.DeviceID, $cpu_datails);
|
||||
}
|
||||
|
||||
return $PhysicalCPUData;
|
||||
}
|
||||
143
lib/provider/disks/Icinga_ProviderDisks.psm1
Normal file
143
lib/provider/disks/Icinga_ProviderDisks.psm1
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
|
||||
function Get-IcingaDiskInformation()
|
||||
{
|
||||
<# Fetches the information for other more specific Get-IcingaDisk-functions
|
||||
e.g. Get-IcingaDiskModel; Get-IcingaDiskManufacturer.
|
||||
Can be used to fetch information regarding a value of your choice. #>
|
||||
param(
|
||||
# The value to fetch from Win32_DiskDrive
|
||||
[string]$Parameter
|
||||
);
|
||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||
[hashtable]$DiskData = @{};
|
||||
|
||||
foreach ($disk in $DiskInformation) {
|
||||
$DiskData.Add($disk.DeviceID.trimstart(".\PHYSICALDRVE"), $disk.$Parameter);
|
||||
}
|
||||
|
||||
return $DiskData;
|
||||
}
|
||||
function Get-IcingaDiskPartitions()
|
||||
{
|
||||
param(
|
||||
$Disk
|
||||
);
|
||||
<# Fetches all the most important informations regarding partitions
|
||||
e.g. physical disk; partition, size
|
||||
, also collects partition information for Get-IcingaDisks #>
|
||||
$LogicalDiskInfo = Get-WmiObject Win32_LogicalDiskToPartition;
|
||||
[hashtable]$PartitionDiskByDriveLetter = @{};
|
||||
|
||||
foreach ($item in $LogicalDiskInfo) {
|
||||
[string]$driveLetter = $item.Dependent.SubString(
|
||||
$item.Dependent.LastIndexOf('=') + 1,
|
||||
$item.Dependent.Length - $item.Dependent.LastIndexOf('=') - 1
|
||||
);
|
||||
$driveLetter = $driveLetter.Replace('"', '').trim(':');
|
||||
|
||||
[string]$diskPartition = $item.Antecedent.SubString(
|
||||
$item.Antecedent.LastIndexOf('=') + 1,
|
||||
$item.Antecedent.Length - $item.Antecedent.LastIndexOf('=') - 1
|
||||
)
|
||||
$diskPartition = $diskPartition.Replace('"', '');
|
||||
$diskDisk,$diskPartition = $diskPartition.split(',');
|
||||
|
||||
$diskPartition = $diskPartition.trim("Partition #");
|
||||
$diskDisk = $diskDisk.trim("Disk #");
|
||||
|
||||
If ([string]::IsNullOrEmpty($Disk) -eq $FALSE) {
|
||||
If ([int]$Disk -ne [int]$diskDisk) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$diskPartitionSize = Get-Partition -DriveLetter $driveLetter;
|
||||
|
||||
$PartitionDiskByDriveLetter.Add(
|
||||
$driveLetter,
|
||||
@{
|
||||
'Disk' = $diskDisk;
|
||||
'Partition' = $diskPartition;
|
||||
'Size' = $diskPartitionSize.Size;
|
||||
}
|
||||
);
|
||||
}
|
||||
return $PartitionDiskByDriveLetter;
|
||||
}
|
||||
|
||||
function Get-IcingaDiskCapabilities
|
||||
{
|
||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||
[hashtable]$DiskCapabilities = @{};
|
||||
|
||||
foreach ($capabilities in $DiskInformation.Capabilities) {
|
||||
$DiskCapabilities.Add([int]$capabilities, $ProviderEnums.DiskCapabilities.([int]$capabilities));
|
||||
}
|
||||
return @{'value' = $DiskCapabilities; 'name' = 'Capabilities'};
|
||||
|
||||
}
|
||||
function Get-IcingaDiskSize
|
||||
{
|
||||
$DiskSize = Get-IcingaDiskInformation -Parameter Size;
|
||||
|
||||
return @{'value' = $DiskSize; 'name' = 'Size'};
|
||||
}
|
||||
|
||||
function Get-IcingaDiskCaption
|
||||
{
|
||||
$DiskCaption = Get-IcingaDiskInformation -Parameter Caption;
|
||||
|
||||
return @{'value' = $DiskCaption; 'name' = 'Caption'};
|
||||
}
|
||||
|
||||
function Get-IcingaDiskModel
|
||||
{
|
||||
$DiskModel = Get-IcingaDiskInformation -Parameter Model;
|
||||
return @{'value' = $DiskModel; 'name' = 'Model'};
|
||||
}
|
||||
|
||||
function Get-IcingaDiskManufacturer
|
||||
{
|
||||
$DiskManufacturer = Get-IcingaDiskInformation -Parameter Manufacturer;
|
||||
return @{'value' = $DiskManufacturer; 'name' = 'Manufacturer'};
|
||||
}
|
||||
|
||||
function Get-IcingaDiskTotalCylinders
|
||||
{
|
||||
$DiskTotalCylinders = Get-IcingaDiskInformation -Parameter TotalCylinders;
|
||||
return @{'value' = $DiskTotalCylinders; 'name' = 'TotalCylinders'};
|
||||
}
|
||||
|
||||
function Get-IcingaDiskTotalSectors
|
||||
{
|
||||
$DiskTotalSectors = Get-IcingaDiskInformation -Parameter TotalSectors;
|
||||
return @{'value' = $DiskTotalSectors; 'name' = 'TotalSectors'};
|
||||
}
|
||||
|
||||
function Get-IcingaDisks {
|
||||
<# Collects all the most important Disk-Informations,
|
||||
e.g. size, model, sectors, cylinders
|
||||
Is dependent on Get-IcingaDiskPartitions#>
|
||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||
[hashtable]$DiskData = @{};
|
||||
|
||||
foreach ($disk in $DiskInformation) {
|
||||
$diskID = $disk.DeviceID.trimstart(".\PHYSICALDRVE");
|
||||
$DiskData.Add(
|
||||
$diskID, @{
|
||||
'metadata' = @{
|
||||
'Size' = $disk.Size;
|
||||
'Model' = $disk.Model;
|
||||
'Name' = $disk.Name.trim('.\');
|
||||
'Manufacturer' = $disk.Manufacturer;
|
||||
'Cylinder' = $disk.TotalCylinders;
|
||||
'Sectors' = $disk.TotalSectors
|
||||
};
|
||||
'partitions' = (Get-IcingaDiskPartitions -Disk $diskID);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return $DiskData;
|
||||
}
|
||||
67
lib/provider/disks/Show-IcingaDiskData.psm1
Normal file
67
lib/provider/disks/Show-IcingaDiskData.psm1
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
function Show-IcingaDiskData {
|
||||
|
||||
$DisksInformations = Get-CimInstance Win32_DiskDrive;
|
||||
|
||||
[hashtable]$PhysicalDiskData = @{};
|
||||
|
||||
foreach ($disk_properties in $DisksInformations) {
|
||||
$disk_datails = @{};
|
||||
foreach($disk in $disk_properties.CimInstanceProperties) {
|
||||
$disk_datails.Add($disk.Name, $disk.Value);
|
||||
}
|
||||
$disk_datails.Add('DriveReference', @());
|
||||
$PhysicalDiskData.Add($disk_datails.DeviceID, $disk_datails);
|
||||
}
|
||||
|
||||
$DiskPartitionInfo = Get-WmiObject Win32_DiskDriveToDiskPartition;
|
||||
|
||||
[hashtable]$MapDiskPartitionToLogicalDisk = @{};
|
||||
|
||||
foreach ($item in $DiskPartitionInfo) {
|
||||
[string]$diskPartition = $item.Dependent.SubString(
|
||||
$item.Dependent.LastIndexOf('=') + 1,
|
||||
$item.Dependent.Length - $item.Dependent.LastIndexOf('=') - 1
|
||||
);
|
||||
$diskPartition = $diskPartition.Replace('"', '');
|
||||
|
||||
[string]$physicalDrive = $item.Antecedent.SubString(
|
||||
$item.Antecedent.LastIndexOf('\') + 1,
|
||||
$item.Antecedent.Length - $item.Antecedent.LastIndexOf('\') - 1
|
||||
)
|
||||
$physicalDrive = $physicalDrive.Replace('"', '');
|
||||
|
||||
$MapDiskPartitionToLogicalDisk.Add($diskPartition, $physicalDrive);
|
||||
}
|
||||
|
||||
$LogicalDiskInfo = Get-WmiObject Win32_LogicalDiskToPartition;
|
||||
|
||||
foreach ($item in $LogicalDiskInfo) {
|
||||
[string]$driveLetter = $item.Dependent.SubString(
|
||||
$item.Dependent.LastIndexOf('=') + 1,
|
||||
$item.Dependent.Length - $item.Dependent.LastIndexOf('=') - 1
|
||||
);
|
||||
$driveLetter = $driveLetter.Replace('"', '');
|
||||
|
||||
[string]$diskPartition = $item.Antecedent.SubString(
|
||||
$item.Antecedent.LastIndexOf('=') + 1,
|
||||
$item.Antecedent.Length - $item.Antecedent.LastIndexOf('=') - 1
|
||||
)
|
||||
$diskPartition = $diskPartition.Replace('"', '');
|
||||
|
||||
if ($MapDiskPartitionToLogicalDisk.ContainsKey($diskPartition)) {
|
||||
foreach ($disk in $PhysicalDiskData.Keys) {
|
||||
[string]$DiskId = $disk.SubString(
|
||||
$disk.LastIndexOf('\') + 1,
|
||||
$disk.Length - $disk.LastIndexOf('\') - 1
|
||||
);
|
||||
|
||||
if ($DiskId.ToLower() -eq $MapDiskPartitionToLogicalDisk[$diskPartition].ToLower()) {
|
||||
$PhysicalDiskData[$disk]['DriveReference'] += $driveLetter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $PhysicalDiskData;
|
||||
|
||||
}
|
||||
498
lib/provider/enums/Icinga_ProviderEnums.psm1
Normal file
498
lib/provider/enums/Icinga_ProviderEnums.psm1
Normal file
|
|
@ -0,0 +1,498 @@
|
|||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/bios ##############################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$BiosCharacteristics = @{
|
||||
0 = 'Reserved';
|
||||
1 = 'Reserved';
|
||||
2 = 'Unknown';
|
||||
3 = 'BIOS Characteristics Not Supported';
|
||||
4 = 'ISA is supported';
|
||||
5 = 'MCA is supported';
|
||||
6 = 'EISA is supported';
|
||||
7 = 'PCI is supported';
|
||||
8 = 'PC Card (PCMCIA) is supported';
|
||||
9 = 'Plug and Play is supported';
|
||||
10 = 'APM is supported';
|
||||
11 = 'BIOS is Upgradeable (Flash)';
|
||||
12 = 'BIOS shadowing is allowed';
|
||||
13 = 'VL-VESA is supported';
|
||||
14 = 'ESCD support is available';
|
||||
15 = 'Boot from CD is supported';
|
||||
16 = 'Selectable Boot is supported';
|
||||
17 = 'BIOS ROM is socketed';
|
||||
18 = 'Boot From PC Card (PCMCIA) is supported';
|
||||
19 = 'EDD (Enhanced Disk Drive) Specification is supported';
|
||||
20 = 'Int 13h - Japanese Floppy for NEC 9800 1.2mb (3.5, 1k Bytes/Sector, 360 RPM) is supported';
|
||||
21 = 'Int 13h - Japanese Floppy for Toshiba 1.2mb (3.5, 360 RPM) is supported';
|
||||
22 = 'Int 13h - 5.25 / 360 KB Floppy Services are supported';
|
||||
23 = 'Int 13h - 5.25 /1.2MB Floppy Services are supported';
|
||||
24 = 'Int 13h - 3.5 / 720 KB Floppy Services are supported';
|
||||
25 = 'Int 13h - 3.5 / 2.88 MB Floppy Services are supported';
|
||||
26 = 'Int 5h, Print Screen Service is supported';
|
||||
27 = 'Int 9h, 8042 Keyboard services are supported';
|
||||
28 = 'Int 14h, Serial Services are supported';
|
||||
29 = 'Int 17h, printer services are supported';
|
||||
30 = 'Int 10h, CGA/Mono Video Services are supported';
|
||||
31 = 'NEC PC-98';
|
||||
32 = 'ACPI is supported';
|
||||
33 = 'USB Legacy is supported';
|
||||
34 = 'AGP is supported';
|
||||
35 = 'I2O boot is supported';
|
||||
36 = 'LS-120 boot is supported';
|
||||
37 = 'ATAPI ZIP Drive boot is supported';
|
||||
38 = '1394 boot is supported';
|
||||
39 = 'Smart Battery is supported';
|
||||
40 = 'Reserved for BIOS vendor';
|
||||
41 = 'Reserved for BIOS vendor';
|
||||
42 = 'Reserved for BIOS vendor';
|
||||
43 = 'Reserved for BIOS vendor';
|
||||
44 = 'Reserved for BIOS vendor';
|
||||
45 = 'Reserved for BIOS vendor';
|
||||
46 = 'Reserved for BIOS vendor';
|
||||
47 = 'Reserved for BIOS vendor';
|
||||
48 = 'Reserved for system vendor';
|
||||
49 = 'Reserved for system vendor';
|
||||
50 = 'Reserved for system vendor';
|
||||
51 = 'Reserved for system vendor';
|
||||
52 = 'Reserved for system vendor';
|
||||
53 = 'Reserved for system vendor';
|
||||
54 = 'Reserved for system vendor';
|
||||
55 = 'Reserved for system vendor';
|
||||
56 = 'Reserved for system vendor';
|
||||
57 = 'Reserved for system vendor';
|
||||
58 = 'Reserved for system vendor';
|
||||
59 = 'Reserved for system vendor';
|
||||
60 = 'Reserved for system vendor';
|
||||
61 = 'Reserved for system vendor';
|
||||
62 = 'Reserved for system vendor';
|
||||
63 = 'Reserved for system vendor'
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/disks #############################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$DiskCapabilities = @{
|
||||
0 = 'Unknown';
|
||||
1 = 'Other';
|
||||
2 = 'Sequential Access';
|
||||
3 = 'Random Access';
|
||||
4 = 'Supports Writing';
|
||||
5 = 'Encryption';
|
||||
6 = 'Compression';
|
||||
7 = 'Supports Removeable Media';
|
||||
8 = 'Manual Cleaning';
|
||||
9 = 'Automatic Cleaning';
|
||||
10 = 'SMART Notification';
|
||||
11 = 'Supports Dual Sided Media';
|
||||
12 = 'Predismount Eject Not Required';
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/cpu ###############################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$CPUArchitecture = @{
|
||||
0='x86';
|
||||
1='MIPS';
|
||||
2='Alpha';
|
||||
3='PowerPC';
|
||||
6='ia64';
|
||||
9='x64';
|
||||
}
|
||||
|
||||
[hashtable]$CPUProcessorType = @{
|
||||
1='Other';
|
||||
2='Unknown';
|
||||
3='Central Processor';
|
||||
4='Math Processor';
|
||||
5='DSP Processor';
|
||||
6='Video Processor';
|
||||
}
|
||||
|
||||
[hashtable]$CPUStatusInfo = @{
|
||||
1='Other';
|
||||
2='Unknown';
|
||||
3='Enabled';
|
||||
4='Disabled';
|
||||
5='Not Applicable';
|
||||
}
|
||||
|
||||
[hashtable]$CPUFamily = @{
|
||||
1='Other';
|
||||
2='Unknown';
|
||||
3='8086';
|
||||
4='80286';
|
||||
5='80386';
|
||||
6='80486';
|
||||
7='8087';
|
||||
8='80287';
|
||||
9='80387';
|
||||
10='80487';
|
||||
11='Pentium(R) brand';
|
||||
12='Pentium(R) Pro';
|
||||
13='Pentium(R) II';
|
||||
14='Pentium(R) processor with MMX(TM) technology';
|
||||
15='Celeron(TM)';
|
||||
16='Pentium(R) II Xeon(TM)';
|
||||
17='Pentium(R) III';
|
||||
18='M1 Family';
|
||||
19='M2 Family';
|
||||
24='K5 Family';
|
||||
25='K6 Family';
|
||||
26='K6-2';
|
||||
27='K6-3';
|
||||
28='AMD Athlon(TM) Processor Family';
|
||||
29='AMD(R) Duron(TM) Processor';
|
||||
30='AMD29000 Family';
|
||||
31='K6-2+';
|
||||
32='Power PC Family';
|
||||
33='Power PC 601';
|
||||
34='Power PC 603';
|
||||
35='Power PC 603+';
|
||||
36='Power PC 604';
|
||||
37='Power PC 620';
|
||||
38='Power PC X704';
|
||||
39='Power PC 750';
|
||||
48='Alpha Family';
|
||||
49='Alpha 21064';
|
||||
50='Alpha 21066';
|
||||
51='Alpha 21164';
|
||||
52='Alpha 21164PC';
|
||||
53='Alpha 21164a';
|
||||
54='Alpha 21264';
|
||||
55='Alpha 21364';
|
||||
64='MIPS Family';
|
||||
65='MIPS R4000';
|
||||
66='MIPS R4200';
|
||||
67='MIPS R4400';
|
||||
68='MIPS R4600';
|
||||
69='MIPS R10000';
|
||||
80='SPARC Family';
|
||||
81='SuperSPARC';
|
||||
82='microSPARC II';
|
||||
83='microSPARC IIep';
|
||||
84='UltraSPARC';
|
||||
85='UltraSPARC II';
|
||||
86='UltraSPARC IIi';
|
||||
87='UltraSPARC III';
|
||||
88='UltraSPARC IIIi';
|
||||
96='68040';
|
||||
97='68xxx Family';
|
||||
98='68000';
|
||||
99='68010';
|
||||
100='68020';
|
||||
101='68030';
|
||||
112='Hobbit Family';
|
||||
120='Crusoe(TM) TM5000 Family';
|
||||
121='Crusoe(TM) TM3000 Family';
|
||||
122='Efficeon(TM) TM8000 Family';
|
||||
128='Weitek';
|
||||
130='Itanium(TM) Processor';
|
||||
131='AMD Athlon(TM) 64 Processor Family';
|
||||
132='AMD Opteron(TM) Family';
|
||||
144='PA-RISC Family';
|
||||
145='PA-RISC 8500';
|
||||
146='PA-RISC 8000';
|
||||
147='PA-RISC 7300LC';
|
||||
148='PA-RISC 7200';
|
||||
149='PA-RISC 7100LC';
|
||||
150='PA-RISC 7100';
|
||||
160='V30 Family';
|
||||
176='Pentium(R) III Xeon(TM)';
|
||||
177='Pentium(R) III Processor with Intel(R) SpeedStep(TM) Technology';
|
||||
178='Pentium(R) 4';
|
||||
179='Intel(R) Xeon(TM)';
|
||||
180='AS400 Family';
|
||||
181='Intel(R) Xeon(TM) processor MP';
|
||||
182='AMD AthlonXP(TM) Family';
|
||||
183='AMD AthlonMP(TM) Family';
|
||||
184='Intel(R) Itanium(R) 2';
|
||||
185='Intel Pentium M Processor';
|
||||
190='K7';
|
||||
200='IBM390 Family';
|
||||
201='G4';
|
||||
202='G5';
|
||||
203='G6';
|
||||
204='z/Architecture base';
|
||||
250='i860';
|
||||
251='i960';
|
||||
260='SH-3';
|
||||
261='SH-4';
|
||||
280='ARM';
|
||||
281='StrongARM';
|
||||
300='6x86';
|
||||
301='MediaGX';
|
||||
302='MII';
|
||||
320='WinChip';
|
||||
350='DSP';
|
||||
500='Video Processor';
|
||||
}
|
||||
|
||||
[hashtable]$CPUConfigManagerErrorCode = @{
|
||||
0='This device is working properly.';
|
||||
1='This device is not configured correctly.';
|
||||
2='Windows cannot load the driver for this device.';
|
||||
3='The driver for this device might be corrupted, or your system may be running low on memory or other resources.';
|
||||
4='This device is not working properly. One of its drivers or your registry might be corrupted.';
|
||||
5='The driver for this device needs a resource that Windows cannot manage.';
|
||||
6='The boot configuration for this device conflicts with other devices.';
|
||||
7='Cannot filter.';
|
||||
8='The driver loader for the device is missing.';
|
||||
9='This device is not working properly because the controlling firmware is reporting the resources for the device incorrectly.';
|
||||
10='This device cannot start.';
|
||||
11=' This device failed.';
|
||||
12='This device cannot find enough free resources that it can use.';
|
||||
13="Windows cannot verify this device’s resources.";
|
||||
14='This device cannot work properly until you restart your computer.';
|
||||
15='This device is not working properly because there is probably a re-enumeration problem.';
|
||||
16='Windows cannot identify all the resources this device uses.';
|
||||
17='This device is asking for an unknown resource type.';
|
||||
18='Reinstall the drivers for this device.';
|
||||
19='Your registry might be corrupted.';
|
||||
20='Failure using the VxD loader.';
|
||||
21='System failure: Try changing the driver for this device. If that does not work, see your hardware documentation. Windows is removing this device.';
|
||||
22='This device is disabled.';
|
||||
23="System failure: Try changing the driver for this device. If that doesn’t work, see your hardware documentation.";
|
||||
24="This device is not present, is not working properly, or does not have all its drivers installed.";
|
||||
25="Windows is still setting up this device.";
|
||||
26="Windows is still setting up this device.";
|
||||
27="This device does not have valid log configuration.";
|
||||
28="The drivers for this device are not installed.";
|
||||
29="This device is disabled because the firmware of the device did not give it the required resources.";
|
||||
30="This device is using an Interrupt Request (IRQ) resource that another device is using.";
|
||||
31='This device is not working properly because Windows cannot load the drivers required for this device.';
|
||||
}
|
||||
|
||||
[hashtable]$CPUAvailability = @{
|
||||
1='Other';
|
||||
2='Unknown';
|
||||
3='Running/Full Power';
|
||||
4='Warning';
|
||||
5='In Test';
|
||||
6='Not Applicable';
|
||||
7='Power Off';
|
||||
8='Off Line';
|
||||
9='Off Duty';
|
||||
10='Degraded';
|
||||
11='Not Installed';
|
||||
12='Install Error';
|
||||
13='Power Save - Unknown';
|
||||
14='Power Save - Low Power Mode';
|
||||
15='Power Save - Standby';
|
||||
16='Power Cycle';
|
||||
17='Power Save - Warning';
|
||||
18='Paused';
|
||||
19='Not Ready';
|
||||
20='Not Configured';
|
||||
21='Quiesced';
|
||||
}
|
||||
|
||||
[hashtable]$CPUPowerManagementCapabilities = @{
|
||||
0='Unknown';
|
||||
1='Not Supported';
|
||||
2='Disabled';
|
||||
3='Enabled';
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/memory ############################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$MemoryFormFactor = @{
|
||||
0='Unknown';
|
||||
1= 'Other';
|
||||
2= 'SIP';
|
||||
3= 'DIP';
|
||||
4= 'ZIP';
|
||||
5= 'SOJ';
|
||||
6= 'Proprietary';
|
||||
7= 'SIMM';
|
||||
8= 'DIMM';
|
||||
9= 'TSOP';
|
||||
10= 'PGA';
|
||||
11= 'RIMM';
|
||||
12= 'SODIMM';
|
||||
13= 'SRIMM';
|
||||
14= 'SMD';
|
||||
15= 'SSMP';
|
||||
16= 'QFP';
|
||||
17= 'TQFP';
|
||||
18= 'SOIC';
|
||||
19= 'LCC';
|
||||
20= 'PLCC';
|
||||
21= 'BGA';
|
||||
22= 'FPBGA';
|
||||
23= 'LGA';
|
||||
}
|
||||
|
||||
[hashtable]$MemoryInterleavePosition = @{
|
||||
0= 'Noninterleaved';
|
||||
1= 'First position';
|
||||
2= 'Second position';
|
||||
}
|
||||
|
||||
[hashtable]$MemoryMemoryType = @{
|
||||
0= 'Unknown';
|
||||
1= 'Other';
|
||||
2= 'DRAM';
|
||||
3= 'Synchronous DRAM';
|
||||
4= 'Cache DRAM';
|
||||
5= 'EDO';
|
||||
6= 'EDRAM';
|
||||
7= 'VRAM';
|
||||
8= 'SRAM';
|
||||
9= 'RAM';
|
||||
10= 'ROM';
|
||||
11= 'Flash';
|
||||
12='EEPROM';
|
||||
13= 'FEPROM';
|
||||
14= 'EPROM';
|
||||
15= 'CDRAM';
|
||||
16= '3DRAM';
|
||||
17= 'SDRAM';
|
||||
18= 'SGRAM';
|
||||
19= 'RDRAM';
|
||||
20= 'DDR';
|
||||
21= 'DDR2';
|
||||
22= 'DDR2 FB-DIMM';
|
||||
23= 'DDR2—FB-DIMM,May not be available; see note above.';
|
||||
24= 'DDR3—May not be available; see note above.';
|
||||
25= 'FBD2';
|
||||
}
|
||||
|
||||
[hashtable]$MemoryTypeDetail = @{
|
||||
1= 'Reserved';
|
||||
2= 'Other';
|
||||
4= 'Unknown';
|
||||
8= 'Fast-paged';
|
||||
16= 'Static column';
|
||||
32= 'Pseudo-static';
|
||||
64= 'RAMBUS';
|
||||
128= 'Synchronous';
|
||||
256= 'CMOS';
|
||||
512= 'EDO';
|
||||
1024= 'Window DRAM';
|
||||
2048= 'Cache DRAM';
|
||||
4096= 'Non-volatile';
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/Windows ###########################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$WindowsOSProductSuite = @{
|
||||
1= 'Microsoft Small Business Server was once installed, but may have been upgraded to another version of Windows.';
|
||||
2= 'Windows Server 2008 Enterprise is installed.';
|
||||
4= 'Windows BackOffice components are installed.';
|
||||
8= 'Communication Server is installed.';
|
||||
16= 'Terminal Services is installed.';
|
||||
32= 'Microsoft Small Business Server is installed with the restrictive client license.';
|
||||
64= 'Windows Embedded is installed.';
|
||||
128= 'Datacenter edition is installed.';
|
||||
256= 'Terminal Services is installed, but only one interactive session is supported.';
|
||||
512= 'Windows Home Edition is installed.';
|
||||
1024= 'Web Server Edition is installed.';
|
||||
8192= 'Storage Server Edition is installed.';
|
||||
16384= 'Compute Cluster Edition is installed.';
|
||||
}
|
||||
|
||||
[hashtable]$WindowsProductType = @{
|
||||
1= 'Work Station';
|
||||
2= 'Domain Controller';
|
||||
3= 'Server';
|
||||
}
|
||||
|
||||
[hashtable]$WindowsOSType = @{
|
||||
0= 'Unknown';
|
||||
1= 'Other';
|
||||
2= 'MACROS';
|
||||
3= 'ATTUNIX';
|
||||
4= 'DGUX';
|
||||
5= 'DECNT';
|
||||
6= 'Digital Unix';
|
||||
7= 'OpenVMS'
|
||||
8= 'HPUX';
|
||||
9= 'AIX';
|
||||
10= 'MVS';
|
||||
11= 'OS400';
|
||||
12= 'OS/2';
|
||||
13= 'JavaVM';
|
||||
14= 'MSDOS';
|
||||
15= 'WIN3x';
|
||||
16= 'WIN95';
|
||||
17= 'WIN98';
|
||||
18= 'WINNT';
|
||||
19= 'WINCE';
|
||||
20= 'NCR3000';
|
||||
21= 'NetWare';
|
||||
22= 'OSF';
|
||||
23= 'DC/OS';
|
||||
24= 'Reliant UNIX';
|
||||
25= 'SCO UnixWare';
|
||||
26= 'SCO OpenServer';
|
||||
27= 'Sequent';
|
||||
28= 'IRIX';
|
||||
29= 'Solaris';
|
||||
30= 'SunOS';
|
||||
31= 'U6000';
|
||||
32= 'ASERIES';
|
||||
33= 'TandemNSK';
|
||||
34= 'TandemNT';
|
||||
35= 'BS2000';
|
||||
36= 'LINUX';
|
||||
37= 'Lynx';
|
||||
38= 'XENIX';
|
||||
39= 'VM/ESA';
|
||||
40= 'Interactive UNIX';
|
||||
41= 'BSDUNIX';
|
||||
42= 'FreeBSD';
|
||||
43= 'NetBSD';
|
||||
44= 'GNU Hurd';
|
||||
45= 'OS9';
|
||||
46= 'MACH Kernel';
|
||||
47= 'Inferno';
|
||||
48= 'QNX';
|
||||
49= 'EPOC';
|
||||
50= 'IxWorks';
|
||||
51= 'VxWorks';
|
||||
52= 'MiNT';
|
||||
53= 'BeOS';
|
||||
54= 'HP MPE';
|
||||
55= 'NextStep';
|
||||
56= 'PalmPilot';
|
||||
57= 'Rhapsody';
|
||||
58= 'Windows 2000';
|
||||
59= 'Dedicated';
|
||||
60= 'OS/390';
|
||||
61= 'VSE';
|
||||
62= 'TPF';
|
||||
}
|
||||
|
||||
[hashtable]$ProviderEnums = @{
|
||||
#/lib/provider/bios
|
||||
BiosCharacteristics = $BiosCharacteristics;
|
||||
#/lib/provider/disks
|
||||
DiskCapabilities = $DiskCapabilities;
|
||||
#/lib/provider/cpu
|
||||
CPUArchitecture = $CPUArchitecture;
|
||||
CPUProcessorType = $CPUProcessorType;
|
||||
CPUStatusInfo = $CPUStatusInfo;
|
||||
CPUFamily = $CPUFamily;
|
||||
CPUConfigManagerErrorCode = $CPUConfigManagerErrorCode;
|
||||
CPUAvailability = $CPUAvailability;
|
||||
CPUPowerManagementCapabilities = $CPUPowerManagementCapabilities;
|
||||
#/lib/provider/memory
|
||||
MemoryFormFactor = $MemoryFormFactor;
|
||||
MemoryInterleavePosition = $MemoryInterleavePosition;
|
||||
MemoryMemoryType = $MemoryMemoryType;
|
||||
MemoryTypeDetail = $MemoryTypeDetail;
|
||||
#/lib/provider/windows
|
||||
WindowsOSProductSuite = $WindowsOSProductSuite;
|
||||
WindowsProductType = $WindowsProductType;
|
||||
WindowsOSType = $WindowsOSType;
|
||||
}
|
||||
|
||||
Export-ModuleMember -Variable @('ProviderEnums');
|
||||
148
lib/provider/memory/Icinga_ProviderMemory.psm1
Normal file
148
lib/provider/memory/Icinga_ProviderMemory.psm1
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
function Get-IcingaMemory ()
|
||||
{
|
||||
<# Collects the most important Memory informations,
|
||||
e.g. name, version, manufacturer#>
|
||||
$MEMInformation = Get-CimInstance Win32_PhysicalMemory;
|
||||
|
||||
[hashtable]$MEMData = @{};
|
||||
|
||||
foreach($memory in $MEMInformation) {
|
||||
|
||||
$TypeDetail = @();
|
||||
$ProviderEnums.MemoryTypeDetail.Keys | Where-Object {
|
||||
$_ -band $memory.TypeDetail
|
||||
} | ForEach-Object {
|
||||
$TypeDetail += $ProviderEnums.MemoryTypeDetail.Get_Item($_);
|
||||
};
|
||||
|
||||
$MEMData.Add(
|
||||
$memory.tag.trim("Physical Memory"), @{
|
||||
'metadata' = @{
|
||||
'Caption' = $memory.Name;
|
||||
'Description'= $memory.Description;
|
||||
'Manufacturer'= $memory.Manufacturer;
|
||||
'Model'= $memory.Model;
|
||||
'OtherIdentifyingInfo'= $memory.OtherIdentifyingInfo;
|
||||
'PartNumber'= $memory.PartNumber;
|
||||
'SerialNumber'= $memory.SerialNumber;
|
||||
'Tag'= $memory.Tag;
|
||||
'SMBIOSMemoryType'= $memory.SMBIOSMemoryType;
|
||||
'DeviceLocator' = $memory.DeviceLocator;
|
||||
'PositionInRow' = $memory.PositionInRow;
|
||||
'Version' = $memory.Version;
|
||||
'PoweredOn' = $memory.PoweredOn;
|
||||
'Status' = $memory.Status;
|
||||
'InstallDate' = $memory.InstallDate;
|
||||
'BankLabel' = $memory.BankLabel;
|
||||
'InterleaveDataDepth' = $memory.InterleaveDataDepth;
|
||||
'Attributes' = $memory.Attributes;
|
||||
'Replaceable' = $memory.Replaceable;
|
||||
'Removable' = $memory.Removable;
|
||||
'HotSwappable' = $memory.HotSwappable;
|
||||
'FormFactor' = @{
|
||||
'raw' = $memory.FormFactor;
|
||||
'value' = $ProviderEnums.MemoryFormFactor[[int]$memory.FormFactor];
|
||||
};
|
||||
'InterleavePosition' = @{
|
||||
'raw' = $memory.InterleavePosition;
|
||||
'value' = $ProviderEnums.MemoryInterleavePosition[[int]$memory.InterleavePosition];
|
||||
};
|
||||
'MemoryType' = @{
|
||||
'raw' = $memory.MemoryType;
|
||||
'value' = $ProviderEnums.MemoryMemoryType[[int]$memory.MemoryType];
|
||||
};
|
||||
'TypeDetail' = @{
|
||||
'raw' = $memory.TypeDetail;
|
||||
'value' = $TypeDetail;
|
||||
};
|
||||
};
|
||||
'specs' = @{
|
||||
'MaxVoltage' = $memory.MaxVoltage;
|
||||
'MinVoltage' = $memory.MinVoltage;
|
||||
'ConfiguredVoltage' = $memory.ConfiguredVoltage;
|
||||
'ConfiguredClockSpeed' = $memory.ConfiguredClockSpeed;
|
||||
'TotalWidth' = $memory.TotalWidth;
|
||||
'DataWidth' = $memory.DataWidth;
|
||||
'Speed' = $memory.Speed;
|
||||
'Capacity' = $memory.Capacity;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return $MEMData;
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryInformation()
|
||||
{
|
||||
<# Fetches the information for other more specific Get-IcingaMemory-functions
|
||||
e.g. Get-IcingaMemoryMaxVoltage; Get-IcingaMemoryTotalWidth.
|
||||
Can be used to fetch information regarding a value of your choice. #>
|
||||
param(
|
||||
[string]$Parameter
|
||||
);
|
||||
$MEMInformation = Get-CimInstance Win32_PhysicalMemory;
|
||||
[hashtable]$MEMData = @{};
|
||||
|
||||
foreach ($memory in $MEMInformation) {
|
||||
$MEMData.Add($memory.tag.trim("Physical Memory"), $memory.$Parameter);
|
||||
}
|
||||
|
||||
return $MEMData;
|
||||
}
|
||||
function Get-IcingaMemoryMaxVoltage()
|
||||
{
|
||||
$MemoryMaxVoltage = Get-IcingaMemoryInformation -Parameter MaxVoltage;
|
||||
|
||||
return @{'value' = $MemoryMaxVoltage; 'name' = 'MaxVoltage'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryMinVoltage()
|
||||
{
|
||||
$MemoryMinVoltage = Get-IcingaMemoryInformation -Parameter MinVoltage;
|
||||
|
||||
return @{'value' = $MemoryMinVoltage; 'name' = 'MinVoltage'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryConfiguredVoltage()
|
||||
{
|
||||
$MemoryConfiguredVoltage = Get-IcingaMemoryInformation -Parameter ConfiguredVoltage;
|
||||
|
||||
return @{'value' = $MemoryConfiguredVoltage; 'name' = 'ConfiguredVoltage'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryConfiguredClockSpeed()
|
||||
{
|
||||
$MemoryConfiguredClockSpeed = Get-IcingaMemoryInformation -Parameter ConfiguredClockSpeed;
|
||||
|
||||
return @{'value' = $MemoryConfiguredClockSpeed; 'name' = 'ConfiguredClockSpeed'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryTotalWidth()
|
||||
{
|
||||
$MemoryTotalWidth = Get-IcingaMemoryInformation -Parameter TotalWidth;
|
||||
|
||||
return @{'value' = $MemoryTotalWidth; 'name' = 'TotalWidth'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryDataWidth()
|
||||
{
|
||||
$MemoryDataWidth = Get-IcingaMemoryInformation -Parameter DataWidth;
|
||||
|
||||
return @{'value' = $MemoryDataWidth; 'name' = 'DataWidth'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemorySpeed()
|
||||
{
|
||||
$MemorySpeed = Get-IcingaMemoryInformation -Parameter Speed;
|
||||
|
||||
return @{'value' = $MemorySpeed; 'name' = 'Speed'};
|
||||
}
|
||||
|
||||
function Get-IcingaMemoryCapacity()
|
||||
{
|
||||
$MemoryCapacity = Get-IcingaMemoryInformation -Parameter Capacity;
|
||||
|
||||
return @{'value' = $MemoryCapacity; 'name' = 'Capacity'};
|
||||
}
|
||||
52
lib/provider/memory/Show-IcingaMemoryData.psm1
Normal file
52
lib/provider/memory/Show-IcingaMemoryData.psm1
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
function Show-IcingaMemoryData ()
|
||||
{
|
||||
|
||||
$MEMInformation = Get-CimInstance Win32_PhysicalMemory;
|
||||
|
||||
[hashtable]$MEMData = @{};
|
||||
|
||||
foreach($memory in $MEMInformation) {
|
||||
$MEMData.Add(
|
||||
$memory.tag.trim("Physical Memory"), @{
|
||||
'Caption' = $memory.Name;
|
||||
'Description' = $memory.Description;
|
||||
'Name' = $memory.Name;
|
||||
'InstallDate' = $memory.InstallDate;
|
||||
'Status' = $memory.Status
|
||||
'CreationClassName'= $memory.CreationClassName
|
||||
'Manufacturer'= $memory.Manufacturer
|
||||
'Model'= $memory.Model
|
||||
'OtherIdentifyingInfo'= $memory.OtherIdentifyingInfo
|
||||
'PartNumber'= $memory.PartNumber
|
||||
'PoweredOn'= $memory.PoweredOn
|
||||
'SerialNumber'= $memory.SerialNumber
|
||||
'SKU'= $memory.SKU
|
||||
'Tag'= $memory.Tag
|
||||
'Version'= $memory.Version
|
||||
'HotSwappable'= $memory.HotSwappable
|
||||
'Removable'= $memory.Removable
|
||||
'Replaceable'= $memory.Replaceable
|
||||
'FormFactor'= $memory.FormFactor
|
||||
'BankLabel'= $memory.BankLabel
|
||||
'Capacity'= $memory.Capacity
|
||||
'DataWidth'= $memory.DataWidth
|
||||
'InterleavePosition'= $memory.InterleavePosition
|
||||
'MemoryType'= $memory.MemoryType
|
||||
'PositionInRow'= $memory.PositionInRow
|
||||
'Speed'= $memory.Speed
|
||||
'TotalWidth'= $memory.TotalWidth
|
||||
'Attributes'= $memory.Attributes
|
||||
'ConfiguredClockSpeed'= $memory.ConfiguredClockSpeed
|
||||
'ConfiguredVoltage'= $memory.ConfiguredVoltage
|
||||
'DeviceLocator'= $memory.DeviceLocator
|
||||
'InterleaveDataDepth'= $memory.InterleaveDataDepth
|
||||
'MaxVoltage'= $memory.MaxVoltage
|
||||
'MinVoltage'= $memory.MinVoltage
|
||||
'SMBIOSMemoryType'= $memory.SMBIOSMemoryType
|
||||
'TypeDetail'= $memory.TypeDetail
|
||||
'PSComputerName'= $memory.PSComputerName
|
||||
}
|
||||
);
|
||||
}
|
||||
return $MEMData;
|
||||
}
|
||||
96
lib/provider/process/Icinga_ProviderProcess.psm1
Normal file
96
lib/provider/process/Icinga_ProviderProcess.psm1
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
Import-IcingaLib provider\cpu;
|
||||
|
||||
function Add-IcingaProcessPerfData()
|
||||
{
|
||||
param($ProcessList, $ProcessKey, $Process);
|
||||
|
||||
if ($ProcessList.ContainsKey($ProcessKey) -eq $FALSE) {
|
||||
$ProcessList.Add($ProcessKey, $Process.$ProcessKey);
|
||||
} else {
|
||||
$ProcessList[$ProcessKey] += $Process.$ProcessKey;
|
||||
}
|
||||
}
|
||||
|
||||
function Get-IcingaProcessData {
|
||||
|
||||
$ProcessInformation = Get-WmiObject Win32_Process;
|
||||
$ProcessPerfDataList = Get-WmiObject Win32_PerfFormattedData_PerfProc_Process;
|
||||
$ProcessUniqueList = Get-WmiObject Win32_Process | Select-Object name -unique;
|
||||
$CPUCoreCount = Get-IcingaCPUCount;
|
||||
|
||||
|
||||
[hashtable]$ProcessData = @{};
|
||||
[hashtable]$ProcessList = @{};
|
||||
[hashtable]$ProcessNamesUnique = @{};
|
||||
[hashtable]$ProcessIDsByName = @{};
|
||||
|
||||
foreach ($process in $ProcessInformation) {
|
||||
[string]$processName = $process.Name.Replace('.exe', '');
|
||||
|
||||
if ($ProcessList.ContainsKey($processName) -eq $FALSE) {
|
||||
$ProcessList.Add($processName, @{
|
||||
'ProcessList' = @{};
|
||||
'PerformanceData' = @{}
|
||||
});
|
||||
}
|
||||
|
||||
$ProcessList[$processName]['ProcessList'].Add(
|
||||
[string]$process.ProcessID, @{
|
||||
'Name' = $process.Name;
|
||||
'ProcessId' = $process.ProcessId;
|
||||
'Priority' = $process.Priority;
|
||||
'PageFileUsage' = $process.PageFileUsage;
|
||||
'ThreadCount' = $process.ThreadCount;
|
||||
'KernelModeTime' = $process.KernelModeTime;
|
||||
'UserModeTime' = $process.UserModeTime;
|
||||
'WorkingSetSize' = $process.WorkingSetSize;
|
||||
'CommandLine' = $process.CommandLine;
|
||||
}
|
||||
);
|
||||
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'ThreadCount' -Process $process;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'PageFileUsage' -Process $process;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'KernelModeTime' -Process $process;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'UserModeTime' -Process $process;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'WorkingSetSize' -Process $process;
|
||||
}
|
||||
|
||||
foreach ($process in $ProcessPerfDataList) {
|
||||
if ($process.Name -eq '_Total' -Or $process.Name -eq 'Idle') {
|
||||
continue;
|
||||
}
|
||||
|
||||
[string]$processName = $process.Name.Split('#')[0];
|
||||
[string]$ProcessId = $process.IDProcess;
|
||||
|
||||
if ($ProcessList.ContainsKey($processName) -eq $FALSE) {
|
||||
Write-Host 'Unknown Process Name: ' $processName;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ProcessList[$processName]['ProcessList'].ContainsKey($ProcessId) -eq $FALSE) {
|
||||
Write-Host 'Unknown Process ID: ' $ProcessId;
|
||||
continue;
|
||||
}
|
||||
|
||||
$ProcessList[$processName]['ProcessList'][$ProcessId].Add(
|
||||
'WorkingSetPrivate', $process.WorkingSetPrivate
|
||||
);
|
||||
$ProcessList[$processName]['ProcessList'][$ProcessId].Add(
|
||||
'PercentProcessorTime', ($process.PercentProcessorTime / $CPUCoreCount)
|
||||
);
|
||||
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'WorkingSetPrivate' -Process $process;
|
||||
if ($ProcessList[$processName]['PerformanceData'].ContainsKey('PercentProcessorTime') -eq $FALSE) {
|
||||
$ProcessList[$processName]['PerformanceData'].Add('PercentProcessorTime', ($process.PercentProcessorTime / $CPUCoreCount));
|
||||
} else {
|
||||
$ProcessList[$processName]['PerformanceData']['PercentProcessorTime'] += ($process.PercentProcessorTime / $CPUCoreCount);
|
||||
}
|
||||
}
|
||||
|
||||
$ProcessData.Add('Process Count', $ProcessInformation.Count);
|
||||
$ProcessData.add('Processes', $ProcessList);
|
||||
|
||||
return $ProcessData;
|
||||
}
|
||||
61
lib/provider/services/Icinga_ProviderServices.psm1
Normal file
61
lib/provider/services/Icinga_ProviderServices.psm1
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
function Get-IcingaServices()
|
||||
{
|
||||
param (
|
||||
[array]$Service
|
||||
)
|
||||
|
||||
$ServiceInformation = Get-Service -Name $Service;
|
||||
|
||||
[hashtable]$ServiceData = @{};
|
||||
|
||||
foreach ($service in $ServiceInformation) {
|
||||
|
||||
[array]$DependentServices = $null;
|
||||
[array]$DependingServices = $null;
|
||||
|
||||
#Dependent / Child
|
||||
foreach ($dependency in $service.DependentServices) {
|
||||
if ($null -eq $DependentServices) { $DependentServices = @(); }
|
||||
$DependentServices += $dependency.Name;
|
||||
}
|
||||
|
||||
#Depends / Parent
|
||||
foreach ($dependency in $service.ServicesDependedOn) {
|
||||
if ($null -eq $DependingServices) { $DependingServices = @(); }
|
||||
$DependingServices += $dependency.Name;
|
||||
}
|
||||
|
||||
$ServiceData.Add(
|
||||
$service.Name, @{
|
||||
'metadata' = @{
|
||||
'DisplayName' = $service.DisplayName;
|
||||
'ServiceName' = $service.ServiceName;
|
||||
'Site' = $service.Site;
|
||||
'Container' = $service.Container;
|
||||
'ServiceHandle' = $service.ServiceHandle;
|
||||
'Dependent' = $DependentServices;
|
||||
'Depends' = $DependingServices;
|
||||
};
|
||||
'configuration' = @{
|
||||
'CanPauseAndContinue' = $service.CanPauseAndContinue;
|
||||
'CanShutdown' = $service.CanShutdown;
|
||||
'CanStop' = $service.CanStop;
|
||||
'Status' = @{
|
||||
'raw' = [int]$service.Status;
|
||||
'value' = $service.Status;
|
||||
};
|
||||
'ServiceType' = @{
|
||||
'raw' = [int]$service.ServiceType;
|
||||
'value' = $service.ServiceType;
|
||||
};
|
||||
'ServiceHandle' = $service.ServiceHandle;
|
||||
'StartType' = @{
|
||||
'raw' = [int]$service.StartType;
|
||||
'value' = $service.StartType;
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return $ServiceData;
|
||||
}
|
||||
29
lib/provider/updates/Get-IcingaUpdatesHotfix.psm1
Normal file
29
lib/provider/updates/Get-IcingaUpdatesHotfix.psm1
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
function Get-IcingaUpdatesHotfix (){
|
||||
|
||||
[hashtable]$HotfixInfo = @{};
|
||||
[hashtable]$HotfixNameCache = @{};
|
||||
|
||||
# First fetch all of our hotfixes
|
||||
$Hotfixes = Get-Hotfix;
|
||||
|
||||
foreach ($property in $Hotfixes) {
|
||||
[hashtable]$HotfixData = @{};
|
||||
foreach ($hotfix in $property.Properties) {
|
||||
$HotfixData.Add($hotfix.Name, $hotfix.Value);
|
||||
}
|
||||
|
||||
[string]$name = [string]::Format('{0} [{1}]', $HotfixData.HotFixID, $HotfixData.InstalledOn);
|
||||
|
||||
if ($HotfixNameCache.ContainsKey($name) -eq $FALSE) {
|
||||
$HotfixNameCache.Add($name, 1);
|
||||
} else {
|
||||
$HotfixNameCache[$name] += 1;
|
||||
$name = [string]::Format('{0} ({1})', $name, $HotfixNameCache[$name]);
|
||||
}
|
||||
|
||||
$HotfixInfo.Add($name, $HotfixData);
|
||||
}
|
||||
|
||||
return $HotfixInfo;
|
||||
|
||||
}
|
||||
75
lib/provider/updates/Get-IcingaUpdatesInstalled.psm1
Normal file
75
lib/provider/updates/Get-IcingaUpdatesInstalled.psm1
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
function Get-IcingaUpdatesInstalled ()
|
||||
{
|
||||
|
||||
# Fetch all informations about installed updates and add them
|
||||
$WindowsUpdates = New-Object -ComObject "Microsoft.Update.Session";
|
||||
$SearchIndex = $WindowsUpdates.CreateUpdateSearcher();
|
||||
[hashtable]$UpdateList = @{};
|
||||
[hashtable]$UpdateInstalled = @{};
|
||||
[hashtable]$UpdateUninstalled = @{};
|
||||
[hashtable]$UpdateOther = @{};
|
||||
|
||||
# Operation ID's
|
||||
# 1: Installed
|
||||
# 2: Uninstalled
|
||||
# 3: Other
|
||||
|
||||
# At first get a list of our Windows Update history
|
||||
$Updates = $SearchIndex.QueryHistory(0, $SearchIndex.GetTotalHistoryCount()) |
|
||||
Select-Object Operation, ResultCode, HResult, Date, Title, Description, ServiceID, SupportUrl;
|
||||
|
||||
foreach ($update in $Updates) {
|
||||
[string]$UpdateKey = [string]::Format('{0} [{1}|{2}]', $update.Title, $update.Date, $update.HResult);
|
||||
switch ($update.Operation) {
|
||||
1 {
|
||||
if ($UpdateInstalled.ContainsKey($UpdateKey) -eq $FALSE) {
|
||||
$UpdateInstalled.Add($UpdateKey, $update);
|
||||
} else {
|
||||
$Icinga2.Log.Write(
|
||||
$Icinga2.Enums.LogState.Warning,
|
||||
[string]::Format(
|
||||
'Unable to add update "{0}" to update list. The key with content "{1}" is already present',
|
||||
$UpdateKey,
|
||||
$update
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
2 {
|
||||
if ($UpdateUninstalled.ContainsKey($UpdateKey) -eq $FALSE) {
|
||||
$UpdateUninstalled.Add($UpdateKey, $update);
|
||||
} else {
|
||||
$Icinga2.Log.Write(
|
||||
$Icinga2.Enums.LogState.Warning,
|
||||
[string]::Format(
|
||||
'Unable to add update "{0}" to update list. The key with content "{1}" is already present',
|
||||
$UpdateKey,
|
||||
$update
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
default {
|
||||
if ($UpdateOther.ContainsKey($UpdateKey) -eq $FALSE) {
|
||||
$UpdateOther.Add($UpdateKey, $update);
|
||||
} else {
|
||||
$Icinga2.Log.Write(
|
||||
$Icinga2.Enums.LogState.Warning,
|
||||
[string]::Format(
|
||||
'Unable to add update "{0}" to update list. The key with content "{1}" is already present',
|
||||
$UpdateKey,
|
||||
$update
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
$UpdateList.Add('installed', $UpdateInstalled);
|
||||
$UpdateList.Add('uninstalled', $UpdateUninstalled);
|
||||
$UpdateList.Add('other', $UpdateOther);
|
||||
|
||||
return $UpdateList;
|
||||
|
||||
}
|
||||
78
lib/provider/updates/Get-IcingaUpdatesPending.psm1
Normal file
78
lib/provider/updates/Get-IcingaUpdatesPending.psm1
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
function Get-IcingaUpdatesPending ()
|
||||
{
|
||||
|
||||
[hashtable]$PendingUpdates = @{};
|
||||
[hashtable]$PendingUpdateNameCache = @{};
|
||||
# Fetch all informations about installed updates and add them
|
||||
$WindowsUpdates = New-Object -ComObject "Microsoft.Update.Session";
|
||||
$SearchIndex = $WindowsUpdates.CreateUpdateSearcher();
|
||||
|
||||
try {
|
||||
# Get a list of current pending updates which are not yet installed on the system
|
||||
$Pending = $SearchIndex.Search("IsInstalled=0");
|
||||
$PendingUpdates.Add('count', $Pending.Updates.Count);
|
||||
|
||||
foreach ($update in $Pending.Updates) {
|
||||
[hashtable]$PendingUpdateDetails = @{};
|
||||
$PendingUpdateDetails.Add('Title', $update.Title);
|
||||
$PendingUpdateDetails.Add('Deadline', $update.Deadline);
|
||||
$PendingUpdateDetails.Add('Description', $update.Description);
|
||||
$PendingUpdateDetails.Add('IsBeta', $update.IsBeta);
|
||||
$PendingUpdateDetails.Add('IsDownloaded', $update.IsDownloaded);
|
||||
$PendingUpdateDetails.Add('IsHidden', $update.IsHidden);
|
||||
$PendingUpdateDetails.Add('IsInstalled', $update.IsInstalled);
|
||||
$PendingUpdateDetails.Add('IsMandatory', $update.IsMandatory);
|
||||
$PendingUpdateDetails.Add('IsUninstallable', $update.IsUninstallable);
|
||||
$PendingUpdateDetails.Add('Languages', $update.Languages);
|
||||
$PendingUpdateDetails.Add('LastDeploymentChangeTime', $update.LastDeploymentChangeTime);
|
||||
$PendingUpdateDetails.Add('MaxDownloadSize', $update.MaxDownloadSize);
|
||||
$PendingUpdateDetails.Add('MinDownloadSize', $update.MinDownloadSize);
|
||||
$PendingUpdateDetails.Add('MoreInfoUrls', $update.MoreInfoUrls);
|
||||
$PendingUpdateDetails.Add('MsrcSeverity', $update.MsrcSeverity);
|
||||
$PendingUpdateDetails.Add('RecommendedCpuSpeed', $update.RecommendedCpuSpeed);
|
||||
$PendingUpdateDetails.Add('RecommendedHardDiskSpace', $update.RecommendedHardDiskSpace);
|
||||
$PendingUpdateDetails.Add('RecommendedMemory', $update.RecommendedMemory);
|
||||
$PendingUpdateDetails.Add('ReleaseNotes', $update.ReleaseNotes);
|
||||
$PendingUpdateDetails.Add('SecurityBulletinIDs', $update.SecurityBulletinIDs);
|
||||
$PendingUpdateDetails.Add('SupersededUpdateIDs', $update.SupersededUpdateIDs);
|
||||
$PendingUpdateDetails.Add('SupportUrl', $update.SupportUrl);
|
||||
$PendingUpdateDetails.Add('Type', $update.Type);
|
||||
$PendingUpdateDetails.Add('UninstallationNotes', $update.UninstallationNotes);
|
||||
$PendingUpdateDetails.Add('UninstallationBehavior', $update.UninstallationBehavior);
|
||||
$PendingUpdateDetails.Add('UninstallationSteps', $update.UninstallationSteps);
|
||||
$PendingUpdateDetails.Add('KBArticleIDs', $update.KBArticleIDs);
|
||||
$PendingUpdateDetails.Add('DeploymentAction', $update.DeploymentAction);
|
||||
$PendingUpdateDetails.Add('DownloadPriority', $update.DownloadPriority);
|
||||
$PendingUpdateDetails.Add('RebootRequired', $update.RebootRequired);
|
||||
$PendingUpdateDetails.Add('IsPresent', $update.IsPresent);
|
||||
$PendingUpdateDetails.Add('CveIDs', $update.CveIDs);
|
||||
$PendingUpdateDetails.Add('BrowseOnly', $update.BrowseOnly);
|
||||
$PendingUpdateDetails.Add('PerUser', $update.PerUser);
|
||||
$PendingUpdateDetails.Add('AutoSelection', $update.AutoSelection);
|
||||
$PendingUpdateDetails.Add('AutoDownload', $update.AutoDownload);
|
||||
|
||||
[string]$name = [string]::Format('{0} [{1}]', $update.Title, $update.LastDeploymentChangeTime);
|
||||
|
||||
if ($PendingUpdateNameCache.ContainsKey($name) -eq $FALSE) {
|
||||
$PendingUpdateNameCache.Add($name, 1);
|
||||
} else {
|
||||
$PendingUpdateNameCache[$name] += 1;
|
||||
$name = [string]::Format('{0} ({1})', $name, $PendingUpdateNameCache[$name]);
|
||||
}
|
||||
|
||||
$PendingUpdates.Add($name, $PendingUpdateDetails);
|
||||
}
|
||||
} catch {
|
||||
if ($PendingUpdates.ContainsKey('Count') -eq $FALSE) {
|
||||
$PendingUpdates.Add('count', 0);
|
||||
} else {
|
||||
$PendingUpdates['count'] = 0;
|
||||
}
|
||||
$PendingUpdates.Add('error', [string]::Format(
|
||||
'Failed to query Windows Update server: {0}',
|
||||
$_.Exception.Message
|
||||
));
|
||||
}
|
||||
|
||||
return $PendingUpdates;
|
||||
}
|
||||
49
lib/provider/windows/Icinga_ProviderWindows.psm1
Normal file
49
lib/provider/windows/Icinga_ProviderWindows.psm1
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
Import-IcingaLib provider\enums;
|
||||
|
||||
function Get-IcingaWindows()
|
||||
{
|
||||
$WindowsInformations = Get-CimInstance Win32_OperatingSystem;
|
||||
|
||||
$OSProductSuite = @();
|
||||
$ProviderEnums.WindowsOSProductSuite.Keys | Where-Object {
|
||||
$_ -band $WindowsInformations.OSProductSuite
|
||||
} | ForEach-Object {
|
||||
$OSProductSuite += $ProviderEnums.WindowsOSProductSuite.Get_Item($_);
|
||||
};
|
||||
|
||||
$windows_datails = @{};
|
||||
$windows_datails.Add(
|
||||
'windows', @{
|
||||
'metadata' = @{
|
||||
'Version' = $WindowsInformations.Version;
|
||||
'CurrentTimeZone' = $WindowsInformations.CurrentTimeZone;
|
||||
'InstallDate' = $WindowsInformations.InstallDate;
|
||||
'SystemDevice' = $WindowsInformations.SystemDevice;
|
||||
'SystemDirectory' = $WindowsInformations.SystemDirectory;
|
||||
'BuildType' = $WindowsInformations.BuildType;
|
||||
'BuildNumber' = $WindowsInformations.BuildNumber;
|
||||
'OSArchitecture' = $WindowsInformations.OSArchitecture;
|
||||
'NumberOfUsers' = $WindowsInformations.NumberOfUsers;
|
||||
'OSType' = @{
|
||||
'raw' = $WindowsInformations.OSType;
|
||||
'value' = $ProviderEnums.WindowsOSType[[int]$WindowsInformations.OSType];
|
||||
};
|
||||
'OSProductSuite' = @{
|
||||
'raw' = $WindowsInformations.OSProductSuite;
|
||||
'value' = $OSProductSuite;
|
||||
};
|
||||
'ProductType' = @{
|
||||
'raw' = $WindowsInformations.ProductType;
|
||||
'value' = $ProviderEnums.WindowsProductType[[int]$WindowsInformations.ProductType];
|
||||
};
|
||||
};
|
||||
'language' = @{
|
||||
'CountryCode' = $WindowsInformations.CountryCode;
|
||||
'OSLanguage' = $WindowsInformations.OSLanguage;
|
||||
'Locale' = $WindowsInformations.Locale;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return $windows_datails;
|
||||
}
|
||||
11
lib/provider/windows/Show-IcingaWindowsData.psm1
Normal file
11
lib/provider/windows/Show-IcingaWindowsData.psm1
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function Show-IcingaWindowsData()
|
||||
{
|
||||
$WindowsInformations = Get-CimInstance Win32_OperatingSystem;
|
||||
|
||||
$windows_datails = @{};
|
||||
foreach($cpu_core in $WindowsInformations.CimInstanceProperties) {
|
||||
$windows_datails.Add($cpu_core.Name, $cpu_core.Value);
|
||||
}
|
||||
|
||||
return $windows_datails;
|
||||
}
|
||||
Loading…
Reference in a new issue