Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

From Windows Server 2008+, wuauserv is no longer a service that's ran all of the time and is instead ran as a scheduled task. I'm not sure of the exact behavior of how the scheduled task is created as it seems the schedule is generated and edited by another service. Prior to this, we setup nagios to just check for the running service to ensure it was accepting updates.

My question is, how does one utilize nagios to track the proper execution/running of wuauserv service in Windows Server 2008+ to ensure it is accepting updates?

share|improve this question

1 Answer 1

up vote 3 down vote accepted
+50

It looks like there are a number of plugins at Nagios Exchange to check for available updates--for example, this one. I've used this one in the past, I believe. That's not precisely what you're asking, though; those are whether updates exist, and you're asking whether or not the system is checking for updates.

What might be closer to what you're looking for is something like this PowerShell script:

$lastcheck = Get-ItemProperty -Path Registry::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Detect" 

$lastdate=[datetime]$lastcheck.LastSuccessTime
$currdate = (Get-Date)
$status = new-timespan -start $lastdate -end $currdate


If ($status.days -eq 0 -and $lastcheck.LastError -eq 0) {
    Write-Host "OK:  Wuauserv last ran $lastdate."
    $exitcode = $status.Days
}
elseif ($status.days -eq 1 -and $lastcheck.LastError -eq 0) {
    Write-Host "WARNING:  Wuauserv last ran $lastdate."
    $exitcode = $status.Days
} else {
    Write-Host "CRITICAL:  Wuauserv last ran $lastdate."
    $exitcode = 2
}
exit $exitcode

(You'd want to check that the date was within the last 24 hours (the default interval is 22 hours) and that the last error was 0.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.