mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Structure Change; Added Updates -> hotfix, pending, installing
This commit is contained in:
parent
2c90d9b990
commit
f78b8bef62
15 changed files with 386 additions and 277 deletions
|
|
@ -1,25 +1,4 @@
|
|||
Import-Module $IncludeDir\provider\enums;
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Show-Icinga{BIOS}" ####################################################
|
||||
##################################################################################################>
|
||||
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;
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Get-Icinga{BIOS}" #####################################################
|
||||
##################################################################################################>
|
||||
function Get-IcingaBios()
|
||||
{
|
||||
<# Collects the most important BIOS informations,
|
||||
|
|
@ -51,6 +30,45 @@ function Get-IcingaBios()
|
|||
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;
|
||||
|
|
@ -105,23 +123,3 @@ function Get-IcingaBiosSoftwareElementID()
|
|||
$bios = Get-CimInstance Win32_BIOS;
|
||||
return @{'value' = $bios.SoftwareElementID; 'name' = 'SoftwareElementID'};
|
||||
}
|
||||
|
||||
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'};
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,28 +1,4 @@
|
|||
Import-Module $IncludeDir\provider\enums;
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Show-Icinga{CPU}" #####################################################
|
||||
##################################################################################################>
|
||||
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;
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Get-Icinga{Memory}" ###################################################
|
||||
##################################################################################################>
|
||||
function Get-IcingaCPUs()
|
||||
{
|
||||
<# Collects the most important CPU informations,
|
||||
|
|
@ -284,8 +260,8 @@ function Get-IcingaCPUNumberOfLogicalProcessors()
|
|||
|
||||
function Get-IcingaCPUCount()
|
||||
{
|
||||
<# Collects the most important CPU informations,
|
||||
e.g. name, version, manufacturer#>
|
||||
<# 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) {
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,99 +1,5 @@
|
|||
Import-Module $IncludeDir\provider\enums;
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Show-Icinga{Disk}" ####################################################
|
||||
##################################################################################################>
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
function Show-IcingaDiskPhysical()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
return $PhysicalDiskData;
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Get-Icinga{Disk}" ####################################################
|
||||
##################################################################################################>
|
||||
|
||||
function Get-IcingaDiskInformation()
|
||||
{
|
||||
<# Fetches the information for other more specific Get-IcingaDisk-functions
|
||||
|
|
@ -160,33 +66,6 @@ function Get-IcingaDiskPartitions()
|
|||
return $PartitionDiskByDriveLetter;
|
||||
}
|
||||
|
||||
#Code-Snippen that still exists for LordHepipud's amusement
|
||||
function Get-IcingaDiskPartitionSize()
|
||||
{
|
||||
param([switch]$sorted);
|
||||
|
||||
[hashtable]$PartitionSizeByDriveLetter = @{};
|
||||
|
||||
# Should be dependent on the driveLetters returned in: "Show-IcingaDiskData"
|
||||
for ($test = 0; $test -lt 26; $test++)
|
||||
{
|
||||
$DiskDriveLetter = ([char](65 + $test))
|
||||
$PartitionSize = (Get-Partition -DriveLetter $DiskDriveLetter -ErrorAction 'silentlycontinue').Size;
|
||||
if ($null -eq $PartitionSize)
|
||||
{
|
||||
$PartitionSize = "0";
|
||||
}
|
||||
$PartitionSizeByDriveLetter.Add("$DiskDriveLetter", $PartitionSize);
|
||||
}
|
||||
|
||||
$output = $PartitionSizeByDriveLetter;
|
||||
|
||||
if ($sorted) {
|
||||
$output = $PartitionSizeByDriveLetter.GetEnumerator() | Sort-Object name;
|
||||
}
|
||||
|
||||
return @{'value' = $output; 'name' = 'Size'};
|
||||
}
|
||||
function Get-IcingaDiskCapabilities
|
||||
{
|
||||
$DiskInformation = Get-CimInstance Win32_DiskDrive;
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
@ -1,63 +1,4 @@
|
|||
Import-Module $IncludeDir\provider\enums;
|
||||
|
||||
<##################################################################################################
|
||||
################# Runspace "Show-Icinga{Memory}" ##################################################
|
||||
##################################################################################################>
|
||||
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;
|
||||
}
|
||||
<##################################################################################################
|
||||
################# Runspace "Get-Icinga{Memory}" ###################################################
|
||||
##################################################################################################>
|
||||
function Get-IcingaMemory ()
|
||||
{
|
||||
<# Collects the most important Memory informations,
|
||||
|
|
@ -127,6 +68,9 @@ function Get-IcingaMemory ()
|
|||
|
||||
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
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ function Get-IcingaProcessData {
|
|||
[hashtable]$ProcessList = @{};
|
||||
[hashtable]$ProcessNamesUnique = @{};
|
||||
[hashtable]$ProcessIDsByName = @{};
|
||||
#$NumberOfCPUThreads = $Icinga2.System.NumberOfCPUThreads;
|
||||
|
||||
foreach ($process in $ProcessInformation) {
|
||||
[string]$processName = $process.Name.Replace('.exe', '');
|
||||
|
|
@ -92,33 +91,5 @@ function Get-IcingaProcessData {
|
|||
$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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
11
lib/provider/windows/Icinga_ProviderWindows.psm1
Normal file
11
lib/provider/windows/Icinga_ProviderWindows.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