Skip to content

Commit

Permalink
Veeam SNMP traps fix and extend (librenms#13549)
Browse files Browse the repository at this point in the history
* Veeam fix and extend part 1

* Veeam SNMP traps

* StyleCI

* StyleCI

* Fix typo

* Lint

* Fix tests

* Fix tests :fingerscrossed:

* Think i get it now

* This is it?

* gotta be it

* Final

* Again
  • Loading branch information
jepke committed Nov 24, 2021
1 parent 382ef62 commit 42fdbea
Show file tree
Hide file tree
Showing 19 changed files with 524 additions and 48 deletions.
8 changes: 3 additions & 5 deletions LibreNMS/Snmptrap/Handlers/VeeamBackupJobCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ public function handle(Device $device, Trap $trap)
{
$name = $trap->getOidData('VEEAM-MIB::backupJobName');
$comment = $trap->getOidData('VEEAM-MIB::backupJobComment');
$result = $trap->getOidData('VEEAM-MIB::backupJobResult');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

if ($trap->getOidData('VEEAM-MIB::backupJobResult') == 'Success') {
Log::event('SNMP Trap: Backup Job success - ' . $name . ' ' . $comment, $device->device_id, 'backup', 1);
} else {
Log::event('SNMP Trap: Backup Job failed - ' . $name . ' ' . $comment, $device->device_id, 'backup', 5);
}
Log::event('SNMP Trap: Backup Job ' . $result . ' - ' . $name . ' - ' . $comment, $device->device_id, 'backup', $color[$result]);
}
}
29 changes: 29 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamCdpRpoReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamCdpRpoReport implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$policy_name = $trap->getOidData('VEEAM-MIB::cdpPolicyName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$result = $trap->getOidData('VEEAM-MIB::cdpRpoStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: CDP policy RPO status change' . $result . ' - ' . $policy_name . ' ' . $vm_name, $device->device_id, 'policy', $color[$result]);
}
}
32 changes: 32 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamLinuxFLRCopyToFinished implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$target_host = $trap->getOidData('VEEAM-MIB::targetHost');
$target_dir = $trap->getOidData('VEEAM-MIB::targetDir');
$time = $trap->getOidData('VEEAM-MIB::transferTime');
$result = $trap->getOidData('VEEAM-MIB::transferStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: FLR job ' . $result . ' - ' . $vm_name . ' - ' . $initiator_name . ' ' . $target_host . ' ' . $target_dir . ' Time taken: ' . $time, $device->device_id, 'backup', $color[$result]);
}
}
29 changes: 29 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToStarted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamLinuxFLRCopyToStarted implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$target_host = $trap->getOidData('VEEAM-MIB::targetHost');
$target_dir = $trap->getOidData('VEEAM-MIB::targetDir');

Log::event('SNMP Trap: FLR job started - ' . $vm_name . ' - ' . $initiator_name . ' ' . $target_dir . ' ' . $target_host, $device->device_id, 'backup', 2);
}
}
27 changes: 27 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRMountStarted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamLinuxFLRMountStarted implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');

Log::event('SNMP Trap: FLR job started - ' . $vm_name . ' - ' . $initiator_name, $device->device_id, 'backup', 2);
}
}
30 changes: 30 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamLinuxFLRToOriginalFinished implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$time = $trap->getOidData('VEEAM-MIB::transferTime');
$result = $trap->getOidData('VEEAM-MIB::transferStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: FLR job ' . $result . ' - ' . $vm_name . ' - ' . $initiator_name . ' Time taken: ' . $time, $device->device_id, 'backup', $color[$result]);
}
}
27 changes: 27 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalStarted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamLinuxFLRToOriginalStarted implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');

Log::event('SNMP Trap: FLR job started - ' . $vm_name . ' - ' . $initiator_name, $device->device_id, 'backup', 2);
}
}
28 changes: 28 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamSobrOffloadFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamSobrOffloadFinished implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$name = $trap->getOidData('VEEAM-MIB::repositoryName');
$result = $trap->getOidData('VEEAM-MIB::repositoryStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: Scale-out offload job ' . $result . ' - ' . $name, $device->device_id, 'backup', $color[$result]);
}
}
30 changes: 30 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamVmBackupCompleted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamVmBackupCompleted implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$job_name = $trap->getOidData('VEEAM-MIB::backupJobName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$comment = $trap->getOidData('VEEAM-MIB::vmBackupComment');
$result = $trap->getOidData('VEEAM-MIB::vmBackupResult');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: VM backup ' . $result . ' - ' . $vm_name . ' Job: ' . $job_name . ' - ' . $comment, $device->device_id, 'backup', $color[$result]);
}
}
31 changes: 0 additions & 31 deletions LibreNMS/Snmptrap/Handlers/VeeamVmBackupJobCompleted.php

This file was deleted.

29 changes: 29 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamWebDownloadFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamWebDownloadFinished implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$result = $trap->getOidData('VEEAM-MIB::transferStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: 1 click FLR job ' . $result . ' - ' . $vm_name . ' - ' . $initiator_name, $device->device_id, 'backup', $color[$result]);
}
}
27 changes: 27 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamWebDownloadStart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamWebDownloadStart implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');

Log::event('SNMP Trap: 1 click FLR job started - ' . $vm_name . ' - ' . $initiator_name, $device->device_id, 'backup', 2);
}
}
30 changes: 30 additions & 0 deletions LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace LibreNMS\Snmptrap\Handlers;

use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;

class VeeamWinFLRCopyToFinished implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$initiator_name = $trap->getOidData('VEEAM-MIB::initiatorName');
$vm_name = $trap->getOidData('VEEAM-MIB::vmName');
$target_dir = $trap->getOidData('VEEAM-MIB::targetDir');
$result = $trap->getOidData('VEEAM-MIB::transferStatus');
$color = ['Success' => 1, 'Warning' => 4, 'Failed' => 5];

Log::event('SNMP Trap: FLR job ' . $result . ' - ' . $vm_name . ' - ' . $initiator_name . ' ' . $target_dir, $device->device_id, 'backup', $color[$result]);
}
}
Loading

0 comments on commit 42fdbea

Please sign in to comment.