2019-07-18 08:20:23 -04:00
|
|
|
Import-Module $IncludeDir\provider\enums;
|
|
|
|
|
|
|
|
|
|
<##################################################################################################
|
|
|
|
|
################# Runspace "Show-Icinga{CPU}" #####################################################
|
|
|
|
|
##################################################################################################>
|
2019-07-17 05:28:22 -04:00
|
|
|
function Show-IcingaCPUData()
|
|
|
|
|
{
|
2019-07-17 01:52:09 -04:00
|
|
|
|
2019-07-17 05:28:22 -04:00
|
|
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
2019-07-17 01:52:09 -04:00
|
|
|
[hashtable]$PhysicalCPUData = @{};
|
|
|
|
|
|
2019-07-17 05:28:22 -04:00
|
|
|
foreach ($cpu_properties in $CPUInformation) {
|
2019-07-17 01:52:09 -04:00
|
|
|
$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;
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
<##################################################################################################
|
|
|
|
|
################# Runspace "Get-Icinga{Memory}" ###################################################
|
|
|
|
|
##################################################################################################>
|
2019-07-17 05:28:22 -04:00
|
|
|
function Get-IcingaCPUs()
|
|
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
<# Collects the most important CPU informations,
|
|
|
|
|
e.g. name, version, manufacturer#>
|
2019-07-17 05:28:22 -04:00
|
|
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
|
|
|
|
[hashtable]$CPUData = @{};
|
|
|
|
|
|
|
|
|
|
foreach ($id in $CPUInformation.DeviceID) {
|
2019-07-18 08:20:23 -04:00
|
|
|
$id=$id.trim('CPU');
|
|
|
|
|
|
2019-07-17 05:28:22 -04:00
|
|
|
$CPUData.Add(
|
|
|
|
|
$id, @{
|
|
|
|
|
'metadata' = @{
|
|
|
|
|
'Name' = $CPUInformation.Name;
|
|
|
|
|
'DeviceID' = $CPUInformation.DeviceID;
|
|
|
|
|
'ProcessorID' = $CPUInformation.ProcessorId;
|
|
|
|
|
'UniqueID' = $CPUInformation.UniqueId;
|
|
|
|
|
'Description' = $CPUInformation.Description;
|
|
|
|
|
'OtherFamilyDescription' = $CPUInformation.OtherFamilyDescription;
|
|
|
|
|
'Caption' = $CPUInformation.Caption;
|
|
|
|
|
'Version' = $CPUInformation.Version;
|
|
|
|
|
'SerialNumber' = $CPUInformation.SerialNumber;
|
|
|
|
|
'Manufacturer' = $CPUInformation.Manufacturer;
|
2019-07-18 08:20:23 -04:00
|
|
|
'NumberOfCores' = $CPUInformation.NumberOfCores;
|
|
|
|
|
'PartNumber' = $CPUInformation.PartNumber;
|
2019-07-17 05:28:22 -04:00
|
|
|
'Status' = $CPUInformation.Status;
|
|
|
|
|
'CPUStatus' = $CPUInformation.CpuStatus;
|
2019-07-18 08:20:23 -04:00
|
|
|
'Revision' = $CPUInformation.Revision;
|
|
|
|
|
'NumberOfLogicalProcessors' = $CPUInformation.NumberOfLogicalProcessors;
|
2019-07-17 05:28:22 -04:00
|
|
|
'Level'= $CPUInformation.Level;
|
2019-07-18 08:20:23 -04:00
|
|
|
'AddressWidth' = $CPUInformation.AddressWidth;
|
|
|
|
|
'Stepping' = $CPUInformation.Stepping;
|
|
|
|
|
'SocketDesignation' = $CPUInformation.SocketDesignation;
|
|
|
|
|
'Family' = @{
|
|
|
|
|
'raw' = $CPUInformation.Family;
|
|
|
|
|
'value' = $ProviderEnums.CPUFamily[[int]$CPUInformation.Family];
|
|
|
|
|
};
|
|
|
|
|
'Architecture' = @{
|
|
|
|
|
'raw' = $CPUInformation.Architecture;
|
|
|
|
|
'value' = $ProviderEnums.CPUArchitecture[[int]$CPUInformation.Architecture];
|
|
|
|
|
};
|
|
|
|
|
'ProcessorType' = @{
|
|
|
|
|
'raw' = $CPUInformation.ProcessorType;
|
|
|
|
|
'value' = $ProviderEnums.CPUProcessorType[[int]$CPUInformation.ProcessorType];
|
|
|
|
|
};
|
|
|
|
|
'StatusInfo' = @{
|
|
|
|
|
'raw' = $CPUInformation.StatusInfo;
|
|
|
|
|
'value' = $ProviderEnums.CPUStatusInfo[[int]$CPUInformation.StatusInfo];
|
|
|
|
|
};
|
|
|
|
|
'Availability' = @{
|
|
|
|
|
'raw' = $CPUInformation.Availability;
|
|
|
|
|
'value' = $ProviderEnums.CPUAvailability[[int]$CPUInformation.Availability];
|
|
|
|
|
};
|
|
|
|
|
'PowerManagementCapabilities' = @{
|
|
|
|
|
'raw' = $CPUInformation.PowerManagementCapabilities;
|
|
|
|
|
'value' = $ProviderEnums.CPUPowerManagementCapabilities[[int]$CPUInformation.PowerManagementCapabilities];
|
|
|
|
|
}
|
2019-07-17 05:28:22 -04:00
|
|
|
};
|
|
|
|
|
'errors' = @{
|
|
|
|
|
'LastErrorCode' = $CPUInformation.LastErrorCode;
|
|
|
|
|
'ErrorCleared' = $CPUInformation.ErrorCleared;
|
|
|
|
|
'ErrorDescription' = $CPUInformation.ErrorDescription;
|
2019-07-18 08:20:23 -04:00
|
|
|
'ConfigManagerErrorCode' = @{
|
|
|
|
|
'raw' = [int]$CPUInformation.ConfigManagerErrorCode;
|
|
|
|
|
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$CPUInformation.ConfigManagerErrorCode);
|
|
|
|
|
}
|
2019-07-17 05:28:22 -04:00
|
|
|
};
|
2019-07-18 08:20:23 -04:00
|
|
|
'specs' = @{
|
2019-07-17 05:28:22 -04:00
|
|
|
'LoadPercentage' = $CPUInformation.LoadPercentage;
|
|
|
|
|
'CurrentVoltage' = $CPUInformation.CurrentVoltage;
|
|
|
|
|
'ThreadCount' = $CPUInformation.ThreadCount;
|
2019-07-18 08:20:23 -04:00
|
|
|
'L3CacheSize' = $CPUInformation.L3CacheSize;
|
|
|
|
|
'L2CacheSpeed' = $CPUInformation.L2CacheSpeed;
|
|
|
|
|
'L2CacheSize' = $CPUInformation.L2CacheSize;
|
|
|
|
|
'VoltageCaps' = $CPUInformation.VoltageCaps;
|
|
|
|
|
'CurrentClockSpeed' = $CPUInformation.CurrentClockSpeed;
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
}
|
2019-07-18 08:20:23 -04:00
|
|
|
);
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
return $CPUData;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
function Get-IcingaCPUInformation()
|
2019-07-17 05:28:22 -04:00
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
<# 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 ($id in $CPUInformation.DeviceID) {
|
|
|
|
|
$CPUData.Add($id.trim('CPU'), $CPUInformation.$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
|
|
|
|
|
);
|
2019-07-17 05:28:22 -04:00
|
|
|
|
|
|
|
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
2019-07-18 08:20:23 -04:00
|
|
|
$Prefix = "CPU";
|
|
|
|
|
|
|
|
|
|
[hashtable]$CPUData = @{};
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
foreach ($id in $CPUInformation.DeviceID) {
|
|
|
|
|
$id=$id.trim('CPU');
|
|
|
|
|
$CPUData.Add(
|
|
|
|
|
$id, @{
|
|
|
|
|
'raw' = $CPUInformation.$Parameter;
|
|
|
|
|
'value' = $ProviderEnums."$Prefix$Parameter"[[int]$CPUInformation.$Parameter]
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
2019-07-18 08:20:23 -04:00
|
|
|
return $CPUData;
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
function Get-IcingaCPUErrors()
|
2019-07-17 05:28:22 -04:00
|
|
|
{
|
|
|
|
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
2019-07-18 08:20:23 -04:00
|
|
|
[hashtable]$CPUData = @{};
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
foreach ($id in $CPUInformation.DeviceID) {
|
|
|
|
|
$id=$id.trim('CPU');
|
|
|
|
|
$CPUData.Add(
|
|
|
|
|
$id, @{
|
|
|
|
|
'errors' = @{
|
|
|
|
|
'LastErrorCode' = $CPUInformation.LastErrorCode;
|
|
|
|
|
'ErrorCleared' = $CPUInformation.ErrorCleared;
|
|
|
|
|
'ErrorDescription' = $CPUInformation.ErrorDescription;
|
|
|
|
|
'ConfigManagerErrorCode' = @{
|
|
|
|
|
'raw' = [int]$CPUInformation.ConfigManagerErrorCode;
|
|
|
|
|
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$CPUInformation.ConfigManagerErrorCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
2019-07-18 08:20:23 -04:00
|
|
|
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'};
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-IcingaCPUStatusInfo()
|
|
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
$CPUStatusInfo = Get-IcingaCPUInformationWithEnums -Parameter StatusInfo;
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
return @{'value' = $CPUStatusInfo; 'name' = 'StatusInfo'};
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-IcingaCPUFamily()
|
|
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
$CPUFamily = Get-IcingaCPUInformationWithEnums -Parameter Family;
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
return @{'value' = $CPUFamily; 'name' = 'Family'};
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-IcingaCPUConfigManagerErrorCode()
|
|
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
$CPUConfigManagerErrorCode = Get-IcingaCPUInformationWithEnums -Parameter ConfigManagerErrorCode;
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
return @{'value' = $CPUConfigManagerErrorCode; 'name' = 'ConfigManagerErrorCode'};
|
2019-07-17 05:28:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-IcingaCPUAvailability()
|
|
|
|
|
{
|
2019-07-18 08:20:23 -04:00
|
|
|
$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;
|
2019-07-17 05:28:22 -04:00
|
|
|
|
2019-07-18 08:20:23 -04:00
|
|
|
return @{'value' = $CPUNumberOfLogicalProcessors; 'name' = 'NumberOfLogicalProcessors'};
|
2019-07-17 01:52:09 -04:00
|
|
|
}
|