mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Removes plugins from framework
This commit is contained in:
parent
901a3c4fe3
commit
2e340deee1
38 changed files with 0 additions and 3393 deletions
|
|
@ -1,27 +0,0 @@
|
|||
Import-IcingaLib provider\bios;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Finds out the Bios Serial
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckBiosSerial returns either the Bios Serial or nothing.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to find out the Bios Serial of a given system
|
||||
Either the a Bios Serial is returned or not. Thereby the Check is always okay.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckBiosSerial
|
||||
[OK]: SerialNumber is 1234-5678-9101-1121-3141-5161-7100
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckBiosSerial()
|
||||
{
|
||||
$Bios = Get-IcingaBiosSerialNumber;
|
||||
$BiosCheck = New-IcingaCheck -Name ([string]::Format('BIOS {0}', $Bios.Name)) -Value $Bios.Value -NoPerfData;
|
||||
return (New-IcingaCheckresult -Check $BiosCheck -NoPerfData $TRUE -Compile);
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
Import-IcingaLib core\perfcounter;
|
||||
Import-IcingaLib core\tools;
|
||||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks cpu usage of cores.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckCPU returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g A system has 4 cores, each running at 60% usage, WARNING is set to 50%, CRITICAL is set to 75%. In this case the check will return WARNING.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check on the current cpu usage of a specified core.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckCpu -Warning 50 -Critical 75
|
||||
[OK]: Check package "CPU Load" is [OK]
|
||||
| 'Core #0'=4,588831%;50;75;0;100 'Core #1'=0,9411243%;50;75;0;100 'Core #2'=11,53223%;50;75;0;100 'Core #3'=4,073013%;50;75;0;100
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckCpu -Warning 50 -Critical 75 -Core 1
|
||||
[OK]: Check package "CPU Load" is [OK]
|
||||
| 'Core #1'=2,612651%;50;75;0;100
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.PARAMETER Core
|
||||
Used to specify a single core to check on.
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckCPU()
|
||||
{
|
||||
param(
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[string]$Core = '*',
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$CpuCounter = New-IcingaPerformanceCounter -Counter ([string]::Format('\Processor({0})\% processor time', $Core));
|
||||
$CpuPackage = New-IcingaCheckPackage -Name 'CPU Load' -OperatorAnd -Verbose $Verbosity;
|
||||
$CpuCount = ([string](Get-IcingaCpuCount)).Length;
|
||||
|
||||
if ($CpuCounter.Counters.Count -ne 0) {
|
||||
foreach ($counter in $CpuCounter.Counters) {
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $counter.Instance.Replace('_', '') -Digits $CpuCount -Symbol ' '))) -Value $counter.Value().Value -Unit '%';
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CpuPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
} else {
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Core {0}', (Format-IcingaDigitCount $Core.Replace('_', '') -Digits $CpuCount -Symbol ' '))) -Value $CpuCounter.Value().Value -Unit '%';
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CpuPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckResult -Name 'CPU Load' -Check $CpuPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Checks hash against filehash of a file
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckCheckSum returns either 'OK' or 'CRITICAL', whether the check matches or not.
|
||||
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check a hash against a filehash of a file, to determine whether changes have occured.
|
||||
Based on the match result the status will change between 'OK' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckCheckSum -Path "C:\Users\Icinga\Downloads\test.txt"
|
||||
[OK] CheckSum C:\Users\Icinga\Downloads\test.txt is 008FB84A017F5DFDAF038DB2FDD6934E6E5D9CD3C7AACE2F2168D7D93AF51E4B
|
||||
|0
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckCheckSum -Path "C:\Users\Icinga\Downloads\test.txt" -Hash 008FB84A017F5DFDAF038DB2FDD6934E6E5D9CD3C7AACE2F2168D7D93AF51E4B
|
||||
[OK] CheckSum C:\Users\Icinga\Downloads\test.txt is 008FB84A017F5DFDAF038DB2FDD6934E6E5D9CD3C7AACE2F2168D7D93AF51E4B|
|
||||
0
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckCheckSum -Path "C:\Users\Icinga\Downloads\test.txt" -Hash 008FB84A017F5DFDAF038DB2FDD6934E6E5D
|
||||
[CRITICAL] CheckSum C:\Users\Icinga\Downloads\test.txt 008FB84A017F5DFDAF038DB2FDD6934E6E5D9CD3C7AACE2F2168D7D93AF51E4B is not matching 008FB84A017F5DFDAF038DB2FDD6934E6E5D
|
||||
|
|
||||
2
|
||||
.PARAMETER WarningBytes
|
||||
Used to specify a string to the path of a file, which will be checked.
|
||||
|
||||
The string has to be like "C:\Users\Icinga\test.txt"
|
||||
|
||||
.PARAMETER Algorithm
|
||||
Used to specify a string, which contains the algorithm to be used.
|
||||
|
||||
Allowed algorithms: 'SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5'
|
||||
|
||||
.INPUTS
|
||||
System.String
|
||||
|
||||
.OUTPUTS
|
||||
System.String
|
||||
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckCheckSum()
|
||||
{
|
||||
param(
|
||||
[string]$Path = $null,
|
||||
[ValidateSet('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5')]
|
||||
[string]$Algorithm = 'SHA256',
|
||||
[string]$Hash = $null,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
[string]$FileHash = (Get-FileHash $Path -Algorithm $Algorithm).Hash
|
||||
$CheckSumCheck = New-IcingaCheck -Name "CheckSum $Path" -Value $FileHash;
|
||||
|
||||
If(([string]::IsNullOrEmpty($Hash)) -eq $FALSE){
|
||||
$CheckSumCheck.CritIfNotMatch($Hash) | Out-Null;
|
||||
}
|
||||
|
||||
return (New-IcingaCheckresult -Check $CheckSumCheck -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
Import-IcingaLib provider\directory;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how many files are in a directory.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckDirectory returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g 'C:\Users\Icinga\Backup' contains 200 files, WARNING is set to 150, CRITICAL is set to 300. In this case the check will return CRITICAL
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check how many files and directories are within are specified path.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckDirectory -Path "C:\Users\Icinga\Downloads" -Warning 20 -Critical 30 -Verbosity 3
|
||||
[OK]: Check package "C:\Users\Icinga\Downloads" is [OK] (Match All)
|
||||
\_ [OK]: C:\Users\Icinga\Downloads is 19
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckDirectory -Path "C:\Users\Icinga\Downloads" -Warning 20 -Critical 30 -Verbosity 3
|
||||
[WARNING]: Check package "C:\Users\Icinga\Downloads" is [WARNING] (Match All)
|
||||
\_ [WARNING]: C:\Users\Icinga\Downloads is 24
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckDirectory -Path "C:\Users\Icinga\Downloads" -Warning 20 -Critical 30 -Verbosity 3 -ChangeYoungerThen 20d -ChangeOlderThen 10d
|
||||
[OK]: Check package "C:\Users\Icinga\Downloads" is [OK] (Match All)
|
||||
\_ [OK]: C:\Users\Icinga\Downloads is 1
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckDirectory -Path "C:\Users\Icinga\Downloads" -FileNames "*.txt","*.sql" -Warning 20 -Critical 30 -Verbosity 3
|
||||
[OK]: Check package "C:\Users\Icinga\Downloads" is [OK] (Match All)
|
||||
\_ [OK]: C:\Users\Icinga\Downloads is 4
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.PARAMETER Path
|
||||
Used to specify a path.
|
||||
e.g. 'C:\Users\Icinga\Downloads'
|
||||
.PARAMETER FileNames
|
||||
Used to specify an array of filenames or expressions to match against.
|
||||
|
||||
e.g '*.txt', '*.sql' # Fiends all files ending with .txt and .sql
|
||||
.PARAMETER Recurse
|
||||
A switch, which can be set to filter through directories recursively.
|
||||
.PARAMETER ChangeYoungerThen
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have a change date younger then 20 days are considered within the check.
|
||||
.PARAMETER ChangeOlderThen
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have a change date older then 20 days are considered within the check.
|
||||
.PARAMETER CreationYoungerThen
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have a creation date younger then 20 days are considered within the check.
|
||||
.PARAMETER CreationOlderThen
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have a creation date older then 20 days are considered within the check.
|
||||
|
||||
.PARAMETER ChangeTimeEqual
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have been changed 20 days ago are considered within the check.
|
||||
|
||||
.PARAMETER CreationTimeEqual
|
||||
String that expects input format like "20d", which translates to 20 days. Allowed units: ms, s, m, h, d, w, M, y.
|
||||
|
||||
Thereby all files which have been created 20 days ago are considered within the check.
|
||||
|
||||
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckDirectory()
|
||||
{
|
||||
param(
|
||||
[string]$Path,
|
||||
[array]$FileNames,
|
||||
[switch]$Recurse,
|
||||
$Critical = $null,
|
||||
$Warning = $null,
|
||||
[string]$ChangeTimeEqual,
|
||||
[string]$ChangeYoungerThan,
|
||||
[string]$ChangeOlderThan,
|
||||
[string]$CreationTimeEqual,
|
||||
[string]$CreationOlderThan,
|
||||
[string]$CreationYoungerThan,
|
||||
[string]$FileSizeGreaterThan,
|
||||
[string]$FileSizeSmallerThan,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0,
|
||||
[switch]$NoPerfData
|
||||
);
|
||||
|
||||
$DirectoryData = Get-IcingaDirectoryAll -Path $Path -FileNames $FileNames -Recurse $Recurse `
|
||||
-ChangeYoungerThan $ChangeYoungerThan -ChangeOlderThan $ChangeOlderThan `
|
||||
-CreationYoungerThan $CreationYoungerThan -CreationOlderThan $CreationOlderThan `
|
||||
-CreationTimeEqual $CreationTimeEqual -ChangeTimeEqual $ChangeTimeEqual;
|
||||
$DirectoryCheck = New-IcingaCheck -Name 'File Count' -Value $DirectoryData.Count;
|
||||
|
||||
$DirectoryCheck.WarnOutOfRange(
|
||||
($Warning)
|
||||
).CritOutOfRange(
|
||||
($Critical)
|
||||
) | Out-Null;
|
||||
|
||||
$DirectoryPackage = New-IcingaCheckPackage -Name $Path -OperatorAnd -Checks $DirectoryCheck -Verbose $Verbosity;
|
||||
|
||||
return (New-IcingaCheckresult -Check $DirectoryPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how many eventlog occurences of a given type there are.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckEventlog returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g Eventlog returns 500 entrys with the specified parameters, WARNING is set to 200, CRITICAL is set to 800. Thereby the check will return WARNING.
|
||||
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This Module is intended to be used to check how many eventlog occurences of a given type there are.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckEventlog -LogName Application -IncludeEntryType Warning -Warning 100 -Critical 1000
|
||||
[WARNING]: Check package "EventLog" is [WARNING]
|
||||
| 'EventId_508'=2c;; 'EventId_2002'=586c;; 'EventId_63'=6c;; 'EventId_2248216578'=1364c;; 'EventId_1008'=1745c;; 'EventId_2147489653'=1c;; 'EventId_636'=3c;; 'EventId_2147484656'=1c;; 'EventId_2147489654'=1c;; 'EventId_640'=3c;; 'EventId_533'=1c;;
|
||||
1
|
||||
PS> Invoke-IcingaCheckEventlog -LogName Application -IncludeEntryType Warning -Warning 100 -Critical 1000
|
||||
[OK]: Check package "EventLog" is [OK]|
|
||||
0
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckEventlog -LogName Application -IncludeEntryType Warning -Warning 100 -Critical 1000
|
||||
[WARNING]: Check package "EventLog" is [WARNING]
|
||||
| 'EventId_508'=2c;; 'EventId_2002'=586c;; 'EventId_63'=6c;; 'EventId_2248216578'=1364c;; 'EventId_1008'=1745c;; 'EventId_2147489653'=1c;; 'EventId_636'=3c;; 'EventId_2147484656'=1c;; 'EventId_2147489654'=1c;; 'EventId_640'=3c;; 'EventId_533'=1c;;
|
||||
1
|
||||
PS> Invoke-IcingaCheckEventlog -LogName Application -IncludeEntryType Warning -Warning 100 -Critical 1000 -DisableTimeCache
|
||||
[WARNING]: Check package "EventLog" is [WARNING]
|
||||
| 'EventId_508'=2c;; 'EventId_2002'=586c;; 'EventId_63'=6c;; 'EventId_2248216578'=1364c;; 'EventId_1008'=1745c;; 'EventId_2147489653'=1c;; 'EventId_636'=3c;; 'EventId_2147484656'=1c;; 'EventId_2147489654'=1c;; 'EventId_640'=3c;; 'EventId_533'=1c;;
|
||||
1
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold.
|
||||
.PARAMETER LogName
|
||||
Used to specify a certain log.
|
||||
.PARAMETER IncludeEventId
|
||||
Used to specify an array of events identified by their id to be included.
|
||||
.PARAMETER ExcludeEventId
|
||||
Used to specify an array of events identified by their id to be excluded.
|
||||
.PARAMETER IncludeUsername
|
||||
Used to specify an array of usernames within the eventlog to be included.
|
||||
.PARAMETER ExcludeUsername
|
||||
Used to specify an array of usernames within the eventlog to be excluded.
|
||||
.PARAMETER IncludeEntryType
|
||||
Used to specify an array of entry types within the eventlog to be included.
|
||||
.PARAMETER ExcludeEntryType
|
||||
Used to specify an array of entry types within the eventlog to be excluded.
|
||||
.PARAMETER IncludeMessage
|
||||
Used to specify an array of messages within the eventlog to be included.
|
||||
.PARAMETER ExcludeMessage
|
||||
Used to specify an array of messages within the eventlog to be excluded.
|
||||
.PARAMETER After
|
||||
Used to specify a date like dd.mm.yyyy and every eventlog entry after that date will be considered.
|
||||
.PARAMETER Before
|
||||
Used to specify a date like dd.mm.yyyy and every eventlog entry before that date will be considered.
|
||||
.PARAMETER DisableTimeCache
|
||||
Switch to disable the time cache on a check. If this parameter is set the time cache is disabled.
|
||||
After the check has been run once, the next check instance will filter through the eventlog from the point the last check ended.
|
||||
This is due to the time cache, when disabled the whole eventlog is checked instead.
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckEventlog()
|
||||
{
|
||||
param(
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[string]$LogName,
|
||||
[array]$IncludeEventId,
|
||||
[array]$ExcludeEventId,
|
||||
[array]$IncludeUsername,
|
||||
[array]$ExcludeUsername,
|
||||
[array]$IncludeEntryType,
|
||||
[array]$ExcludeEntryType,
|
||||
[array]$IncludeMessage,
|
||||
[array]$ExcludeMessage,
|
||||
$After = $null,
|
||||
$Before = $null,
|
||||
[switch]$DisableTimeCache = $FALSE,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$EventLogPackage = New-IcingaCheckPackage -Name 'EventLog' -OperatorAnd -Verbose $Verbosity;
|
||||
$EventLogData = Get-IcingaEventLog -LogName $LogName -IncludeEventId $IncludeEventId -ExcludeEventId $ExcludeEventId -IncludeUsername $IncludeUsername -ExcludeUsername $ExcludeUsername `
|
||||
-IncludeEntryType $IncludeEntryType -ExcludeEntryType $ExcludeEntryType -IncludeMessage $IncludeMessage -ExcludeMessage $ExcludeMessage `
|
||||
-After $After -Before $Before -DisableTimeCache $DisableTimeCache;
|
||||
|
||||
if ($EventLogData.eventlog.Count -ne 0) {
|
||||
foreach ($event in $EventLogData.eventlog.Keys) {
|
||||
$eventEntry = $EventLogData.eventlog[$event];
|
||||
$EventLogEntryPackage = New-IcingaCheckPackage -Name ([string]::Format('Between: [{0}] - [{1}] there occured {2} event(s).', $eventEntry.OldestEntry, $eventEntry.NewestEntry, $eventEntry.Count)) -OperatorAnd -Verbose $Verbosity;
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('EventId {0}', $EventLogData.eventlog[$event].EventId)) -Value $eventEntry.Count -NoPerfData;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$EventLogEntryPackage.AddCheck($IcingaCheck);
|
||||
|
||||
$EventLogPackage.AddCheck($EventLogEntryPackage);
|
||||
}
|
||||
|
||||
$EventLogCountPackage = New-IcingaCheckPackage -Name 'EventLog Count' -OperatorAnd -Verbose $Verbosity -Hidden;
|
||||
|
||||
foreach ($event in $EventLogData.events.Keys) {
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('EventId {0}', $event)) -Value $EventLogData.events[$event] -Unit 'c';
|
||||
$EventLogCountPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
|
||||
$EventLogPackage.AddCheck($EventLogCountPackage);
|
||||
} else {
|
||||
$IcingaCheck = New-IcingaCheck -Name 'No EventLogs found' -Value 0 -Unit 'c' -NoPerfData;
|
||||
$EventLogPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckResult -Name 'EventLog' -Check $EventLogPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Checks whether a firewall module is enabled or not
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckFirewall returns either 'OK' or 'CRITICAL', whether the check matches or not.
|
||||
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check the status of a firewall profile.
|
||||
Based on the match result the status will change between 'OK' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckFirewall -Profile "Domain" -Verbosity 3
|
||||
[OK] Check package "Firewall profiles" (Match All)
|
||||
\_ [OK] Firewall Profile Domain is True
|
||||
| 'firewall_profile_domain'=True;;
|
||||
0
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckFirewall -Profile "Domain", "Private" -Verbosity 1}
|
||||
[OK] Check package "Firewall profiles" (Match All)
|
||||
| 'firewall_profile_domain'=True;; 'firewall_profile_private'=True;;
|
||||
0
|
||||
[array]$Profile,
|
||||
[bool]$Status = $TRUE,
|
||||
.PARAMETER Profile
|
||||
Used to specify an array of profiles to check.
|
||||
|
||||
.PARAMETER Status
|
||||
Used to specify a bool value, which determines, whether the firewall profiles should be enabled or disabled.
|
||||
|
||||
-Status $TRUE
|
||||
translates to enabled, while
|
||||
-Status $FALSE
|
||||
translates to disabled.
|
||||
.INPUTS
|
||||
System.String
|
||||
|
||||
.OUTPUTS
|
||||
System.String
|
||||
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckFirewall()
|
||||
{
|
||||
param(
|
||||
[array]$Profile,
|
||||
[bool]$Status = $TRUE,
|
||||
[switch]$NoPerfData,
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
if ($Status -eq $TRUE) {
|
||||
$StatusString = "true"
|
||||
} else {
|
||||
$StatusString = "false"
|
||||
}
|
||||
|
||||
$FirewallPackage = New-IcingaCheckPackage -Name 'Firewall profiles' -OperatorAnd -Verbos $Verbosity;
|
||||
|
||||
foreach ($singleprofile in $Profile) {
|
||||
$FirewallData = (Get-NetFirewallProfile -Name $singleprofile)
|
||||
|
||||
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value $FirewallData.Enabled;
|
||||
$FirewallCheck.CritIfNotMatch($StatusString) | Out-Null;
|
||||
|
||||
$FirewallPackage.AddCheck($FirewallCheck)
|
||||
}
|
||||
|
||||
|
||||
return (New-IcingaCheckResult -Check $FirewallPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
Import-IcingaLib provider\memory;
|
||||
Import-IcingaLib core\tools;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks on memory usage
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckMemory returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g memory is currently at 60% usage, WARNING is set to 50, CRITICAL is set to 90. In this case the check will return WARNING.
|
||||
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check on memory usage.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckMemory -Verbosity 3 -Warning 60 -Critical 80
|
||||
[WARNING]: % Memory Check 78.74 is greater than 60
|
||||
1
|
||||
.EXAMPLE
|
||||
PS>
|
||||
.PARAMETER WarningBytes
|
||||
Used to specify a Warning threshold. In this case an string value.
|
||||
|
||||
The string has to be like, "20B", "20KB", "20MB", "20GB", "20TB", "20TB"
|
||||
.PARAMETER CriticalBytes
|
||||
Used to specify a Critical threshold. In this case an string value.
|
||||
|
||||
The string has to be like, "20B", "20KB", "20MB", "20GB", "20TB", "20TB"
|
||||
|
||||
.PARAMETER Pagefile
|
||||
Switch which determines whether the pagefile should be used instead.
|
||||
If not set memory will be checked.
|
||||
|
||||
.PARAMETER CriticalPercent
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
|
||||
Like 30 for 30%. If memory usage is below 30%, the check will return CRITICAL.
|
||||
|
||||
.PARAMETER CriticalPercent
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
|
||||
Like 30 for 30%. If memory usage is below 30%, the check will return Warning.
|
||||
|
||||
.INPUTS
|
||||
System.String
|
||||
|
||||
.OUTPUTS
|
||||
System.String
|
||||
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckMemory()
|
||||
{
|
||||
param(
|
||||
[string]$CriticalBytes = $null,
|
||||
[string]$WarningBytes = $null,
|
||||
$CriticalPercent = $null,
|
||||
$WarningPercent = $null,
|
||||
# [switch]$PageFile,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0,
|
||||
[switch]$NoPerfData
|
||||
);
|
||||
|
||||
If ([string]::IsNullOrEmpty($CriticalBytes) -eq $FALSE) {
|
||||
$CrticalConvertedAll = Convert-Bytes $CriticalBytes -Unit B
|
||||
[decimal]$CriticalConverted = $CriticalConvertedAll.value
|
||||
|
||||
}
|
||||
If ([string]::IsNullOrEmpty($WarningBytes) -eq $FALSE) {
|
||||
$WarningConvertedAll = Convert-Bytes $WarningBytes -Unit B
|
||||
[decimal]$WarningConverted = $WarningConvertedAll.value
|
||||
}
|
||||
|
||||
$MemoryPackage = New-IcingaCheckPackage -Name 'Memory Usage' -OperatorAnd -Verbos $Verbosity;
|
||||
$MemoryData = (Get-IcingaMemoryPerformanceCounter);
|
||||
|
||||
# Auto-Detect?
|
||||
If (($MemoryData['Memory Total Bytes'] / [math]::Pow(2, 50)) -ge 1) {
|
||||
$Unit = "PB"
|
||||
} elseif (($MemoryData['Memory Total Bytes'] / [math]::Pow(2, 40)) -ge 1) {
|
||||
$Unit = "TB"
|
||||
} elseif (($MemoryData['Memory Total Bytes'] / [math]::Pow(2, 30)) -ge 1) {
|
||||
$Unit = "GB"
|
||||
} elseif (($MemoryData['Memory Total Bytes'] / [math]::Pow(2, 20)) -ge 1) {
|
||||
$Unit = "MB"
|
||||
} elseif (($MemoryData['Memory Total Bytes'] / [math]::Pow(2, 10)) -ge 1) {
|
||||
$Unit = "KB"
|
||||
} else {
|
||||
$Unit = "B"
|
||||
}
|
||||
|
||||
Write-Host $Unit
|
||||
|
||||
$MemoryPerc = New-IcingaCheck -Name 'Memory Percent Used' -Value $MemoryData['Memory Used %'] -Unit '%';
|
||||
$MemoryByteUsed = New-IcingaCheck -Name "Used Bytes" -Value $MemoryData['Memory Used Bytes'] -Unit 'B';
|
||||
#$MemoryByteAvailable = New-IcingaCheck -Name "Available Bytes" -Value $MemoryData['Memory Available Bytes'] -Unit 'B';
|
||||
#$PageFileCheck = New-IcingaCheck -Name 'PageFile Percent' -Value $MemoryData['PageFile %'] -Unit '%';
|
||||
|
||||
# PageFile To-Do
|
||||
$MemoryByteUsed.WarnOutOfRange($WarningConverted).CritOutOfRange($CrticalConverted) | Out-Null;
|
||||
$MemoryPerc.WarnOutOfRange($WarningPercent).CritOutOfRange($CriticalPercent) | Out-Null;
|
||||
|
||||
$MemoryPackage.AddCheck($MemoryPerc);
|
||||
#$MemoryPackage.AddCheck($MemoryByteAvailable);
|
||||
$MemoryPackage.AddCheck($MemoryByteUsed);
|
||||
#$MemoryPackage.AddCheck($PageFileCheck);
|
||||
|
||||
return (New-IcingaCheckResult -Check $MemoryPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Performs checks on various performance counter
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckDirectory returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
Use "Show-IcingaPerformanceCounterCategories" to see all performance counter categories available.
|
||||
To gain insight on an specific performance counter use "Show-IcingaPerformanceCounters <performance counter category>"
|
||||
e.g '
|
||||
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to perform checks on different performance counter.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckPerfCounter -PerfCounter '\processor(*)\% processor time' -Warning 60 -Critical 90
|
||||
[WARNING]: Check package "Performance Counter" is [WARNING]
|
||||
| 'processor1_processor_time'=68.95;60;90 'processor3_processor_time'=4.21;60;90 'processor5_processor_time'=9.5;60;90 'processor_Total_processor_time'=20.6;60;90 'processor0_processor_time'=5.57;60;90 'processor2_processor_time'=0;60;90 'processor4_processor_time'=6.66;60;90
|
||||
1
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an ??? value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an ??? value.
|
||||
.PARAMETER PerfCounter
|
||||
Used to specify an array of performance counter to check against.
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckPerfcounter()
|
||||
{
|
||||
param(
|
||||
[array]$PerfCounter,
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$Counters = New-IcingaPerformanceCounterArray -CounterArray $PerfCounter;
|
||||
$CheckPackage = New-IcingaCheckPackage -Name 'Performance Counter' -OperatorAnd -Verbose $Verbosity;
|
||||
|
||||
foreach ($counter in $Counters.Keys) {
|
||||
|
||||
$CounterPackage = New-IcingaCheckPackage -Name $counter -OperatorAnd -Verbose $Verbosity;
|
||||
|
||||
foreach ($instanceName in $Counters[$counter].Keys) {
|
||||
$instance = $Counters[$counter][$instanceName];
|
||||
if ($instance -isnot [hashtable]) {
|
||||
$IcingaCheck = New-IcingaCheck -Name $counter -Value $Counters[$counter].Value;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CounterPackage.AddCheck($IcingaCheck);
|
||||
break;
|
||||
}
|
||||
$IcingaCheck = New-IcingaCheck -Name $instanceName -Value $instance.Value;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$CounterPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
$CheckPackage.AddCheck($CounterPackage);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
Import-IcingaLib provider\process;
|
||||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how many processes of a process exist.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckDirectory returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g there are three conhost processes running, WARNING is set to 3, CRITICAL is set to 4. In this case the check will return WARNING.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check how many processes of a process exist.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckProcessCount -Process conhost -Warning 5 -Critical 10
|
||||
[OK]: Check package "Process Check" is [OK]
|
||||
| 'Process Count "conhost"'=3;;
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckProcessCount -Process conhost,wininit -Warning 5 -Critical 10 -Verbosity 4
|
||||
[OK]: Check package "Process Check" is [OK] (Match All)
|
||||
\_ [OK]: Process Count "conhost" is 3
|
||||
\_ [OK]: Process Count "wininit" is 1
|
||||
| 'Process Count "conhost"'=3;5;10 'Process Count "wininit"'=1;5;10
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.PARAMETER Process
|
||||
Used to specify an array of processes to count and match against.
|
||||
e.g. conhost,wininit
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckProcessCount()
|
||||
{
|
||||
param(
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[array]$Process,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$ProcessInformation = (Get-IcingaProcessData -Name $Process)
|
||||
|
||||
$ProcessPackage = New-icingaCheckPackage -Name "Process Check" -OperatorAnd -Verbose $Verbosity -NoPerfData $NoPerfData;
|
||||
|
||||
if ($Process.Count -eq 0) {
|
||||
$ProcessCount = $ProcessInformation['Process Count'];
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count')) -Value $ProcessCount;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$ProcessPackage.AddCheck($IcingaCheck);
|
||||
} else {
|
||||
foreach ($proc in $process) {
|
||||
$ProcessCount = $ProcessInformation."Processes".$proc.processlist.Count;
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count "{0}"', $proc)) -Value $ProcessCount;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$ProcessPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (New-IcingaCheckResult -Check $ProcessPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
Import-IcingaLib provider\services;
|
||||
Import-IcingaLib provider\enums;
|
||||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks if a service has a specified status.
|
||||
.DESCRIPTION
|
||||
Invoke-icingaCheckService returns either 'OK' or 'CRITICAL', if a service status is matching status to be checked.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check whether one or more services have a certain status.
|
||||
As soon as one of the specified services does not match the status, the function returns 'CRITICAL' instead of 'OK'.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckService -Service WiaRPC, Spooler -Status '1' -Verbose 3
|
||||
[CRITICAL]: Check package "Services" is [CRITICAL] (Match All)
|
||||
\_ [OK]: Service "Ereignisse zum Abrufen von Standbildern (WiaRPC)" is Stopped
|
||||
\_ [CRITICAL]: Service "Druckwarteschlange (Spooler)" Running is not matching Stopped
|
||||
.PARAMETER Service
|
||||
Used to specify an array of services which should be checked against the status.
|
||||
Seperated with ','
|
||||
.PARAMETER Status
|
||||
Status for the specified service or services to check against.
|
||||
.INPUTS
|
||||
System.Array
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckService()
|
||||
{
|
||||
param(
|
||||
[array]$Service,
|
||||
[ValidateSet('Stopped', 'StartPending', 'StopPending', 'Running', 'ContinuePending', 'PausePending', 'Paused')]
|
||||
[string]$Status = 'Running',
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0,
|
||||
[switch]$NoPerfData
|
||||
);
|
||||
|
||||
$ServicesPackage = New-IcingaCheckPackage -Name 'Services' -OperatorAnd -Verbose $Verbosity;
|
||||
$ServicesCountPackage = New-IcingaCheckPackage -Name 'Count Services' -OperatorAnd -Verbose $Verbosity -Hidden;
|
||||
|
||||
[int]$StoppedCount,[int]$StartPendingCount,[int]$StopPendingCount,[int]$RunningCount,[int]$ContinuePendingCount,[int]$PausePendingCount,[int]$PausedCount,[int]$ServicesCounted = 0
|
||||
foreach ($services in $Service) {
|
||||
$IcingaCheck = $null;
|
||||
|
||||
$FoundService = Get-IcingaServices -Service $services;
|
||||
$ServiceName = Get-IcingaServiceCheckName -ServiceInput $services -Service $FoundService;
|
||||
$ConvertedStatus = ConvertTo-ServiceStatusCode -Status $Status;
|
||||
$StatusRaw = $FoundService.Values.configuration.Status.raw;
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName;
|
||||
$IcingaCheck.CritIfNotMatch($ConvertedStatus) | Out-Null;
|
||||
$ServicesPackage.AddCheck($IcingaCheck)
|
||||
|
||||
switch($StatusRaw) {
|
||||
{1 -contains $_} { $StoppedCount++; $ServicesCounted++}
|
||||
{2 -contains $_} { $StartPendingCount++; $ServicesCounted++}
|
||||
{3 -contains $_} { $StopPendingCount++; $ServicesCounted++}
|
||||
{4 -contains $_} { $RunningCount++; $ServicesCounted++}
|
||||
{5 -contains $_} { $ContinuePendingCount++; $ServicesCounted++}
|
||||
{6 -contains $_} { $PausePendingCount++; $ServicesCounted++}
|
||||
{7 -contains $_} { $PausedCount++; $ServicesCounted++}
|
||||
}
|
||||
}
|
||||
$IcingaStopped = New-IcingaCheck -Name 'stopped services' -Value $StoppedCount;
|
||||
$IcingaStartPending = New-IcingaCheck -Name 'pending started services' -Value $StartPendingCount;
|
||||
$IcingaStopPending = New-IcingaCheck -Name 'pending stopped services' -Value $StopPendingCount;
|
||||
$IcingaRunning = New-IcingaCheck -Name 'running services' -Value $RunningCount;
|
||||
$IcingaContinuePending = New-IcingaCheck -Name 'pending continued services' -Value $ContinuePendingCount;
|
||||
$IcingaPausePending = New-IcingaCheck -Name 'pending paused services' -Value $PausePendingCount;
|
||||
$IcingaPaused = New-IcingaCheck -Name 'paused services' -Value $PausePendingCount;
|
||||
|
||||
$IcingaCount = New-IcingaCheck -Name 'service count' -Value $ServicesCounted;
|
||||
|
||||
$ServicesCountPackage.AddCheck($IcingaStopped)
|
||||
$ServicesCountPackage.AddCheck($IcingaStartPending)
|
||||
$ServicesCountPackage.AddCheck($IcingaStopPending)
|
||||
$ServicesCountPackage.AddCheck($IcingaRunning)
|
||||
$ServicesCountPackage.AddCheck($IcingaContinuePending)
|
||||
$ServicesCountPackage.AddCheck($IcingaPausePending)
|
||||
$ServicesCountPackage.AddCheck($IcingaPaused)
|
||||
|
||||
$ServicesCountPackage.AddCheck($IcingaCount)
|
||||
$ServicesPackage.AddCheck($ServicesCountPackage)
|
||||
|
||||
return (New-IcingaCheckResult -Name 'Services' -Check $ServicesPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
Import-IcingaLib provider\updates;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how many updates are to be applied
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckUpdates returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g 'C:\Users\Icinga\Backup' 10 updates are pending, WARNING is set to 20, CRITICAL is set to 50. In this case the check will return OK.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check how many updates are to be applied and thereby currently pending
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckUpdates -Warning 4 -Critical 20
|
||||
[OK]: Check package "Updates" is [OK]
|
||||
| 'Pending Update Count'=2;4;20
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckUpdates()
|
||||
{
|
||||
param (
|
||||
[array]$UpdateFilter,
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$PendingUpdates = Get-IcingaUpdatesPending;
|
||||
|
||||
$UpdateCount = New-IcingaCheckPackage -Name 'Pending Update Count' -OperatorAnd;
|
||||
$UpdateList = New-IcingaCheckPackage -Name 'Update List' -OperatorAnd;
|
||||
$PendingCount = 0;
|
||||
|
||||
if ($UpdateFilter.Count -ne 0) {
|
||||
foreach ($Filter in $UpdateFilter) {
|
||||
foreach ($Update in $PendingUpdates.updates.Keys) {
|
||||
if ($Update -Like $Filter) {
|
||||
$PendingCount += 1;
|
||||
$UpdateList.AddCheck(
|
||||
(New-IcingaCheck -Name $Update -Value 'pending' -NoPerfData)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($PendingCount -eq 0) {
|
||||
$UpdateList.AddCheck(
|
||||
(New-IcingaCheck -Name 'No update' -Value 'pending' -NoPerfData)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$PendingCount = $PendingUpdates.count;
|
||||
foreach ($Update in $PendingUpdates.updates.Keys) {
|
||||
$UpdateList.AddCheck(
|
||||
(New-IcingaCheck -Name $Update -Value 'pending' -NoPerfData)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name 'Pending Update Count' -Value $PendingCount;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$UpdateCount.AddCheck($IcingaCheck);
|
||||
|
||||
$UpdatePackage = New-IcingaCheckPackage -Name 'Windows Updates' -OperatorAnd -Verbose $Verbosity -Checks @(
|
||||
$UpdateCount
|
||||
);
|
||||
|
||||
if ($PendingCount -ne 0) {
|
||||
$UpdatePackage.AddCheck($UpdateList);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckResult -Name 'Pending Updates' -Check $UpdatePackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
Import-IcingaLib provider\windows;
|
||||
Import-IcingaLib core\tools;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how long a Windows system has been up for.
|
||||
.DESCRIPTION
|
||||
InvokeIcingaCheckUptime returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g 'C:\Users\Icinga\Backup' the system has been running for 10 days, WARNING is set to 15d, CRITICAL is set to 30d. In this case the check will return OK.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to check how long a Windows system has been up for.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS> Invoke-IcingaCheckUptime -Warning 18d -Critical 20d
|
||||
[WARNING]: Check package "Windows Uptime: Days: 19 Hours: 13 Minutes: 48 Seconds: 29" is [WARNING]
|
||||
| 'Windows Uptime'=1691309,539176s;1555200;1728000
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case a string.
|
||||
Allowed units include: ms, s, m, h, d, w, M, y
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case a string.
|
||||
Allowed units include: ms, s, m, h, d, w, M, y
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckUptime()
|
||||
{
|
||||
param(
|
||||
[string]$Warning = $null,
|
||||
[string]$Critical = $null,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$WindowsData = Get-IcingaWindows;
|
||||
$Name = ([string]::Format('System Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value)));
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name 'System Uptime' -Value $WindowsData.windows.metadata.uptime.value -Unit 's';
|
||||
$IcingaCheck.WarnOutOfRange(
|
||||
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Warning)
|
||||
).CritOutOfRange(
|
||||
(ConvertTo-SecondsFromIcingaThresholds -Threshold $Critical)
|
||||
) | Out-Null;
|
||||
|
||||
$CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Checks $IcingaCheck -Verbose $Verbosity;
|
||||
|
||||
return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
Import-IcingaLib core\perfcounter;
|
||||
Import-IcingaLib icinga\plugin;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how much space on a partition is used.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckUsedPartition returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g 'C:' is at 8% usage, WARNING is set to 60, CRITICAL is set to 80. In this case the check will return OK.
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check how much usage there is on an partition.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckUsedPartitionSpace -Warning 60 -Critical 80
|
||||
[OK]: Check package "Used Partition Space" is [OK]
|
||||
| 'Partition C'=8,06204986572266%;60;;0;100 'Partition D'=12,06204736572266%;60;;0;100 'Partition K'=19,062047896572266%;60;;0;100
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckUsedPartitionSpace -Warning 60 -Critical 80 -Exclude "C:\"
|
||||
[OK]: Check package "Used Partition Space" is [OK]
|
||||
| 'Partition D'=12,06204736572266%;60;;0;100 'Partition K'=19,062047896572266%;60;;0;100
|
||||
.EXAMPLE
|
||||
PS>Invoke-IcingaCheckUsedPartitionSpace -Warning 60 -Critical 80 -Include "C:\"
|
||||
[OK]: Check package "Used Partition Space" is [OK]
|
||||
| 'Partition C'=8,06204986572266%;60;;0;100
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.PARAMETER Exclude
|
||||
Used to specify an array of partitions to be excluded.
|
||||
e.g. 'C:\','D:\'
|
||||
.PARAMETER Include
|
||||
Used to specify an array of partitions to be included.
|
||||
e.g. 'C:\','D:\'
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckUsedPartitionSpace()
|
||||
{
|
||||
param(
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[array]$Include = @(),
|
||||
[array]$Exclude = @(),
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$DiskFree = Get-IcingaDiskPartitions;
|
||||
$DiskPackage = New-IcingaCheckPackage -Name 'Used Partition Space' -OperatorAnd -Verbos $Verbosity;
|
||||
|
||||
foreach ($Letter in $DiskFree.Keys) {
|
||||
if ($Include.Count -ne 0) {
|
||||
$Include = $Include.trim(' :/\');
|
||||
if (-Not ($Include.Contains($Letter))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($Exclude.Count -ne 0) {
|
||||
$Exclude = $Exclude.trim(' :/\');
|
||||
if ($Exclude.Contains($Letter)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value (100-($DiskFree.([string]::Format($Letter))."Free Space")) -Unit '%';
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$DiskPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
|
||||
return (New-IcingaCheckResult -Check $DiskPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
Import-IcingaLib icinga\plugin;
|
||||
Import-IcingaLib provider\users;
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks how many files are in a directory.
|
||||
.DESCRIPTION
|
||||
Invoke-IcingaCheckDirectory returns either 'OK', 'WARNING' or 'CRITICAL', based on the thresholds set.
|
||||
e.g 'C:\Users\Icinga\Backup' contains 200 files, WARNING is set to 150, CRITICAL is set to 300. In this case the check will return CRITICAL
|
||||
More Information on https://github.com/Icinga/icinga-powershell-framework
|
||||
.FUNCTIONALITY
|
||||
This module is intended to be used to check how many files and directories are within are specified path.
|
||||
Based on the thresholds set the status will change between 'OK', 'WARNING' or 'CRITICAL'. The function will return one of these given codes.
|
||||
|
||||
.EXAMPLE
|
||||
PS>
|
||||
.EXAMPLE
|
||||
PS>
|
||||
.PARAMETER Warning
|
||||
Used to specify a Warning threshold. In this case an integer value.
|
||||
.PARAMETER Critical
|
||||
Used to specify a Critical threshold. In this case an integer value.
|
||||
.PARAMETER Username
|
||||
Used to specify an array of usernames to match against.
|
||||
|
||||
e.g 'Administrator', 'Icinga'
|
||||
.INPUTS
|
||||
System.String
|
||||
.OUTPUTS
|
||||
System.String
|
||||
.LINK
|
||||
https://github.com/Icinga/icinga-powershell-framework
|
||||
.NOTES
|
||||
#>
|
||||
|
||||
function Invoke-IcingaCheckUsers()
|
||||
{
|
||||
param (
|
||||
[array]$Username,
|
||||
$Warning = $null,
|
||||
$Critical = $null,
|
||||
[switch]$NoPerfData,
|
||||
[ValidateSet(0, 1, 2, 3)]
|
||||
[int]$Verbosity = 0
|
||||
);
|
||||
|
||||
$UsersPackage = New-IcingaCheckPackage -Name 'Users' -OperatorAnd -Verbose $Verbosity;
|
||||
$LoggedOnUsers = Get-IcingaLoggedOnUsers -UserFilter $Username;
|
||||
|
||||
if ($Username.Count -ne 0) {
|
||||
foreach ($User in $Username) {
|
||||
$IcingaCheck = $null;
|
||||
[int]$LoginCount = 0;
|
||||
|
||||
if ($LoggedOnUsers.users.ContainsKey($User)) {
|
||||
$LoginCount = $LoggedOnUsers.users.$User.count;
|
||||
}
|
||||
|
||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Logged On Users "{0}"', $User)) -Value $LoginCount;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$UsersPackage.AddCheck($IcingaCheck);
|
||||
}
|
||||
} else {
|
||||
foreach ($User in $LoggedOnUsers.users.Keys) {
|
||||
$UsersPackage.AddCheck(
|
||||
(New-IcingaCheck -Name ([string]::Format('Logged On Users "{0}"', $User)) -Value $LoggedOnUsers.users.$User.count)
|
||||
);
|
||||
}
|
||||
$IcingaCheck = New-IcingaCheck -Name 'Logged On Users' -Value $LoggedOnUsers.count;
|
||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||
$UsersPackage.AddCheck($IcingaCheck)
|
||||
}
|
||||
|
||||
return (New-IcingaCheckResult -Name 'Users' -Check $UsersPackage -NoPerfData $NoPerfData -Compile);
|
||||
}
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
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'};
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
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,279 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
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,187 +0,0 @@
|
|||
Import-IcingaLib core\tools;
|
||||
|
||||
function Get-IcingaDirectoryAll()
|
||||
{
|
||||
param(
|
||||
[string]$Path,
|
||||
[array]$FileNames,
|
||||
[bool]$Recurse,
|
||||
[string]$ChangeTimeEqual,
|
||||
[string]$ChangeYoungerThan,
|
||||
[string]$ChangeOlderThan,
|
||||
[string]$CreationTimeEqual,
|
||||
[string]$CreationOlderThan,
|
||||
[string]$CreationYoungerThan,
|
||||
[string]$FileSizeGreaterThan,
|
||||
[string]$FileSizeSmallerThan
|
||||
);
|
||||
|
||||
if ($Recurse -eq $TRUE) {
|
||||
$DirectoryData = Get-IcingaDirectoryRecurse -Path $Path -FileNames $FileNames;
|
||||
} else {
|
||||
$DirectoryData = Get-IcingaDirectory -Path $Path -FileNames $FileNames;
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($ChangeTimeEqual) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryChangeTimeEqual -ChangeTimeEqual $ChangeTimeEqual -DirectoryData $DirectoryData;
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($CreationTimeEqual) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryCreationTimeEqual -CreationTimeEqual $CreationTimeEqual -DirectoryData $DirectoryData;
|
||||
}
|
||||
|
||||
If ([string]::IsNullOrEmpty($ChangeTimeEqual) -eq $TRUE -Or [string]::IsNullOrEmpty($CreationTimeEqual) -eq $TRUE) {
|
||||
if ([string]::IsNullOrEmpty($ChangeOlderThan) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryChangeOlderThan -ChangeOlderThan $ChangeOlderThan -DirectoryData $DirectoryData;
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($ChangeYoungerThan) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryChangeYoungerThan -ChangeYoungerThan $ChangeYoungerThan -DirectoryData $DirectoryData;
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($CreationOlderThan) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryCreationOlderThan -CreationOlderThan $CreationOlderThan -DirectoryData $DirectoryData;
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($CreationYoungerThan) -eq $FALSE) {
|
||||
$DirectoryData = Get-IcingaDirectoryCreationYoungerThan -CreationYoungerThan $CreationYoungerThan -DirectoryData $DirectoryData;
|
||||
}
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($FileSizeGreaterThan) -eq $FALSE) {
|
||||
$DirectoryData = (Get-IcingaDirectorySizeGreaterThan -FileSizeGreaterThan $FileSizeGreaterThan -DirectoryData $DirectoryData);
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($FileSizeSmallerThan) -eq $FALSE) {
|
||||
$DirectoryData = (Get-IcingaDirectorySizeSmallerThan -FileSizeSmallerThan $FileSizeSmallerThan -DirectoryData $DirectoryData);
|
||||
}
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# RECURSE
|
||||
|
||||
function Get-IcingaDirectory()
|
||||
{
|
||||
param(
|
||||
[string]$Path,
|
||||
[array]$FileNames
|
||||
);
|
||||
|
||||
$DirectoryData = Get-ChildItem -Include $FileNames -Path $Path;
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectoryRecurse()
|
||||
{
|
||||
param(
|
||||
[string]$Path,
|
||||
[array]$FileNames
|
||||
);
|
||||
|
||||
$DirectoryData = Get-ChildItem -Recurse -Include $FileNames -Path $Path;
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
# FILE SIZE
|
||||
|
||||
function Get-IcingaDirectorySizeGreaterThan()
|
||||
{
|
||||
param(
|
||||
[string]$FileSizeGreaterThan,
|
||||
$DirectoryData
|
||||
);
|
||||
$FileSizeGreaterThanValue = (Convert-Bytes $FileSizeGreaterThan -Unit B).value
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.Length -gt $FileSizeGreaterThanValue})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectorySizeSmallerThan()
|
||||
{
|
||||
param(
|
||||
[string]$FileSizeSmallerThan,
|
||||
$DirectoryData
|
||||
);
|
||||
$FileSizeSmallerThanValue = (Convert-Bytes $FileSizeSmallerThan -Unit B).value
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.Length -gt $FileSizeSmallerThanValue})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
# TIME BASED CHANGE
|
||||
|
||||
function Get-IcingaDirectoryChangeOlderThan()
|
||||
{
|
||||
param (
|
||||
[string]$ChangeOlderThan,
|
||||
$DirectoryData
|
||||
)
|
||||
$ChangeOlderThan = Set-NumericNegative (ConvertTo-Seconds $ChangeOlderThan);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.LastWriteTime -lt (Get-Date).AddSeconds($ChangeOlderThan)})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectoryChangeYoungerThan()
|
||||
{
|
||||
param (
|
||||
[string]$ChangeYoungerThan,
|
||||
$DirectoryData
|
||||
)
|
||||
$ChangeYoungerThan = Set-NumericNegative (ConvertTo-Seconds $ChangeYoungerThan);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.LastWriteTime -gt (Get-Date).AddSeconds($ChangeYoungerThan)})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectoryChangeTimeEqual()
|
||||
{
|
||||
param (
|
||||
[string]$ChangeTimeEqual,
|
||||
$DirectoryData
|
||||
)
|
||||
$ChangeTimeEqual = Set-NumericNegative (ConvertTo-Seconds $ChangeTimeEqual);
|
||||
$ChangeTimeEqual = (Get-Date).AddSeconds($ChangeTimeEqual);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.LastWriteTime.Day -eq $ChangeTimeEqual.Day -And $_.LastWriteTime.Month -eq $ChangeTimeEqual.Month -And $_.LastWriteTime.Year -eq $ChangeTimeEqual.Year})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
# TIME BASED CREATION
|
||||
|
||||
function Get-IcingaDirectoryCreationYoungerThan()
|
||||
{
|
||||
param (
|
||||
[string]$CreationYoungerThan,
|
||||
$DirectoryData
|
||||
)
|
||||
$CreationYoungerThan = Set-NumericNegative (ConvertTo-Seconds $CreationYoungerThan);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.CreationTime -gt (Get-Date).AddSeconds($CreationYoungerThan)})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectoryCreationOlderThan()
|
||||
{
|
||||
param (
|
||||
[string]$CreationOlderThan,
|
||||
$DirectoryData
|
||||
)
|
||||
$CreationOlderThan = Set-NumericNegative (ConvertTo-Seconds $CreationOlderThan);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.CreationTime -lt (Get-Date).AddSeconds($CreationOlderThan)})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
||||
function Get-IcingaDirectoryCreationTimeEqual()
|
||||
{
|
||||
param (
|
||||
[string]$CreationTimeEqual,
|
||||
$DirectoryData
|
||||
)
|
||||
$CreationTimeEqual = Set-NumericNegative (ConvertTo-Seconds $CreationTimeEqual);
|
||||
$CreationTimeEqual = (Get-Date).AddSeconds($CreationTimeEqual);
|
||||
$DirectoryData = ($DirectoryData | Where-Object {$_.CreationTime.Day -eq $CreationTimeEqual.Day -And $_.CreationTime.Month -eq $CreationTimeEqual.Month -And $_.CreationTime.Year -eq $CreationTimeEqual.Year})
|
||||
|
||||
return $DirectoryData;
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$DiskArray = New-IcingaPerformanceCounterStructure -CounterCategory 'LogicalDisk' -PerformanceCounterHash (New-IcingaPerformanceCounterArray @('\LogicalDisk(*)\% free space'));
|
||||
|
||||
$diskPartitionSize = Get-Partition -DriveLetter $driveLetter;
|
||||
|
||||
$PartitionDiskByDriveLetter.Add(
|
||||
$driveLetter,
|
||||
@{
|
||||
'Disk' = $diskDisk;
|
||||
'Partition' = $diskPartition;
|
||||
'Size' = $diskPartitionSize.Size;
|
||||
'Free Space' = $DiskArray.Item([string]::Format('{0}:', $driveLetter))."% free space".value;
|
||||
}
|
||||
);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
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,525 +0,0 @@
|
|||
|
||||
<##################################################################################################
|
||||
################# /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';
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/Services ###########################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$ServiceStatusName = @{
|
||||
1 = 'Stopped';
|
||||
2 = 'StartPending';
|
||||
3 = 'StopPending';
|
||||
4 = 'Running';
|
||||
5 = 'ContinuePending';
|
||||
6 = 'PausePending';
|
||||
7 = 'Paused';
|
||||
}
|
||||
|
||||
[hashtable]$ServiceStatus = @{
|
||||
'Stopped' = 1;
|
||||
'StartPending' = 2;
|
||||
'StopPending' = 3;
|
||||
'Running' = 4;
|
||||
'ContinuePending' = 5;
|
||||
'PausePending' = 6;
|
||||
'Paused' = 7;
|
||||
}
|
||||
|
||||
[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;
|
||||
#/lib/provider/services
|
||||
ServiceStatus = $ServiceStatus;
|
||||
ServiceStatusName =$ServiceStatusName;
|
||||
}
|
||||
|
||||
Export-ModuleMember -Variable @('ProviderEnums');
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
Import-IcingaLib icinga\exception;
|
||||
|
||||
function Get-IcingaEventLog()
|
||||
{
|
||||
param(
|
||||
[string]$LogName,
|
||||
[array]$IncludeEventId,
|
||||
[array]$ExcludeEventId,
|
||||
[array]$IncludeUsername,
|
||||
[array]$ExcludeUsername,
|
||||
[array]$IncludeEntryType,
|
||||
[array]$ExcludeEntryType,
|
||||
[array]$IncludeMessage,
|
||||
[array]$ExcludeMessage,
|
||||
$After,
|
||||
$Before,
|
||||
[bool]$DisableTimeCache
|
||||
);
|
||||
|
||||
if ([string]::IsNullOrEmpty($LogName)) {
|
||||
Exit-IcingaThrowException -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.EventLog -Force;
|
||||
}
|
||||
|
||||
[hashtable]$EventLogArguments = @{
|
||||
LogName = $LogName;
|
||||
};
|
||||
|
||||
# This will generate a unique hash for each possible configured EventLog check to store the last check time for each of these checks
|
||||
[string]$CheckHash = (Get-StringSha1 ($LogName + $IncludeEventId + $ExcludeEventId + $IncludeUsername + $ExcludeUsername + $IncludeEntryType + $ExcludeEntryType + $IncludeMessage + $ExcludeMessage)) + '.lastcheck';
|
||||
|
||||
if ($null -eq $After -and $DisableTimeCache -eq $FALSE) {
|
||||
$time = Get-IcingaCacheData -Space 'provider' -CacheStore 'eventlog' -KeyName $CheckHash;
|
||||
Set-IcingaCacheData -Space 'provider' -CacheStore 'eventlog' -KeyName $CheckHash -Value ((Get-Date).ToFileTime());
|
||||
|
||||
if ($null -ne $time) {
|
||||
$After = [datetime]::FromFileTime($time);
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -ne $IncludeEventId) {
|
||||
$EventLogArguments.Add('InstanceID', $IncludeEventId);
|
||||
}
|
||||
if ($null -ne $IncludeUsername) {
|
||||
$EventLogArguments.Add('UserName', $IncludeUsername);
|
||||
}
|
||||
if ($null -ne $IncludeEntryType) {
|
||||
$EventLogArguments.Add('EntryType', $IncludeEntryType);
|
||||
}
|
||||
if ($null -ne $After) {
|
||||
$EventLogArguments.Add('After', $After);
|
||||
}
|
||||
if ($null -ne $Before) {
|
||||
$EventLogArguments.Add('Before', $Before);
|
||||
}
|
||||
|
||||
try {
|
||||
$events = Get-EventLog @EventLogArguments;
|
||||
} catch {
|
||||
Exit-IcingaThrowException -InputString $_.Exception -StringPattern 'ParameterBindingValidationException' -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.EventLog;
|
||||
Exit-IcingaThrowException -InputString $_.Exception -StringPattern 'System.InvalidOperationException' -CustomMessage (-Join $LogName) -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.EventLogLogName;
|
||||
Exit-IcingaThrowException -InputString $_.Exception -ExceptionType 'Unhandled' -Force;
|
||||
}
|
||||
|
||||
if ($null -ne $ExcludeEventId -Or $null -ne $ExcludeUsername -Or $null -ne $ExcludeEntryType -Or $null -ne $ExcludeMessage -Or $null -ne $IncludeMessage) {
|
||||
$filteredEvents = @();
|
||||
foreach ($event in $events) {
|
||||
# Filter out excluded event IDs
|
||||
if ($ExcludeEventId.Count -ne 0 -And $event.InstanceID -contains $ExcludeEventId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
# Filter out excluded event IDs
|
||||
if ($ExcludeUsername.Count -ne 0 -And $event.UserName -contains $ExcludeUsername) {
|
||||
continue;
|
||||
}
|
||||
|
||||
# Filter out excluded event IDs
|
||||
if ($ExcludeEntryType.Count -ne 0 -And $event.EntryType -contains $ExcludeEntryType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[bool]$skip = $FALSE;
|
||||
foreach ($exMessage in $ExcludeMessage) {
|
||||
# Filter out excluded event IDs
|
||||
if ([string]$event.Message -like [string]$exMessage) {
|
||||
$skip = $TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[bool]$skip = $TRUE;
|
||||
|
||||
foreach ($inMessage in $IncludeMessage) {
|
||||
# Filter for specific message content
|
||||
if ([string]$event.Message -like [string]$inMessage) {
|
||||
$skip = $FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filteredEvents += $event;
|
||||
}
|
||||
|
||||
$events = $filteredEvents;
|
||||
}
|
||||
|
||||
$groupedEvents = @{
|
||||
'eventlog' = @{};
|
||||
'events' = @{};
|
||||
};
|
||||
|
||||
foreach ($event in $events) {
|
||||
[string]$EventIdentifier = [string]::Format('{0}-{1}',
|
||||
$event.InstanceID,
|
||||
$event.Message
|
||||
);
|
||||
|
||||
[string]$EventHash = Get-StringSha1 $EventIdentifier;
|
||||
|
||||
if ($groupedEvents.eventlog.ContainsKey($EventHash) -eq $FALSE) {
|
||||
$groupedEvents.eventlog.Add(
|
||||
$EventHash,
|
||||
@{
|
||||
NewestEntry = $event.TimeGenerated;
|
||||
OldestEntry = $event.TimeGenerated;
|
||||
EventId = $event.InstanceID;
|
||||
Message = $event.Message;
|
||||
Severity = $event.EntryType;
|
||||
Count = 1;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$groupedEvents.eventlog[$EventHash].OldestEntry = $event.TimeGenerated;
|
||||
$groupedEvents.eventlog[$EventHash].Count += 1;
|
||||
}
|
||||
|
||||
if ($groupedEvents.events.ContainsKey($event.InstanceID) -eq $FALSE) {
|
||||
$groupedEvents.events.Add($event.InstanceID, 1);
|
||||
} else {
|
||||
$groupedEvents.events[$event.InstanceID] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $groupedEvents;
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
function Get-IcingaMemoryPerformanceCounter()
|
||||
{
|
||||
$MemoryPercent = New-IcingaPerformanceCounterArray -Counter "\Memory\% committed bytes in use","\Memory\Available Bytes","\Paging File(_Total)\% usage"
|
||||
[hashtable]$Initial = @{};
|
||||
[hashtable]$MemoryData = @{};
|
||||
|
||||
foreach ($item in $MemoryPercent.Keys) {
|
||||
$Initial.Add($item, $MemoryPercent[$item]);
|
||||
}
|
||||
|
||||
$MemoryData.Add('Memory Available Bytes', [decimal]($Initial.'\Memory\Available Bytes'.value));
|
||||
$MemoryData.Add('Memory Total Bytes', (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory);
|
||||
$MemoryData.Add('Memory Used Bytes', $MemoryData.'Memory Total Bytes' - $MemoryData.'Memory Available Bytes');
|
||||
$MemoryData.Add('Memory Used %', 100 - ($MemoryData.'Memory Available Bytes' / $MemoryData.'Memory Total Bytes' * 100));
|
||||
$MemoryData.Add('PageFile %', $Initial.'\Paging File(_Total)\% usage'.value);
|
||||
|
||||
return $MemoryData;
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
function Get-IcingaMemoryUsage()
|
||||
{
|
||||
$MEMUsageInformations = Get-CimInstance Win32_OperatingSystem;
|
||||
|
||||
[hashtable]$MEMUsageData = @{
|
||||
'FreePhysicalMemory' = $MEMUsageInformations.FreePhysicalMemory;
|
||||
'FreeVirtualMemory' = $MEMUsageInformations.FreeVirtualMemory;
|
||||
'TotalVirtualMemorySize' = $MEMUsageInformations.TotalVirtualMemorySize;
|
||||
'TotalVisibleMemorySize' = $MEMUsageInformations.TotalVisibleMemorySize;
|
||||
'MaxProcessMemorySize' = $MEMUsageInformations.MaxProcessMemorySize;
|
||||
}
|
||||
|
||||
return $MEMUsageData;
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
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'};
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
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 {
|
||||
|
||||
param(
|
||||
[array]$Process
|
||||
);
|
||||
|
||||
$ProcessInformation = Get-WmiObject Win32_Process;
|
||||
$ProcessPerfDataList = Get-WmiObject Win32_PerfFormattedData_PerfProc_Process;
|
||||
$CPUCoreCount = Get-IcingaCPUCount;
|
||||
|
||||
|
||||
[hashtable]$ProcessData = @{};
|
||||
[hashtable]$ProcessList = @{};
|
||||
[hashtable]$ProcessNamesUnique = @{};
|
||||
[hashtable]$ProcessIDsByName = @{};
|
||||
|
||||
foreach ($processinfo in $ProcessInformation) {
|
||||
[string]$processName = $processinfo.Name.Replace('.exe', '');
|
||||
|
||||
If ($null -ne $Process) {
|
||||
If (-Not ($Process.Contains($processName))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ProcessList.ContainsKey($processName) -eq $FALSE) {
|
||||
$ProcessList.Add($processName, @{
|
||||
'ProcessList' = @{};
|
||||
'PerformanceData' = @{}
|
||||
});
|
||||
}
|
||||
|
||||
$ProcessList[$processName]['ProcessList'].Add(
|
||||
[string]$processinfo.ProcessID, @{
|
||||
'Name' = $processinfo.Name;
|
||||
'ProcessId' = $processinfo.ProcessId;
|
||||
'Priority' = $processinfo.Priority;
|
||||
'PageFileUsage' = $processinfo.PageFileUsage;
|
||||
'ThreadCount' = $processinfo.ThreadCount;
|
||||
'KernelModeTime' = $processinfo.KernelModeTime;
|
||||
'UserModeTime' = $processinfo.UserModeTime;
|
||||
'WorkingSetSize' = $processinfo.WorkingSetSize;
|
||||
'CommandLine' = $processinfo.CommandLine;
|
||||
}
|
||||
);
|
||||
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'ThreadCount' -Process $processinfo;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'PageFileUsage' -Process $processinfo;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'KernelModeTime' -Process $processinfo;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'UserModeTime' -Process $processinfo;
|
||||
Add-IcingaProcessPerfData -ProcessList $ProcessList[$processName]['PerformanceData'] -ProcessKey 'WorkingSetSize' -Process $processinfo;
|
||||
}
|
||||
|
||||
foreach ($processinfo in $ProcessPerfDataList) {
|
||||
if ($processinfo.Name -eq '_Total' -Or $processinfo.Name -eq 'Idle') {
|
||||
continue;
|
||||
}
|
||||
|
||||
If ($null -ne $Process) {
|
||||
If (-Not ($Process.Contains($processName))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
[string]$processName = $processinfo.Name.Split('#')[0];
|
||||
[string]$ProcessId = $processinfo.IDProcess;
|
||||
|
||||
if ($ProcessList.ContainsKey($processName) -eq $FALSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ProcessList[$processName]['ProcessList'].ContainsKey($ProcessId) -eq $FALSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ProcessList[$processName]['ProcessList'][$ProcessId].Add(
|
||||
'WorkingSetPrivate', $processinfo.WorkingSetPrivate
|
||||
);
|
||||
$ProcessList[$processName]['ProcessList'][$ProcessId].Add(
|
||||
'PercentProcessorTime', ($processinfo.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', ($processinfo.PercentProcessorTime / $CPUCoreCount));
|
||||
} else {
|
||||
$ProcessList[$processName]['PerformanceData']['PercentProcessorTime'] += ($processinfo.PercentProcessorTime / $CPUCoreCount);
|
||||
}
|
||||
}
|
||||
|
||||
$ProcessData.Add('Process Count', $ProcessInformation.Count);
|
||||
$ProcessData.add('Processes', $ProcessList);
|
||||
|
||||
return $ProcessData;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Import-IcingaLib core\tools;
|
||||
Import-IcingaLib provider\enums;
|
||||
|
||||
function ConvertTo-ServiceStatusCode()
|
||||
{
|
||||
param (
|
||||
$Status
|
||||
)
|
||||
|
||||
if (Test-Numeric $Status) {
|
||||
return [int]$Status
|
||||
}
|
||||
|
||||
return [int]($ProviderEnums.ServiceStatus.$Status);
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
function Get-IcingaServiceCheckName()
|
||||
{
|
||||
param (
|
||||
[string]$ServiceInput,
|
||||
$Service
|
||||
);
|
||||
|
||||
if ($null -eq $Service) {
|
||||
return [string]::Format(
|
||||
'Service "{0}"',
|
||||
$ServiceInput
|
||||
);
|
||||
}
|
||||
|
||||
return [string]::Format(
|
||||
'Service "{0} ({1})"',
|
||||
$Service.Values.metadata.DisplayName,
|
||||
$Service.Values.metadata.ServiceName
|
||||
);
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
function Get-IcingaServices()
|
||||
{
|
||||
param (
|
||||
[array]$Service
|
||||
);
|
||||
|
||||
$ServiceInformation = Get-Service -Name $Service -ErrorAction SilentlyContinue;
|
||||
$ServiceWmiInfo = $null;
|
||||
|
||||
if ($Service.Count -eq 0) {
|
||||
$ServiceWmiInfo = Get-WmiObject Win32_Service;
|
||||
} else {
|
||||
$ServiceWmiInfo = Get-WmiObject -Class Win32_Service | Where-Object { $Service -Contains $_.Name } | Select-Object StartName, Name;
|
||||
}
|
||||
|
||||
if ($null -eq $ServiceInformation) {
|
||||
return $null;
|
||||
}
|
||||
|
||||
[hashtable]$ServiceData = @{};
|
||||
|
||||
foreach ($service in $ServiceInformation) {
|
||||
|
||||
[array]$DependentServices = $null;
|
||||
[array]$DependingServices = $null;
|
||||
[string]$ServiceUser = '';
|
||||
|
||||
foreach ($wmiService in $ServiceWmiInfo) {
|
||||
if ($wmiService.Name -eq $service.ServiceName) {
|
||||
$ServiceUser = $wmiService.StartName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#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;
|
||||
};
|
||||
'ServiceUser' = $ServiceUser;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return $ServiceData;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
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);
|
||||
$PendingUpdates.Add('updates', @{ });
|
||||
|
||||
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.updates.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;
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
function Get-IcingaLoggedOnUsers()
|
||||
{
|
||||
param(
|
||||
[array]$UserFilter = @()
|
||||
);
|
||||
|
||||
[hashtable]$UserList = @{};
|
||||
[int]$UserCount = 0;
|
||||
$UserList.Add('users', @{ });
|
||||
|
||||
$Users = Get-CIMInstance Win32_LoggedOnUser | Select-Object Antecedent, Dependent;
|
||||
|
||||
foreach ($user in $Users) {
|
||||
[string]$username = $user.Antecedent.Name;
|
||||
|
||||
if ($UserFilter.Count -ne 0) {
|
||||
if (-Not $UserFilter.Contains($username)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$UserCount += 1;
|
||||
|
||||
if ($UserList.users.ContainsKey($username) -eq $FALSE) {
|
||||
$UserList.users.Add(
|
||||
$username,
|
||||
@{
|
||||
'domains' = @($user.Antecedent.Domain);
|
||||
'logonid' = @($user.Dependent.LogonId);
|
||||
'count' = 1;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$UserList.users[$username].domains += $user.Antecedent.Domain;
|
||||
$UserList.users[$username].logonid += $user.Dependent.LogonId;
|
||||
$UserList.users[$username].count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$UserList.Add('count', $UserCount);
|
||||
|
||||
return $UserList;
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
function Get-IcingaUsers()
|
||||
{
|
||||
param (
|
||||
[array]$Username
|
||||
);
|
||||
|
||||
if ($null -eq $Username) {
|
||||
return Get-LocalUser;
|
||||
} else {
|
||||
[array]$UserInformation = @();
|
||||
foreach ($UniqueUser in $Username) {
|
||||
$UserInformation += (Get-LocalUser -Name $UniqueUser);
|
||||
}
|
||||
}
|
||||
|
||||
return $UserInformation;
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
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;
|
||||
'Uptime' = @{
|
||||
'raw' = $WindowsInformations.LastBootUpTime;
|
||||
'value' = ((Get-Date) - $WindowsInformations.LastBootUpTime).TotalSeconds;
|
||||
};
|
||||
'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;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
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