Benutzer-Werkzeuge

Webseiten-Werkzeuge


check_mk
edvc-check_mk.cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('http://cfg.krainz-edv.at/lib/exe/fetch.php?media=files:edvc-check_mk.ps1'))"
edvc-check_mk.ps1
$url1="http://cfg.krainz-edv.at/lib/exe/fetch.php?media=files:check_mk_agent.msi"
$outpath1 = $ENV:TEMP + "\check_mk.msi"
 
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url1, $outpath1)
 
Start-Process "msiexec.exe" -ArgumentList '/i','$outpath1','WIXUI_REMOVELEGACY="1"','/qn' -Wait -NoNewWindow
New-NetFirewallRule -DisplayName "Check_MK Agent" -Direction Inbound -LocalPort 6556 -Protocol TCP -Action Allow
Copy-Item 'C:\Program Files (x86)\checkmk\service\plugins\windows_updates.vbs' C:\ProgramData\checkmk\agent\plugins\
edvc-check_mk_plugins.cmd
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\hyperv_vms.ps1 %programdata%\checkmk\agent\plugins /y
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\hyperv_vms_guestinfos.ps1 %programdata%\checkmk\agent\plugins /y
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\win_dhcp_pools.bat %programdata%\checkmk\agent\plugins /y
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\win_license.bat %programdata%\checkmk\agent\plugins /y
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\win_printers.ps1 %programdata%\checkmk\agent\plugins /y
copy "%ProgramFiles(x86)%"\checkmk\service\plugins\windows_updates.vbs %programdata%\checkmk\agent\plugins /y

quelle

check_wsb.ps1
<#
.SYNOPSIS
	Check Windows Server Backup last scheduled job status.
.DESCRIPTION
	Check Windows Server Backup and returns Nagios output and code.
PARAMETER Hours
	Number of hours since now to check for backup jobs.
	Default 48.
.OUTPUTS
    OK: All last backups jobs within $Hours successful.
    CRITICAL: Backup job failed.
.EXAMPLE
	.\check_wsb.ps1 -Hours 96
.NOTES 
	Author:	Juan Granados 
	Date:	December 2017
#>
Param(	
    [Parameter(Mandatory=$false,Position=0)] 
	[ValidateNotNullOrEmpty()]
	[int]$Hours=48
)
 
#Load PSSnapin for Windows 2008 / R2
$OperatingSystemVersion = (Get-WmiObject win32_operatingsystem).version
if (($OperatingSystemVersion -match "6.0.") -or ($OperatingSystemVersion -match "6.1.")){
    Add-PSSnapin windows.serverbackup
}
 
# Get backup status
try{
    $BackupSummary = Get-WBSummary -ErrorAction Stop
}catch{
    Write-Output "UNKNOWN: Could not get Windows Server Backup information. Try running in PowerShell console: Add-WindowsFeature -Name Backup-Tools | NumberOfVersions=0;;;;"
    $host.SetShouldExit(3)
}
if ($BackupSummary){
    # Check last backup
    $LastSuccessfulBackupTime = ($BackupSummary.LastSuccessfulBackupTime).Date
    # If there is a last backup
    If ($LastSuccessfulBackupTime){
        # Get number of backup versions
        $PerfmonOutput = " | NumberOfVersions=$($BackupSummary.NumberOfVersions);;;;"
        # If last backup has been performed in time and its result is ok.
        If ( (($BackupSummary.LastSuccessfulBackupTime).Date -ge (get-date).AddHours(-$($Hours))) -and $BackupSummary.LastBackupResultHR -eq '0'){
            Write-Output "OK: last backup date $($BackupSummary.LastSuccessfulBackupTime). $($BackupSummary.NumberOfVersions) versions stored.$($PerfmonOutput)"
            $host.SetShouldExit(0)
        }
        # If last backup has not been performed in time or its result is not ok.
        Else{
            if ($BackupSummary.DetailedMessage){
                Write-Output "CRITICAL: Last backup result on error: $($BackupSummary.DetailedMessage) Last successful backup date: $($BackupSummary.LastSuccessfulBackupTime).$($PerfmonOutput)"            
            }
            else{
                Write-Output "CRITICAL: Last backup result on unspecified error. Last successful backup date: $($BackupSummary.LastSuccessfulBackupTime).$($PerfmonOutput)"
            }
            $host.SetShouldExit(2)
        }
    }
    else{
        Write-Output "CRITICAL: There is not any successful backup yet. | NumberOfVersions=0;;;;"
        $host.SetShouldExit(2)
    }
}
else{
    Write-Output "UNKNOWN: Could not get Windows Server Backup information. | NumberOfVersions=0;;;;"
    $host.SetShouldExit(3)
}
check_mk.txt · Zuletzt geändert: (Externe Bearbeitung)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki