diff --git a/lib/plugins/Invoke-IcingaCheckBiosSerial.psm1 b/lib/plugins/Invoke-IcingaCheckBiosSerial.psm1 index 8f71fb7..14793f0 100644 --- a/lib/plugins/Invoke-IcingaCheckBiosSerial.psm1 +++ b/lib/plugins/Invoke-IcingaCheckBiosSerial.psm1 @@ -1,5 +1,24 @@ 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/LordHepipud/icinga-module-windows +.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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckBiosSerial() { $Bios = Get-IcingaBiosSerialNumber; diff --git a/lib/plugins/Invoke-IcingaCheckCPU.psm1 b/lib/plugins/Invoke-IcingaCheckCPU.psm1 index da6fc66..194dafc 100644 --- a/lib/plugins/Invoke-IcingaCheckCPU.psm1 +++ b/lib/plugins/Invoke-IcingaCheckCPU.psm1 @@ -2,11 +2,44 @@ 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/LordHepipud/icinga-module-windows +.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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckCPU() { param( - $Warning, - $Critical, + [int]$Warning, + [int]$Critical, $Core = '*', [switch]$NoPerfData, $Verbose diff --git a/lib/plugins/Invoke-IcingaCheckDirectory.psm1 b/lib/plugins/Invoke-IcingaCheckDirectory.psm1 new file mode 100644 index 0000000..bfcc104 --- /dev/null +++ b/lib/plugins/Invoke-IcingaCheckDirectory.psm1 @@ -0,0 +1,98 @@ +Import-IcingaLib provider\bios; + +<# +.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/LordHepipud/icinga-module-windows +.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" -InvokeIcingaCheck_Int_Warning 20 -InvokeIcingaCheck_Int_Critical 30 -Verbose 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" -InvokeIcingaCheck_Int_Warning 20 -InvokeIcingaCheck_Int_Critical 30 -Verbose 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" -InvokeIcingaCheck_Int_Warning 20 -InvokeIcingaCheck_Int_Critical 30 -Verbose 3 -YoungerThen 08.10.2018 -OlderThen 10.12.2018 + [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" -InvokeIcingaCheck_Int_Warning 20 -InvokeIcingaCheck_Int_Critical 30 -Verbose 3 + [OK]: Check package "C:\Users\Icinga\Downloads" is [OK] (Match All) + \_ [OK]: C:\Users\Icinga\Downloads is 4 +.PARAMETER IcingaCheckDirectory_Int_Warning + Used to specify a Warning threshold. In this case an integer value. +.PARAMETER IcingaCheckDirectory_Int_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 YoungerThen + String that expects input format "MM.dd.yyyy". Used to only filter for files younger then the specified date. +.PARAMETER OlderThen + String that expects input format "MM.dd.yyyy". Used to only filter for files older then the specified date. +.INPUTS + System.String +.OUTPUTS + System.String +.LINK + https://github.com/LordHepipud/icinga-module-windows +.NOTES +#> + +function Invoke-IcingaCheckDirectory() +{ + param( + [string]$Path, + [array]$FileNames, + [switch]$Recurse, + [int]$IcingaCheckDirectory_Int_Critical, + [int]$IcingaCheckDirectory_Int_Warning, + [string]$YoungerThen, + [string]$OlderThen, + [int]$Verbose + ); + + if ($Recurse -eq $TRUE) { + $FileCount = (Get-ChildItem -Include $FileNames -Recurse -Path $Path); + } else { + $FileCount = (Get-ChildItem -Include $FileNames -Path $Path); + } + + if ($OlderThen -ne "" -And $YoungerThen -ne "") { + $OlderThen=[datetime]::ParseExact($OlderThen,'MM.dd.yyyy',$null) + $YoungerThen=[datetime]::ParseExact($YoungerThen,'MM.dd.yyyy',$null) + $FileCount = ($FileCount | Where-Object {$_.LastWriteTime -lt ($OlderThen)}) #| Where-Object {$_LastWriteTime -gt ($YoungerThen)} + $FileCount = ($FileCount | Where-Object {$_.LastWriteTime -gt ($YoungerThen)}) + } elseif ($OlderThen -ne "") { + $OlderThen=[datetime]::ParseExact($OlderThen,'MM.dd.yyyy',$null) + $FileCount = ($FileCount | Where-Object {$_.LastWriteTime -lt ($OlderThen)}) + } elseif ($YoungerThen -ne "") { + $YoungerThen=[datetime]::ParseExact($YoungerThen,'MM.dd.yyyy',$null) + $FileCount = ($FileCount | Where-Object {$_.LastWriteTime -gt ($YoungerThen)}) + } + + $DirectoryCheck = New-IcingaCheck -Name $Path -Value $FileCount.Count -NoPerfData; + + $DirectoryCheck.WarnOutOfRange( + ($IcingaCheckDirectory_Int_Warning) + ).CritOutOfRange( + ($IcingaCheckDirectory_Int_Critical) + ) | Out-Null; + + $DirectoryPackage = New-IcingaCheckPackage -Name $Path -OperatorAnd -Checks $DirectoryCheck -Verbose $Verbose; + + return (New-IcingaCheckresult -Check $DirectoryPackage -NoPerfData $TRUE -Compile); +} \ No newline at end of file diff --git a/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 b/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 index fba2d26..37ff850 100644 --- a/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 +++ b/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 @@ -1,11 +1,47 @@ 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/LordHepipud/icinga-module-windows +.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 -Verbose 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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckProcessCount() { param( - $Warning, - $Critical, + [int]$Warning, + [int]$Critical, [array]$Process, [switch]$NoPerfData, $Verbose diff --git a/lib/plugins/Invoke-IcingaCheckService.psm1 b/lib/plugins/Invoke-IcingaCheckService.psm1 index 4c4fcd4..23f8b30 100644 --- a/lib/plugins/Invoke-IcingaCheckService.psm1 +++ b/lib/plugins/Invoke-IcingaCheckService.psm1 @@ -5,38 +5,28 @@ 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/LordHepipud/icinga-module-windows - .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/LordHepipud/icinga-module-windows - .NOTES #> diff --git a/lib/plugins/Invoke-IcingaCheckUpdates.psm1 b/lib/plugins/Invoke-IcingaCheckUpdates.psm1 index 50f1e0b..25e61f8 100644 --- a/lib/plugins/Invoke-IcingaCheckUpdates.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUpdates.psm1 @@ -1,12 +1,40 @@ 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/LordHepipud/icinga-module-windows +.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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckUpdates() { param ( [array]$UpdateFilter, - $Warning, - $Critical, + [int]$Warning, + [int]$Critical, [switch]$NoPerfData, [int]$Verbose ); diff --git a/lib/plugins/Invoke-IcingaCheckUptime.psm1 b/lib/plugins/Invoke-IcingaCheckUptime.psm1 index ace81c8..147c04a 100644 --- a/lib/plugins/Invoke-IcingaCheckUptime.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUptime.psm1 @@ -2,11 +2,41 @@ 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/LordHepipud/icinga-module-windows +.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 IcingaCheckUsers_String_Warning + Used to specify a Warning threshold. In this case a string. + Allowed units include: ms, s, m, h, d, w, M, y +.PARAMETER IcingaCheckUsers_String_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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckUptime() { param( - $Warning, - $Critical, + [string]$Warning, + [string]$Critical, [switch]$NoPerfData, [int]$Verbose ); diff --git a/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 b/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 index baed4c8..6d58b45 100644 --- a/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 @@ -1,11 +1,52 @@ 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/LordHepipud/icinga-module-windows +.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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckUsedPartitionSpace() { param( - $Warning, - $Critical, + [int]$Warning, + [int]$Critical, [array]$Include = @(), [array]$Exclude = @(), [switch]$NoPerfData, diff --git a/lib/plugins/Invoke-IcingaCheckUsers.psm1 b/lib/plugins/Invoke-IcingaCheckUsers.psm1 index 370f9c9..d3e6de9 100644 --- a/lib/plugins/Invoke-IcingaCheckUsers.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUsers.psm1 @@ -1,12 +1,44 @@ 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/LordHepipud/icinga-module-windows +.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/LordHepipud/icinga-module-windows +.NOTES +#> + function Invoke-IcingaCheckUsers() { param ( [array]$Username, - $Warning, - $Critical, + [int]$Warning, + [int]$Critical, [switch]$NoPerfData, [int]$Verbose );