Skip to content

Instantly share code, notes, and snippets.

@liveaverage
Created July 29, 2014 13:47
Show Gist options
  • Save liveaverage/9114265640b97cabc14e to your computer and use it in GitHub Desktop.
Save liveaverage/9114265640b97cabc14e to your computer and use it in GitHub Desktop.
Local Check_MK: check_DNS_Scavenge.ps1
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(500,300)
$server = $env:COMPUTERNAME
$global:debug = ""
$global:n_stat = ""
$global:n_stattext = ""
function GetScavengeStatus($server)
{
$global:n_stat=0
$global:n_stattext = "Initialized "
$e1 = Get-WinEvent -FilterHashTable @{logname="DNS Server"; ID = 2501} `
| sort-object TimeCreated -descending `
| select-object -first 1
$nextscav = $e1.TimeCreated.addhours( 7 * 24 + 1 )
$global:n_stattext = "Last scavenge at {0}; Next Scavenge at {1}" -f $e1.TimeCreated.toString(""), $nextscav.toString("")
if ( $e1.LevelDisplayName -ne "Information" ) {
$global:n_stat=2
$global:n_stattext = "DNS scavenge at {0}, returned {1}" -f $e1.TimeCreated.toString(""), $e1.EntryType
}
if ($nagios_status -eq 0 -and $nextscav.compareTo( (get-date)) -lt 1 ) {
$global:n_stat=2
$global:n_stattext = "Expected scavenge did not occur at {0}" -f $nextscav
}
}
#Main:
GetScavengeStatus $server
echo "$global:n_stat DNS_Scavenge - $global:n_stattext"
#echo $global:Debug
#exit $global:n_stat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment