mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added Process.psm1, Added Services.psm1; Fixed previous concept errors
This commit is contained in:
parent
1c87a62d81
commit
a64449e074
6 changed files with 374 additions and 160 deletions
|
|
@ -30,75 +30,74 @@ function Get-IcingaCPUs()
|
||||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
[hashtable]$CPUData = @{};
|
[hashtable]$CPUData = @{};
|
||||||
|
|
||||||
foreach ($id in $CPUInformation.DeviceID) {
|
foreach ($cpu in $CPUInformation) {
|
||||||
$id=$id.trim('CPU');
|
|
||||||
|
|
||||||
$CPUData.Add(
|
$CPUData.Add(
|
||||||
$id, @{
|
$cpu.DeviceID.trim('CPU'), @{
|
||||||
'metadata' = @{
|
'metadata' = @{
|
||||||
'Name' = $CPUInformation.Name;
|
'Name' = $cpu.Name;
|
||||||
'DeviceID' = $CPUInformation.DeviceID;
|
'DeviceID' = $cpu.DeviceID;
|
||||||
'ProcessorID' = $CPUInformation.ProcessorId;
|
'ProcessorID' = $cpu.ProcessorId;
|
||||||
'UniqueID' = $CPUInformation.UniqueId;
|
'UniqueID' = $cpu.UniqueId;
|
||||||
'Description' = $CPUInformation.Description;
|
'Description' = $cpu.Description;
|
||||||
'OtherFamilyDescription' = $CPUInformation.OtherFamilyDescription;
|
'OtherFamilyDescription' = $cpu.OtherFamilyDescription;
|
||||||
'Caption' = $CPUInformation.Caption;
|
'Caption' = $cpu.Caption;
|
||||||
'Version' = $CPUInformation.Version;
|
'Version' = $cpu.Version;
|
||||||
'SerialNumber' = $CPUInformation.SerialNumber;
|
'SerialNumber' = $cpu.SerialNumber;
|
||||||
'Manufacturer' = $CPUInformation.Manufacturer;
|
'Manufacturer' = $cpu.Manufacturer;
|
||||||
'NumberOfCores' = $CPUInformation.NumberOfCores;
|
'NumberOfCores' = $cpu.NumberOfCores;
|
||||||
'PartNumber' = $CPUInformation.PartNumber;
|
'PartNumber' = $cpu.PartNumber;
|
||||||
'Status' = $CPUInformation.Status;
|
'Status' = $cpu.Status;
|
||||||
'CPUStatus' = $CPUInformation.CpuStatus;
|
'CPUStatus' = $cpu.CpuStatus;
|
||||||
'Revision' = $CPUInformation.Revision;
|
'Revision' = $cpu.Revision;
|
||||||
'NumberOfLogicalProcessors' = $CPUInformation.NumberOfLogicalProcessors;
|
'NumberOfLogicalProcessors' = $cpu.NumberOfLogicalProcessors;
|
||||||
'Level'= $CPUInformation.Level;
|
'Level'= $cpu.Level;
|
||||||
'AddressWidth' = $CPUInformation.AddressWidth;
|
'AddressWidth' = $cpu.AddressWidth;
|
||||||
'Stepping' = $CPUInformation.Stepping;
|
'Stepping' = $cpu.Stepping;
|
||||||
'SocketDesignation' = $CPUInformation.SocketDesignation;
|
'SocketDesignation' = $cpu.SocketDesignation;
|
||||||
'Family' = @{
|
'Family' = @{
|
||||||
'raw' = $CPUInformation.Family;
|
'raw' = $cpu.Family;
|
||||||
'value' = $ProviderEnums.CPUFamily[[int]$CPUInformation.Family];
|
'value' = $ProviderEnums.CPUFamily[[int]$cpu.Family];
|
||||||
};
|
};
|
||||||
'Architecture' = @{
|
'Architecture' = @{
|
||||||
'raw' = $CPUInformation.Architecture;
|
'raw' = $cpu.Architecture;
|
||||||
'value' = $ProviderEnums.CPUArchitecture[[int]$CPUInformation.Architecture];
|
'value' = $ProviderEnums.CPUArchitecture[[int]$cpu.Architecture];
|
||||||
};
|
};
|
||||||
'ProcessorType' = @{
|
'ProcessorType' = @{
|
||||||
'raw' = $CPUInformation.ProcessorType;
|
'raw' = $cpu.ProcessorType;
|
||||||
'value' = $ProviderEnums.CPUProcessorType[[int]$CPUInformation.ProcessorType];
|
'value' = $ProviderEnums.CPUProcessorType[[int]$cpu.ProcessorType];
|
||||||
};
|
};
|
||||||
'StatusInfo' = @{
|
'StatusInfo' = @{
|
||||||
'raw' = $CPUInformation.StatusInfo;
|
'raw' = $cpu.StatusInfo;
|
||||||
'value' = $ProviderEnums.CPUStatusInfo[[int]$CPUInformation.StatusInfo];
|
'value' = $ProviderEnums.CPUStatusInfo[[int]$cpu.StatusInfo];
|
||||||
};
|
};
|
||||||
'Availability' = @{
|
'Availability' = @{
|
||||||
'raw' = $CPUInformation.Availability;
|
'raw' = $cpu.Availability;
|
||||||
'value' = $ProviderEnums.CPUAvailability[[int]$CPUInformation.Availability];
|
'value' = $ProviderEnums.CPUAvailability[[int]$cpu.Availability];
|
||||||
};
|
};
|
||||||
'PowerManagementCapabilities' = @{
|
'PowerManagementCapabilities' = @{
|
||||||
'raw' = $CPUInformation.PowerManagementCapabilities;
|
'raw' = $cpu.PowerManagementCapabilities;
|
||||||
'value' = $ProviderEnums.CPUPowerManagementCapabilities[[int]$CPUInformation.PowerManagementCapabilities];
|
'value' = $ProviderEnums.CPUPowerManagementCapabilities[[int]$cpu.PowerManagementCapabilities];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
'errors' = @{
|
'errors' = @{
|
||||||
'LastErrorCode' = $CPUInformation.LastErrorCode;
|
'LastErrorCode' = $cpu.LastErrorCode;
|
||||||
'ErrorCleared' = $CPUInformation.ErrorCleared;
|
'ErrorCleared' = $cpu.ErrorCleared;
|
||||||
'ErrorDescription' = $CPUInformation.ErrorDescription;
|
'ErrorDescription' = $cpu.ErrorDescription;
|
||||||
'ConfigManagerErrorCode' = @{
|
'ConfigManagerErrorCode' = @{
|
||||||
'raw' = [int]$CPUInformation.ConfigManagerErrorCode;
|
'raw' = [int]$cpu.ConfigManagerErrorCode;
|
||||||
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$CPUInformation.ConfigManagerErrorCode);
|
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$cpu.ConfigManagerErrorCode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
'specs' = @{
|
'specs' = @{
|
||||||
'LoadPercentage' = $CPUInformation.LoadPercentage;
|
'LoadPercentage' = $cpu.LoadPercentage;
|
||||||
'CurrentVoltage' = $CPUInformation.CurrentVoltage;
|
'CurrentVoltage' = $cpu.CurrentVoltage;
|
||||||
'ThreadCount' = $CPUInformation.ThreadCount;
|
'ThreadCount' = $cpu.ThreadCount;
|
||||||
'L3CacheSize' = $CPUInformation.L3CacheSize;
|
'L3CacheSize' = $cpu.L3CacheSize;
|
||||||
'L2CacheSpeed' = $CPUInformation.L2CacheSpeed;
|
'L2CacheSpeed' = $cpu.L2CacheSpeed;
|
||||||
'L2CacheSize' = $CPUInformation.L2CacheSize;
|
'L2CacheSize' = $cpu.L2CacheSize;
|
||||||
'VoltageCaps' = $CPUInformation.VoltageCaps;
|
'VoltageCaps' = $cpu.VoltageCaps;
|
||||||
'CurrentClockSpeed' = $CPUInformation.CurrentClockSpeed;
|
'CurrentClockSpeed' = $cpu.CurrentClockSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -117,8 +116,8 @@ function Get-IcingaCPUInformation()
|
||||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
[hashtable]$CPUData = @{};
|
[hashtable]$CPUData = @{};
|
||||||
|
|
||||||
foreach ($id in $CPUInformation.DeviceID) {
|
foreach ($cpu in $CPUInformation) {
|
||||||
$CPUData.Add($id.trim('CPU'), $CPUInformation.$Parameter);
|
$CPUData.Add($cpu.DeviceID.trim('CPU'), $cpu.$Parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $CPUData;
|
return $CPUData;
|
||||||
|
|
@ -137,12 +136,11 @@ function Get-IcingaCPUInformationWithEnums()
|
||||||
|
|
||||||
[hashtable]$CPUData = @{};
|
[hashtable]$CPUData = @{};
|
||||||
|
|
||||||
foreach ($id in $CPUInformation.DeviceID) {
|
foreach ($cpu in $CPUInformation) {
|
||||||
$id=$id.trim('CPU');
|
|
||||||
$CPUData.Add(
|
$CPUData.Add(
|
||||||
$id, @{
|
$cpu.DeviceID.trim('CPU'), @{
|
||||||
'raw' = $CPUInformation.$Parameter;
|
'raw' = $cpu.$Parameter;
|
||||||
'value' = $ProviderEnums."$Prefix$Parameter"[[int]$CPUInformation.$Parameter]
|
'value' = $ProviderEnums."$Prefix$Parameter"[[int]$cpu.$Parameter]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -154,17 +152,16 @@ function Get-IcingaCPUErrors()
|
||||||
$CPUInformation = Get-CimInstance Win32_Processor;
|
$CPUInformation = Get-CimInstance Win32_Processor;
|
||||||
[hashtable]$CPUData = @{};
|
[hashtable]$CPUData = @{};
|
||||||
|
|
||||||
foreach ($id in $CPUInformation.DeviceID) {
|
foreach ($cpu in $CPUInformation) {
|
||||||
$id=$id.trim('CPU');
|
|
||||||
$CPUData.Add(
|
$CPUData.Add(
|
||||||
$id, @{
|
$cpu.trim('CPU'), @{
|
||||||
'errors' = @{
|
'errors' = @{
|
||||||
'LastErrorCode' = $CPUInformation.LastErrorCode;
|
'LastErrorCode' = $cpu.LastErrorCode;
|
||||||
'ErrorCleared' = $CPUInformation.ErrorCleared;
|
'ErrorCleared' = $cpu.ErrorCleared;
|
||||||
'ErrorDescription' = $CPUInformation.ErrorDescription;
|
'ErrorDescription' = $cpu.ErrorDescription;
|
||||||
'ConfigManagerErrorCode' = @{
|
'ConfigManagerErrorCode' = @{
|
||||||
'raw' = [int]$CPUInformation.ConfigManagerErrorCode;
|
'raw' = [int]$cpu.ConfigManagerErrorCode;
|
||||||
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$CPUInformation.ConfigManagerErrorCode);
|
'value' = $ProviderEnums.CPUConfigManagerErrorCode.([int]$cpu.ConfigManagerErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -283,4 +280,24 @@ function Get-IcingaCPUNumberOfLogicalProcessors()
|
||||||
$CPUNumberOfLogicalProcessors = Get-IcingaCPUInformation -Parameter NumberOfLogicalProcessors;
|
$CPUNumberOfLogicalProcessors = Get-IcingaCPUInformation -Parameter NumberOfLogicalProcessors;
|
||||||
|
|
||||||
return @{'value' = $CPUNumberOfLogicalProcessors; 'name' = 'NumberOfLogicalProcessors'};
|
return @{'value' = $CPUNumberOfLogicalProcessors; 'name' = 'NumberOfLogicalProcessors'};
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-IcingaCPUCount()
|
||||||
|
{
|
||||||
|
<# Collects the most important CPU informations,
|
||||||
|
e.g. name, version, manufacturer#>
|
||||||
|
$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;
|
||||||
}
|
}
|
||||||
|
|
@ -106,15 +106,17 @@ function Get-IcingaDiskInformation()
|
||||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||||
[hashtable]$DiskData = @{};
|
[hashtable]$DiskData = @{};
|
||||||
|
|
||||||
foreach ($id in $DiskInformation.DeviceID) {
|
foreach ($disk in $DiskInformation) {
|
||||||
$id = $id.trimstart(".\PHYSICALDRVE");
|
$DiskData.Add($disk.DeviceID.trimstart(".\PHYSICALDRVE"), $disk.$Parameter);
|
||||||
$DiskData.Add($id.trim(), $DiskInformation.$Parameter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $DiskData;
|
return $DiskData;
|
||||||
}
|
}
|
||||||
function Get-IcingaDiskPartitions()
|
function Get-IcingaDiskPartitions()
|
||||||
{
|
{
|
||||||
|
param(
|
||||||
|
$Disk
|
||||||
|
);
|
||||||
<# Fetches all the most important informations regarding partitions
|
<# Fetches all the most important informations regarding partitions
|
||||||
e.g. physical disk; partition, size
|
e.g. physical disk; partition, size
|
||||||
, also collects partition information for Get-IcingaDisks #>
|
, also collects partition information for Get-IcingaDisks #>
|
||||||
|
|
@ -137,7 +139,15 @@ function Get-IcingaDiskPartitions()
|
||||||
|
|
||||||
$diskPartition = $diskPartition.trim("Partition #");
|
$diskPartition = $diskPartition.trim("Partition #");
|
||||||
$diskDisk = $diskDisk.trim("Disk #");
|
$diskDisk = $diskDisk.trim("Disk #");
|
||||||
|
|
||||||
|
If ([string]::IsNullOrEmpty($Disk) -eq $FALSE) {
|
||||||
|
If ([int]$Disk -ne [int]$diskDisk) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$diskPartitionSize = Get-Partition -DriveLetter $driveLetter;
|
$diskPartitionSize = Get-Partition -DriveLetter $driveLetter;
|
||||||
|
|
||||||
$PartitionDiskByDriveLetter.Add(
|
$PartitionDiskByDriveLetter.Add(
|
||||||
$driveLetter,
|
$driveLetter,
|
||||||
@{
|
@{
|
||||||
|
|
@ -182,8 +192,8 @@ function Get-IcingaDiskCapabilities
|
||||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||||
[hashtable]$DiskCapabilities = @{};
|
[hashtable]$DiskCapabilities = @{};
|
||||||
|
|
||||||
foreach ($id in $DiskInformation.Capabilities) {
|
foreach ($capabilities in $DiskInformation.Capabilities) {
|
||||||
$DiskCapabilities.Add([int]$id, $ProviderEnums.DiskCapabilities.([int]$id));
|
$DiskCapabilities.Add([int]$capabilities, $ProviderEnums.DiskCapabilities.([int]$capabilities));
|
||||||
}
|
}
|
||||||
return @{'value' = $DiskCapabilities; 'name' = 'Capabilities'};
|
return @{'value' = $DiskCapabilities; 'name' = 'Capabilities'};
|
||||||
|
|
||||||
|
|
@ -231,23 +241,21 @@ function Get-IcingaDisks {
|
||||||
e.g. size, model, sectors, cylinders
|
e.g. size, model, sectors, cylinders
|
||||||
Is dependent on Get-IcingaDiskPartitions#>
|
Is dependent on Get-IcingaDiskPartitions#>
|
||||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||||
$diskPartitionInformation = Get-IcingaDiskPartitions;
|
|
||||||
[hashtable]$DiskData = @{};
|
[hashtable]$DiskData = @{};
|
||||||
|
|
||||||
foreach ($id in $DiskInformation.DeviceID) {
|
foreach ($disk in $DiskInformation) {
|
||||||
[int]$id = $id.trimstart(".\PHYSICALDRVE");
|
$diskID = $disk.DeviceID.trimstart(".\PHYSICALDRVE");
|
||||||
|
|
||||||
$DiskData.Add(
|
$DiskData.Add(
|
||||||
$id, @{
|
$diskID, @{
|
||||||
'metadata' = @{
|
'metadata' = @{
|
||||||
'Size' = $DiskInformation.Size;
|
'Size' = $disk.Size;
|
||||||
'Model' = $DiskInformation.Model;
|
'Model' = $disk.Model;
|
||||||
'Name' = $DiskInformation.Name.trim('.\');
|
'Name' = $disk.Name.trim('.\');
|
||||||
'Manufacturer' = $DiskInformation.Manufacturer;
|
'Manufacturer' = $disk.Manufacturer;
|
||||||
'Cylinder' = $DiskInformation.TotalCylinders;
|
'Cylinder' = $disk.TotalCylinders;
|
||||||
'Sectors' = $DiskInformation.TotalSectors
|
'Sectors' = $disk.TotalSectors
|
||||||
};
|
};
|
||||||
'partitions' = $diskPartitionInformation
|
'partitions' = (Get-IcingaDiskPartitions -Disk $diskID);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,10 @@
|
||||||
3='Enabled';
|
3='Enabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<##################################################################################################
|
||||||
|
################# /lib/provider/memory.psm1 #######################################################
|
||||||
|
##################################################################################################>
|
||||||
|
|
||||||
[hashtable]$MemoryFormFactor = @{
|
[hashtable]$MemoryFormFactor = @{
|
||||||
0='Unknown';
|
0='Unknown';
|
||||||
1= 'Other';
|
1= 'Other';
|
||||||
|
|
|
||||||
|
|
@ -10,46 +10,46 @@ function Show-IcingaMemoryData ()
|
||||||
|
|
||||||
[hashtable]$MEMData = @{};
|
[hashtable]$MEMData = @{};
|
||||||
|
|
||||||
foreach($id in $MEMInformation) {
|
foreach($memory in $MEMInformation) {
|
||||||
$MEMData.Add(
|
$MEMData.Add(
|
||||||
$id.tag.trim("Physical Memory"), @{
|
$memory.tag.trim("Physical Memory"), @{
|
||||||
'Caption' = $id.Name;
|
'Caption' = $memory.Name;
|
||||||
'Description' = $id.Description;
|
'Description' = $memory.Description;
|
||||||
'Name' = $id.Name;
|
'Name' = $memory.Name;
|
||||||
'InstallDate' = $id.InstallDate;
|
'InstallDate' = $memory.InstallDate;
|
||||||
'Status' = $id.Status
|
'Status' = $memory.Status
|
||||||
'CreationClassName'= $id.CreationClassName
|
'CreationClassName'= $memory.CreationClassName
|
||||||
'Manufacturer'= $id.Manufacturer
|
'Manufacturer'= $memory.Manufacturer
|
||||||
'Model'= $id.Model
|
'Model'= $memory.Model
|
||||||
'OtherIdentifyingInfo'= $id.OtherIdentifyingInfo
|
'OtherIdentifyingInfo'= $memory.OtherIdentifyingInfo
|
||||||
'PartNumber'= $id.PartNumber
|
'PartNumber'= $memory.PartNumber
|
||||||
'PoweredOn'= $id.PoweredOn
|
'PoweredOn'= $memory.PoweredOn
|
||||||
'SerialNumber'= $id.SerialNumber
|
'SerialNumber'= $memory.SerialNumber
|
||||||
'SKU'= $id.SKU
|
'SKU'= $memory.SKU
|
||||||
'Tag'= $id.Tag
|
'Tag'= $memory.Tag
|
||||||
'Version'= $id.Version
|
'Version'= $memory.Version
|
||||||
'HotSwappable'= $id.HotSwappable
|
'HotSwappable'= $memory.HotSwappable
|
||||||
'Removable'= $id.Removable
|
'Removable'= $memory.Removable
|
||||||
'Replaceable'= $id.Replaceable
|
'Replaceable'= $memory.Replaceable
|
||||||
'FormFactor'= $id.FormFactor
|
'FormFactor'= $memory.FormFactor
|
||||||
'BankLabel'= $id.BankLabel
|
'BankLabel'= $memory.BankLabel
|
||||||
'Capacity'= $id.Capacity
|
'Capacity'= $memory.Capacity
|
||||||
'DataWidth'= $id.DataWidth
|
'DataWidth'= $memory.DataWidth
|
||||||
'InterleavePosition'= $id.InterleavePosition
|
'InterleavePosition'= $memory.InterleavePosition
|
||||||
'MemoryType'= $id.MemoryType
|
'MemoryType'= $memory.MemoryType
|
||||||
'PositionInRow'= $id.PositionInRow
|
'PositionInRow'= $memory.PositionInRow
|
||||||
'Speed'= $id.Speed
|
'Speed'= $memory.Speed
|
||||||
'TotalWidth'= $id.TotalWidth
|
'TotalWidth'= $memory.TotalWidth
|
||||||
'Attributes'= $id.Attributes
|
'Attributes'= $memory.Attributes
|
||||||
'ConfiguredClockSpeed'= $id.ConfiguredClockSpeed
|
'ConfiguredClockSpeed'= $memory.ConfiguredClockSpeed
|
||||||
'ConfiguredVoltage'= $id.ConfiguredVoltage
|
'ConfiguredVoltage'= $memory.ConfiguredVoltage
|
||||||
'DeviceLocator'= $id.DeviceLocator
|
'DeviceLocator'= $memory.DeviceLocator
|
||||||
'InterleaveDataDepth'= $id.InterleaveDataDepth
|
'InterleaveDataDepth'= $memory.InterleaveDataDepth
|
||||||
'MaxVoltage'= $id.MaxVoltage
|
'MaxVoltage'= $memory.MaxVoltage
|
||||||
'MinVoltage'= $id.MinVoltage
|
'MinVoltage'= $memory.MinVoltage
|
||||||
'SMBIOSMemoryType'= $id.SMBIOSMemoryType
|
'SMBIOSMemoryType'= $memory.SMBIOSMemoryType
|
||||||
'TypeDetail'= $id.TypeDetail
|
'TypeDetail'= $memory.TypeDetail
|
||||||
'PSComputerName'= $id.PSComputerName
|
'PSComputerName'= $memory.PSComputerName
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -66,57 +66,57 @@ function Get-IcingaMemory ()
|
||||||
|
|
||||||
[hashtable]$MEMData = @{};
|
[hashtable]$MEMData = @{};
|
||||||
|
|
||||||
foreach($id in $MEMInformation) {
|
foreach($memory in $MEMInformation) {
|
||||||
$MEMData.Add(
|
$MEMData.Add(
|
||||||
$id.tag.trim("Physical Memory"), @{
|
$memory.tag.trim("Physical Memory"), @{
|
||||||
'metadata' = @{
|
'metadata' = @{
|
||||||
'Caption' = $id.Name;
|
'Caption' = $memory.Name;
|
||||||
'Description'= $id.Description;
|
'Description'= $memory.Description;
|
||||||
'Manufacturer'= $id.Manufacturer;
|
'Manufacturer'= $memory.Manufacturer;
|
||||||
'Model'= $id.Model;
|
'Model'= $memory.Model;
|
||||||
'OtherIdentifyingInfo'= $id.OtherIdentifyingInfo;
|
'OtherIdentifyingInfo'= $memory.OtherIdentifyingInfo;
|
||||||
'PartNumber'= $id.PartNumber;
|
'PartNumber'= $memory.PartNumber;
|
||||||
'SerialNumber'= $id.SerialNumber;
|
'SerialNumber'= $memory.SerialNumber;
|
||||||
'Tag'= $id.Tag;
|
'Tag'= $memory.Tag;
|
||||||
'SMBIOSMemoryType'= $id.SMBIOSMemoryType;
|
'SMBIOSMemoryType'= $memory.SMBIOSMemoryType;
|
||||||
'DeviceLocator' = $id.DeviceLocator;
|
'DeviceLocator' = $memory.DeviceLocator;
|
||||||
'PositionInRow' = $id.PositionInRow;
|
'PositionInRow' = $memory.PositionInRow;
|
||||||
'Version' = $id.Version;
|
'Version' = $memory.Version;
|
||||||
'PoweredOn' = $id.PoweredOn;
|
'PoweredOn' = $memory.PoweredOn;
|
||||||
'Status' = $id.Status;
|
'Status' = $memory.Status;
|
||||||
'InstallDate' = $id.InstallDate;
|
'InstallDate' = $memory.InstallDate;
|
||||||
'BankLabel' = $id.BankLabel;
|
'BankLabel' = $memory.BankLabel;
|
||||||
'InterleaveDataDepth' = $id.InterleaveDataDepth;
|
'InterleaveDataDepth' = $memory.InterleaveDataDepth;
|
||||||
'Attributes' = $id.Attributes;
|
'Attributes' = $memory.Attributes;
|
||||||
'Replaceable' = $id.Replaceable;
|
'Replaceable' = $memory.Replaceable;
|
||||||
'Removable' = $id.Removable;
|
'Removable' = $memory.Removable;
|
||||||
'HotSwappable' = $id.HotSwappable;
|
'HotSwappable' = $memory.HotSwappable;
|
||||||
'FormFactor' = @{
|
'FormFactor' = @{
|
||||||
'raw' = $id.FormFactor;
|
'raw' = $memory.FormFactor;
|
||||||
'value' = $ProviderEnums.MemoryFormFactor[[int]$id.FormFactor];
|
'value' = $ProviderEnums.MemoryFormFactor[[int]$memory.FormFactor];
|
||||||
};
|
};
|
||||||
'InterleavePosition' = @{
|
'InterleavePosition' = @{
|
||||||
'raw' = $id.InterleavePosition;
|
'raw' = $memory.InterleavePosition;
|
||||||
'value' = $ProviderEnums.MemoryInterleavePosition[[int]$id.InterleavePosition];
|
'value' = $ProviderEnums.MemoryInterleavePosition[[int]$memory.InterleavePosition];
|
||||||
};
|
};
|
||||||
'MemoryType' = @{
|
'MemoryType' = @{
|
||||||
'raw' = $id.MemoryType;
|
'raw' = $memory.MemoryType;
|
||||||
'value' = $ProviderEnums.MemoryMemoryType[[int]$id.MemoryType];
|
'value' = $ProviderEnums.MemoryMemoryType[[int]$memory.MemoryType];
|
||||||
};
|
};
|
||||||
'TypeDetail' = @{
|
'TypeDetail' = @{
|
||||||
'raw' = $id.TypeDetail;
|
'raw' = $memory.TypeDetail;
|
||||||
'value' = $ProviderEnums.MemoryTypeDetail[[int]$id.TypeDetail];
|
'value' = $ProviderEnums.MemoryTypeDetail[[int]$memory.TypeDetail];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'specs' = @{
|
'specs' = @{
|
||||||
'MaxVoltage' = $id.MaxVoltage;
|
'MaxVoltage' = $memory.MaxVoltage;
|
||||||
'MinVoltage' = $id.MinVoltage;
|
'MinVoltage' = $memory.MinVoltage;
|
||||||
'ConfiguredVoltage' = $id.ConfiguredVoltage;
|
'ConfiguredVoltage' = $memory.ConfiguredVoltage;
|
||||||
'ConfiguredClockSpeed' = $id.ConfiguredClockSpeed;
|
'ConfiguredClockSpeed' = $memory.ConfiguredClockSpeed;
|
||||||
'TotalWidth' = $id.TotalWidth;
|
'TotalWidth' = $memory.TotalWidth;
|
||||||
'DataWidth' = $id.DataWidth;
|
'DataWidth' = $memory.DataWidth;
|
||||||
'Speed' = $id.Speed;
|
'Speed' = $memory.Speed;
|
||||||
'Capacity' = $id.Capacity;
|
'Capacity' = $memory.Capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -133,8 +133,8 @@ function Get-IcingaMemoryInformation()
|
||||||
$MEMInformation = Get-CimInstance Win32_PhysicalMemory;
|
$MEMInformation = Get-CimInstance Win32_PhysicalMemory;
|
||||||
[hashtable]$MEMData = @{};
|
[hashtable]$MEMData = @{};
|
||||||
|
|
||||||
foreach ($id in $MEMInformation) {
|
foreach ($memory in $MEMInformation) {
|
||||||
$MEMData.Add($id.tag.trim("Physical Memory"), $id.$Parameter);
|
$MEMData.Add($memory.tag.trim("Physical Memory"), $memory.$Parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $MEMData;
|
return $MEMData;
|
||||||
|
|
|
||||||
124
lib/provider/process.psm1
Normal file
124
lib/provider/process.psm1
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
Import-Module $IncludeDir\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 = @{};
|
||||||
|
#$NumberOfCPUThreads = $Icinga2.System.NumberOfCPUThreads;
|
||||||
|
|
||||||
|
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;
|
||||||
|
# Code Stolli below
|
||||||
|
|
||||||
|
foreach ($NameID in $ProcessUniqueList.Name) {
|
||||||
|
$ProcessIDsBasedOnName = (Get-WmiObject Win32_Process -Filter name="'${NameID}'").ProcessID;
|
||||||
|
$ProcessIDsByName.Add($NameID,$ProcessIDsBasedOnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($id in $ProcessUniqueList) {
|
||||||
|
$nameid = $id.name;
|
||||||
|
$ProcessNamesUnique.Add(
|
||||||
|
$id.Name.trim(".exe"), @{
|
||||||
|
'processlist' = @{
|
||||||
|
$ProcessIDsByName.Item("$nameid") = "metadata";
|
||||||
|
};
|
||||||
|
'perfdata' = @{
|
||||||
|
'lawl' = 'lol';
|
||||||
|
'lel' = 'lel';
|
||||||
|
'lol' = 'eyooo';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$ProcessData.Add('Process Count', $ProcessInformation.Count);
|
||||||
|
$ProcessData.add('Processes', $ProcessNamesUnique);
|
||||||
|
|
||||||
|
return $ProcessData;
|
||||||
|
}
|
||||||
61
lib/provider/services.psm1
Normal file
61
lib/provider/services.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;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue