mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
cpu first draft
This commit is contained in:
parent
ec6b71c5b2
commit
41fd4bb3a0
3 changed files with 326 additions and 6 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
function Show-IcingaCPUData(){
|
function Show-IcingaCPUData()
|
||||||
|
{
|
||||||
|
|
||||||
$CPUInformations = Get-CimInstance Win32_Processor;
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
[hashtable]$PhysicalCPUData = @{};
|
[hashtable]$PhysicalCPUData = @{};
|
||||||
|
|
||||||
foreach ($cpu_properties in $CPUInformations) {
|
foreach ($cpu_properties in $CPUInformation) {
|
||||||
$cpu_datails = @{};
|
$cpu_datails = @{};
|
||||||
foreach($cpu_core in $cpu_properties.CimInstanceProperties) {
|
foreach($cpu_core in $cpu_properties.CimInstanceProperties) {
|
||||||
$cpu_datails.Add($cpu_core.Name, $cpu_core.Value);
|
$cpu_datails.Add($cpu_core.Name, $cpu_core.Value);
|
||||||
|
|
@ -13,3 +14,120 @@ foreach ($cpu_properties in $CPUInformations) {
|
||||||
|
|
||||||
return $PhysicalCPUData;
|
return $PhysicalCPUData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUs()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUData = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.DeviceID) {
|
||||||
|
$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;
|
||||||
|
'Number of Cores' = $CPUInformation.NumberOfCores;
|
||||||
|
'Family' = $CPUFamily.Family;
|
||||||
|
'Architecture' = $CPUArchitecture.Architecture;
|
||||||
|
'ProcessorType' = $CPUProcessorType.ProcessorType;
|
||||||
|
'StatusInfo' = $CPUStatusInfo.StatusInfo;
|
||||||
|
'Status' = $CPUInformation.Status;
|
||||||
|
'CPUStatus' = $CPUInformation.CpuStatus;
|
||||||
|
'NumberOfLogicalProcessors' = $CPUStatusInfo.NumberOfLogicalProcessors;
|
||||||
|
'Level'= $CPUInformation.Level;
|
||||||
|
'Availability' = $CPUAvailability.Availability;
|
||||||
|
|
||||||
|
};
|
||||||
|
'errors' = @{
|
||||||
|
'LastErrorCode' = $CPUInformation.LastErrorCode;
|
||||||
|
'ErrorCleared' = $CPUInformation.ErrorCleared;
|
||||||
|
'ErrorDescription' = $CPUInformation.ErrorDescription;
|
||||||
|
'ConfigManagerErrorCode' = $CPUConfigManagerErrorCode.ConfigManagerErrorCode;
|
||||||
|
};
|
||||||
|
'perfdata' = @{
|
||||||
|
'LoadPercentage' = $CPUInformation.LoadPercentage;
|
||||||
|
'CurrentVoltage' = $CPUInformation.CurrentVoltage;
|
||||||
|
'ThreadCount' = $CPUInformation.ThreadCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $CPUData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Get-IcingaCPUArchitecture()
|
||||||
|
{
|
||||||
|
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUArchitecture = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.Architecture) {
|
||||||
|
$CPUArchitecture.Add([int]$id, $ProviderEnums.CPUArchitecture.([int]$id));
|
||||||
|
}
|
||||||
|
return @{'value' = $CPUArchitecture; 'name' = 'Architecture'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUProcessorType()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUProcessorType = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.ProcessorType) {
|
||||||
|
$CPUProcessorType.Add([int]$id, $ProviderEnums.CPUProcessorType.([int]$id));
|
||||||
|
}
|
||||||
|
return @{'value' = $CPUProcessorType; 'name' = 'ProcessorType'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUStatusInfo()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUStatusInfo = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.StatusInfo) {
|
||||||
|
$CPUStatusInfo.Add([int]$id, $ProviderEnums.CPUStatusInfo.([int]$id));
|
||||||
|
}
|
||||||
|
return @{'value' = $CPUStatusInfo; 'name' = 'StatusInfo'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUFamily()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUFamily = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.Family) {
|
||||||
|
$CPUFamily.Add([int]$id, $ProviderEnums.CPUFamily.([int]$id));
|
||||||
|
}
|
||||||
|
return @{'value' = $CPUFamily; 'name' = 'Family'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUConfigManagerErrorCode()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUConfigManagerErrorCode = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.ConfigManagerErrorCode) {
|
||||||
|
$CPUConfigManagerErrorCode.Add([int]$id, $ProviderEnums.CPUConfigManagerErrorCode.([int]$id));
|
||||||
|
}
|
||||||
|
return @{'value' = $CPUConfigManagerErrorCode; 'name' = 'ConfigManagerErrorCode'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUAvailability()
|
||||||
|
{
|
||||||
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
|
[hashtable]$CPUAvailability = @{};
|
||||||
|
|
||||||
|
foreach ($id in $CPUInformation.Availability) {
|
||||||
|
$CPUAvailability.Add([int]$id, $ProviderEnums.CPUAvailability.([int]$id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return @{'value' = $CPUAvailability; 'name' = 'Availability'};
|
||||||
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ function Get-IcingaDiskCapabilities
|
||||||
[hashtable]$DiskCapabilities = @{};
|
[hashtable]$DiskCapabilities = @{};
|
||||||
|
|
||||||
foreach ($id in $DiskInformation.Capabilities) {
|
foreach ($id in $DiskInformation.Capabilities) {
|
||||||
$DiskCapabilities.Add([int]$id, $ProviderEnums.Capabilities.([int]$id));
|
$DiskCapabilities.Add([int]$id, $ProviderEnums.DiskCapabilities.([int]$id));
|
||||||
}
|
}
|
||||||
return @{'value' = $DiskCapabilities; 'name' = 'Capabilities'};
|
return @{'value' = $DiskCapabilities; 'name' = 'Capabilities'};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
63 = 'Reserved for system vendor'
|
63 = 'Reserved for system vendor'
|
||||||
}
|
}
|
||||||
|
|
||||||
[hashtable]$Capabilities = @{
|
[hashtable]$DiskCapabilities = @{
|
||||||
0 = 'Unknown';
|
0 = 'Unknown';
|
||||||
1 = 'Other';
|
1 = 'Other';
|
||||||
2 = 'Sequential Access';
|
2 = 'Sequential Access';
|
||||||
|
|
@ -81,9 +81,211 @@
|
||||||
12 = 'Predismount Eject Not Required'
|
12 = 'Predismount Eject Not Required'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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]$ProviderEnums = @{
|
[hashtable]$ProviderEnums = @{
|
||||||
BiosCharacteristics = $BiosCharacteristics;
|
BiosCharacteristics = $BiosCharacteristics;
|
||||||
Capabilities = $Capabilities;
|
DiskCapabilities = $DiskCapabilities;
|
||||||
|
CPUArchitecture = $CPUArchitecture;
|
||||||
|
CPUProcessorType = $CPUProcessorType;
|
||||||
|
CPUStatusInfo = $CPUStatusInfo;
|
||||||
|
CPUFamily = $CPUFamily;
|
||||||
|
CPUConfigManagerErrorCode = $CPUConfigManagerErrorCode;
|
||||||
|
CPUAvailability = $CPUAvailability;
|
||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Variable @('ProviderEnums');
|
Export-ModuleMember -Variable @('ProviderEnums');
|
||||||
Loading…
Reference in a new issue