icinga-powershell-plugin-bw-icinga.psm1
function Invoke-IcingaCheckFailedLoginEvents() { # Create our arguments we can use to parse thresholds # Example: Invoke-IcingaCheckTutorial -Warning 10 -Critical 30 param ( $Warning = $null, $Critical = $null, [switch]$NoPerfData = $FALSE, [int]$LastXDays = 7 ); # Create a new object we can check on. This will include # comparing values and checking if they are between a # range is Unknown $Check = New-IcingaCheck ` -Name 'FailedLoginEvents' ` -Value ( $(Get-WinEvent -FilterHashtable @{ProviderName = "Microsoft-Windows-Security-Auditing";ID="4625"} | where {$_.TimeCreated -ge $(Get-Date).AddDays(-$LastXDays)}).count ); # Each compare function within our check object will return the # object itself, allowing us to write a nested call like below # to compare multiple values at once. # IMPORTANT: We have to output the last call either to Out-Null # or store the result inside a variable, as the check # object is otherwise written into our plugin output $Check.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; # Don't forget to add our comparison for the second check with # the identical thresholds. If you want to, you could compare # them to different arguments # Return our checkresult for the provided check and compile it # This function will take care to write the plugin output and # with return we will return the exit code to determine if our # check is Ok, Warning, Critical or Unknown return (New-IcingaCheckResult -Check $Check -NoPerfData $NoPerfData -Compile) } #Invoke-IcingaCheckFailedLoginEvents -Warning 3 -Critical 5 -NoPerfData Export-ModuleMember -Function Invoke-IcingaCheckFailedLoginEvents |