Monitoring Windows Server Backup with Check_MK (Server 2008 R2)

Below Powershell script will monitor Windows Server backups with Check_MK.


Before starting – You must install Windows Server Backup Features Command Line Tools.

To do this, open up Server Manager and go to Features > Add Features

In the Add Features menu, expand “Windows Server Backup Features” and ensure “Command-Line tools” is enabled, if not – Proceed to install this (No restart required).

The Backup Monitoring Script:

Assuming a default installation of the Check_MK agent on your Windows server, create the file below:

C:\Program Files (x86)\check_mk\local\server-backup-status.ps1

#region Parameters 
#endregion Parameters 
$rsession = New-PSSession -ComputerName localhost
Invoke-Command -Session $rsession -ScriptBlock {add-pssnapin windows.serverbackup -ErrorAction SilentlyContinue; $status = get-wbjob -previous 1;$runstatus = get-wbjob} 
$rstatus = Invoke-Command -Session $rsession -ScriptBlock {$status} 
$runningstatus = Invoke-Command -Session $rsession -ScriptBlock {$runstatus} 
remove-pssession $rsession 
if ($rstatus.hresult -eq "0" -and !$hresult) 
$Backup = "0 WindowsBackup - Success, last backup at {0} {1}" -f $outstatus, $rstatus.endtime 
elseif ($hresult.Contains("warnings")) 
$Backup = "1 WindowsBackup - Warning, last backup did not complete successfully {0}" -f $rstatus.endtime
$Backup = "2 WindowsBackup - Failed, last backup at did not complete successfully {0}" -f $rstatus.endtime
if ($runningstatus.CurrentOperation) 
$Backup = "0 WindowsBackup - Backup in process. Last completed successfully at {0}" -f $rstatus.endtime
Write-output $Backup

Run an inventory from your Check_MK server and ensure the backup status monitoring now appears.

Any comments or questions? Get in touch here or Email me at [email protected]