Comprehensive data protection for all workloads
Post Reply
smarechal
Enthusiast
Posts: 56
Liked: 11 times
Joined: Dec 21, 2015 1:23 pm
Full Name: Siegfried
Contact:

Nagios/Centreon NSC++ client check

Post by smarechal » 1 person likes this post

Hello,

I've arranged a powershell script made for vRanger to Veeam.
You can check your job status with nagios/centreon.
It contains min max job duration and min and max job interval:

Code: Select all

#VEEAM BACKUP CHECK JOB

##########################################################################
# Quest Vranger Nagios check
# For monitoring duration and run interval of backup jobs
# 12/2013 Simon Meggle <simon.meggle@consol.de>
# warn/crit for "duration": maximum allowed run time
# warn/crit for "interval": maximum age of the last backup (e.g. for a daily backup, 
#   set warning to 24h + 1h, crit to 24h + 4h)
###########################################################################
# NSC.ini: 
# check_veeam_vm= cmd /c echo scripts\check_veeam_job.ps1 -JobName "Backup" -duration_warning 4 -duration_critical 5 -interval_warning 25 -interval_critical 28 ; exit($lastexitcode) | powershell.exe -command -

# Specifies command parameter required for requesting the backup job name.



Param (
[parameter(Mandatory = $true)][string] $JobName,
[parameter(Mandatory = $true)][single] $duration_warning,
[parameter(Mandatory = $true)][single] $duration_critical,
[parameter(Mandatory = $true)][single] $interval_warning,
[parameter(Mandatory = $true)][single] $interval_critical
);


function getState ($state) {
switch ($State) 
{
0 {return "OK"}
1 {return "WARNING"}
2 {return "CRITICAL"}
3 {return "UNKNOWN"}
}
}

function getStateID($val,$w,$c) {
if ($val -gt $c) {
return 2;
} else {
if ($val -gt $w) {
return 1
} else {
return 0

}
}
}

$output = "";
$NagiosState = 0;

if (-not (asnp VeeamPSSnapin -ErrorAction SilentlyContinue)) 
{
asnp VeeamPSSnapin > $null
}

$Template = Get-VBRJob -Name $JobName;
if ($Template -eq $null) {
Write-Host "UNKNOWN: Could not find any matching job template!";
exit 3;
}


$Job = Get-VBRBackupSession | ?{$_.JobName -eq $jobName} | Select -Last 1
if ($Job -eq $null) {
Write-Host "UNKNOWN: Could not find any matching job!";
exit 3;
}

#Write-Host ($Job | Format-List | Out-String);


$today = Get-Date;

# Interval exceeded?
$interval_diff = New-TimeSpan $Job.CreationTime $today;
$interval_diff_hours = [math]::Round( ($interval_diff).hours + ($interval_diff).minutes / 60,1); 
$interval_stateID = getStateID $interval_diff_hours $interval_warning $interval_critical;

switch ($interval_stateID)
{
0 { $output = "Backup interval ok."; }
1 { 
Write-Host "WARNING: Last backup job ""$JobName"" was started "$interval_diff_hours "hours ago. (warn at" $interval_warning"h, crit at" $interval_critical"h)."; 
exit $interval_stateID;
}
2 { 
Write-Host "CRITICAL: Last backup job ""$JobName"" was started "$interval_diff_hours "hours ago. (warn at" $interval_warning"h, crit at" $interval_critical"h)."; 
exit $interval_stateID;
}
}

# Job successful?
if ($Job.Result -ne "Success") {
Write-Host "CRITICAL: Backup job ""$JobName"" within interval, but completed on "$Job.EndTime "with errors!";
exit 2;
}

# Duration
$duration_diff = New-TimeSpan $Job.CreationTime $Job.EndTime;
$duration_diff_hours = [math]::Round( ($duration_diff).hours + ($duration_diff).minutes / 60,1);
$duration_stateID = getStateID $duration_diff_hours $duration_warning $duration_critical;

switch ($duration_stateID) 
{
0 { $output = "OK: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
1 { $output = "WARNING: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
2 { $output = "CRITICAL: Backup job ""$JobName"" completed in "+$duration_diff_hours+" hours (warn at " + $duration_warning + "h, crit at " + $duration_critical + "h) at "+$Job.EndTime+"."; }
default { Write-Host "UNKNOWN: Could not check Backup job state of "$JobName"."; exit 3;}
}

$output = $output + "|time="+$duration_diff_hours+";"+$duration_warning+";"+$duration_critical;

Write-Host $output;
exit $NagiosState;

Here is the result in Centreon:
Image
Dima P.
Product Manager
Posts: 14396
Liked: 1568 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Nagios/Centreon NSC++ client check

Post by Dima P. »

Hi smarechal,

Have you looked into Veeam One monitoring, reporting, and capacity planning tool? Just asking :mrgreen:
smarechal
Enthusiast
Posts: 56
Liked: 11 times
Joined: Dec 21, 2015 1:23 pm
Full Name: Siegfried
Contact:

Re: Nagios/Centreon NSC++ client check

Post by smarechal »

Of course, yes!
But i have to monitor network, hardware, UPS etc ... And Veeam One can't do this :mrgreen:
I've got a Nagvis screen with all my monitored infrastructure.
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Nagios/Centreon NSC++ client check

Post by Vitaliy S. » 1 person likes this post

You can also integrate Veeam ONE reporting for backup jobs via predefined web-based dashboard, just embed a link with a dashboard to the Nagios screen.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 313 guests