From 42fdbea126364bf4d2d52d220a183e1ddbec5c07 Mon Sep 17 00:00:00 2001 From: Wheel Date: Wed, 24 Nov 2021 18:20:56 +0100 Subject: [PATCH] Veeam SNMP traps fix and extend (#13549) * 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 --- .../Handlers/VeeamBackupJobCompleted.php | 8 +- .../Snmptrap/Handlers/VeeamCdpRpoReport.php | 29 ++++++ .../Handlers/VeeamLinuxFLRCopyToFinished.php | 32 +++++++ .../Handlers/VeeamLinuxFLRCopyToStarted.php | 29 ++++++ .../Handlers/VeeamLinuxFLRMountStarted.php | 27 ++++++ .../VeeamLinuxFLRToOriginalFinished.php | 30 +++++++ .../VeeamLinuxFLRToOriginalStarted.php | 27 ++++++ .../Handlers/VeeamSobrOffloadFinished.php | 28 ++++++ .../Handlers/VeeamVmBackupCompleted.php | 30 +++++++ .../Handlers/VeeamVmBackupJobCompleted.php | 31 ------- .../Handlers/VeeamWebDownloadFinished.php | 29 ++++++ .../Handlers/VeeamWebDownloadStart.php | 27 ++++++ .../Handlers/VeeamWinFLRCopyToFinished.php | 30 +++++++ .../Handlers/VeeamWinFLRCopyToStarted.php | 28 ++++++ .../Handlers/VeeamWinFLRMountStarted.php | 27 ++++++ .../VeeamWinFLRToOriginalFinished.php | 29 ++++++ .../Handlers/VeeamWinFLRToOriginalStarted.php | 27 ++++++ config/snmptraps.php | 16 +++- tests/Feature/SnmpTraps/VeeamTrapTest.php | 88 ++++++++++++++++--- 19 files changed, 524 insertions(+), 48 deletions(-) create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamCdpRpoReport.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToStarted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRMountStarted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalStarted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamSobrOffloadFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamVmBackupCompleted.php delete mode 100644 LibreNMS/Snmptrap/Handlers/VeeamVmBackupJobCompleted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWebDownloadFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWebDownloadStart.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToStarted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWinFLRMountStarted.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalFinished.php create mode 100644 LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalStarted.php diff --git a/LibreNMS/Snmptrap/Handlers/VeeamBackupJobCompleted.php b/LibreNMS/Snmptrap/Handlers/VeeamBackupJobCompleted.php index dda7107def..88f5e42065 100644 --- a/LibreNMS/Snmptrap/Handlers/VeeamBackupJobCompleted.php +++ b/LibreNMS/Snmptrap/Handlers/VeeamBackupJobCompleted.php @@ -21,11 +21,9 @@ class VeeamBackupJobCompleted implements SnmptrapHandler { $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]); } } diff --git a/LibreNMS/Snmptrap/Handlers/VeeamCdpRpoReport.php b/LibreNMS/Snmptrap/Handlers/VeeamCdpRpoReport.php new file mode 100644 index 0000000000..110296a903 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamCdpRpoReport.php @@ -0,0 +1,29 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToFinished.php new file mode 100644 index 0000000000..b83633a0c9 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToFinished.php @@ -0,0 +1,32 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToStarted.php new file mode 100644 index 0000000000..f4f828a921 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRCopyToStarted.php @@ -0,0 +1,29 @@ +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); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRMountStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRMountStarted.php new file mode 100644 index 0000000000..2817249100 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRMountStarted.php @@ -0,0 +1,27 @@ +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); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalFinished.php new file mode 100644 index 0000000000..635612c9c1 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalFinished.php @@ -0,0 +1,30 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalStarted.php new file mode 100644 index 0000000000..074198e921 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamLinuxFLRToOriginalStarted.php @@ -0,0 +1,27 @@ +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); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamSobrOffloadFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamSobrOffloadFinished.php new file mode 100644 index 0000000000..971dbe1b80 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamSobrOffloadFinished.php @@ -0,0 +1,28 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamVmBackupCompleted.php b/LibreNMS/Snmptrap/Handlers/VeeamVmBackupCompleted.php new file mode 100644 index 0000000000..eafe8e5f65 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamVmBackupCompleted.php @@ -0,0 +1,30 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamVmBackupJobCompleted.php b/LibreNMS/Snmptrap/Handlers/VeeamVmBackupJobCompleted.php deleted file mode 100644 index df2e6f83e7..0000000000 --- a/LibreNMS/Snmptrap/Handlers/VeeamVmBackupJobCompleted.php +++ /dev/null @@ -1,31 +0,0 @@ -getOidData('VEEAM-MIB::backupJobName'); - $comment = $trap->getOidData('VEEAM-MIB::vmName'); - - if ($trap->getOidData('VEEAM-MIB::vmBackupResult') == 'Success') { - Log::event('SNMP Trap: VM Backup success - ' . $name . ' ' . $comment, $device->device_id, 'backup', 1); - } else { - Log::event('SNMP Trap: VM Backup failed - ' . $name . ' ' . $comment, $device->device_id, 'backup', 5); - } - } -} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadFinished.php new file mode 100644 index 0000000000..47eb59587d --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadFinished.php @@ -0,0 +1,29 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadStart.php b/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadStart.php new file mode 100644 index 0000000000..18e00a2cc9 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWebDownloadStart.php @@ -0,0 +1,27 @@ +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); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToFinished.php new file mode 100644 index 0000000000..280569efd2 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToFinished.php @@ -0,0 +1,30 @@ +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]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToStarted.php new file mode 100644 index 0000000000..dfb86ea5c9 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRCopyToStarted.php @@ -0,0 +1,28 @@ +getOidData('VEEAM-MIB::initiatorName'); + $vm_name = $trap->getOidData('VEEAM-MIB::vmName'); + $target_dir = $trap->getOidData('VEEAM-MIB::targetDir'); + + Log::event('SNMP Trap: FLR job started - ' . $vm_name . ' - ' . $initiator_name . ' - ' . $target_dir, $device->device_id, 'backup', 2); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWinFLRMountStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRMountStarted.php new file mode 100644 index 0000000000..8c7a1a7f51 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRMountStarted.php @@ -0,0 +1,27 @@ +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); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalFinished.php b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalFinished.php new file mode 100644 index 0000000000..6b8839ace4 --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalFinished.php @@ -0,0 +1,29 @@ +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: FLR job started - ' . $vm_name . ' - ' . $initiator_name, $device->device_id, 'backup', $color[$result]); + } +} diff --git a/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalStarted.php b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalStarted.php new file mode 100644 index 0000000000..e744300cae --- /dev/null +++ b/LibreNMS/Snmptrap/Handlers/VeeamWinFLRToOriginalStarted.php @@ -0,0 +1,27 @@ +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); + } +} diff --git a/config/snmptraps.php b/config/snmptraps.php index 962bed029d..5e2aabb050 100644 --- a/config/snmptraps.php +++ b/config/snmptraps.php @@ -116,7 +116,21 @@ return [ 'OSPF-TRAP-MIB::ospfNbrStateChange' => \LibreNMS\Snmptrap\Handlers\OspfNbrStateChange::class, 'UPS-MIB::upsTraps.0.1' => \LibreNMS\Snmptrap\Handlers\UpsTrapsOnBattery::class, 'VEEAM-MIB::onBackupJobCompleted' => \LibreNMS\Snmptrap\Handlers\VeeamBackupJobCompleted::class, - 'VEEAM-MIB::onVmBackupJobCompleted' => \LibreNMS\Snmptrap\Handlers\VeeamVmBackupJobCompleted::class, + 'VEEAM-MIB::onVmBackupCompleted' => \LibreNMS\Snmptrap\Handlers\VeeamVmBackupCompleted::class, + 'VEEAM-MIB::onLinuxFLRMountStarted' => \LibreNMS\Snmptrap\Handlers\VeeamLinuxFLRMountStarted::class, + 'VEEAM-MIB::onLinuxFLRCopyToStarted' => \LibreNMS\Snmptrap\Handlers\VeeamLinuxFLRCopyToStarted::class, + 'VEEAM-MIB::onLinuxFLRToOriginalStarted' => \LibreNMS\Snmptrap\Handlers\VeeamLinuxFLRToOriginalStarted::class, + 'VEEAM-MIB::onLinuxFLRCopyToFinished' => \LibreNMS\Snmptrap\Handlers\VeeamLinuxFLRCopyToFinished::class, + 'VEEAM-MIB::onLinuxFLRToOriginalFinished' => \LibreNMS\Snmptrap\Handlers\VeeamLinuxFLRToOriginalFinished::class, + 'VEEAM-MIB::onWinFLRMountStarted' => \LibreNMS\Snmptrap\Handlers\VeeamWinFLRMountStarted::class, + 'VEEAM-MIB::onWinFLRToOriginalStarted' => \LibreNMS\Snmptrap\Handlers\VeeamWinFLRToOriginalStarted::class, + 'VEEAM-MIB::onWinFLRCopyToStarted' => \LibreNMS\Snmptrap\Handlers\VeeamWinFLRCopyToStarted::class, + 'VEEAM-MIB::onWinFLRToOriginalFinished' => \LibreNMS\Snmptrap\Handlers\VeeamWinFLRToOriginalFinished::class, + 'VEEAM-MIB::onWinFLRCopyToFinished' => \LibreNMS\Snmptrap\Handlers\VeeamWinFLRCopyToFinished::class, + 'VEEAM-MIB::onWebDownloadStart' => \LibreNMS\Snmptrap\Handlers\VeeamWebDownloadStart::class, + 'VEEAM-MIB::onWebDownloadFinished' => \LibreNMS\Snmptrap\Handlers\VeeamWebDownloadFinished::class, + 'VEEAM-MIB::onSobrOffloadFinished' => \LibreNMS\Snmptrap\Handlers\VeeamSobrOffloadFinished::class, + 'VEEAM-MIB::onCdpRpoReport' => \LibreNMS\Snmptrap\Handlers\VeeamCdpRpoReport::class, 'HP-ICF-FAULT-FINDER-MIB::hpicfFaultFinderTrap' => \LibreNMS\Snmptrap\Handlers\HpFault::class, 'UPS-MIB::upsTrapOnBattery' => \LibreNMS\Snmptrap\Handlers\UpsTrapOnBattery::class, ], diff --git a/tests/Feature/SnmpTraps/VeeamTrapTest.php b/tests/Feature/SnmpTraps/VeeamTrapTest.php index 965b21d44c..c040875cc0 100644 --- a/tests/Feature/SnmpTraps/VeeamTrapTest.php +++ b/tests/Feature/SnmpTraps/VeeamTrapTest.php @@ -9,7 +9,7 @@ use Log; class VeeamTrapTest extends SnmpTrapTestCase { - public function testVeeamOnBackupCompleted(): void + public function testVeeamBackupJobCompleted(): void { $device = Device::factory()->create(); @@ -20,18 +20,18 @@ SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onBackupJobCompleted VEEAM-MIB::backupJobId 7a1b3549-c4c7-4629-84d6-74e24fee8011 VEEAM-MIB::backupJobName SureBackup Job 1 VEEAM-MIB::sourceHostName hostname -VEEAM-MIB::vmBackupComment +VEEAM-MIB::backupJobComment comment VEEAM-MIB::backupJobResult Success"; $trap = new Trap($trapText); - $message = 'SNMP Trap: Backup Job success - SureBackup Job 1 '; + $message = 'SNMP Trap: Backup Job Success - SureBackup Job 1 - comment'; Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 1); $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); } - public function testVeeamOnBackupCompletedFails(): void + public function testVeeamBackupJobCompletedWarning(): void { $device = Device::factory()->create(); @@ -42,36 +42,102 @@ SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onBackupJobCompleted VEEAM-MIB::backupJobId 7a1b3549-c4c7-4629-84d6-74e24fee8011 VEEAM-MIB::backupJobName SureBackup Job 1 VEEAM-MIB::sourceHostName hostname -VEEAM-MIB::vmBackupComment -VEEAM-MIB::vmBackupResult Failed"; +VEEAM-MIB::backupJobComment comment +VEEAM-MIB::backupJobResult Warning"; $trap = new Trap($trapText); - $message = 'SNMP Trap: Backup Job failed - SureBackup Job 1 '; + $message = 'SNMP Trap: Backup Job Warning - SureBackup Job 1 - comment'; + Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 4); + + $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); + } + + public function testVeeamBackupJobCompletedFailed(): void + { + $device = Device::factory()->create(); + + $trapText = "$device->hostname +UDP: [$device->ip]:46024->[1.1.1.1]:162 +DISMAN-EVENT-MIB::sysUpTimeInstance 4:13:08:37.60 +SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onBackupJobCompleted +VEEAM-MIB::backupJobId 7a1b3549-c4c7-4629-84d6-74e24fee8011 +VEEAM-MIB::backupJobName SureBackup Job 1 +VEEAM-MIB::sourceHostName hostname +VEEAM-MIB::backupJobComment comment +VEEAM-MIB::backupJobResult Failed"; + + $trap = new Trap($trapText); + + $message = 'SNMP Trap: Backup Job Failed - SureBackup Job 1 - comment'; Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 5); $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); } - public function testVeeamOnVmBackupCompleted(): void + public function testVeeamVmBackupCompleted(): void { $device = Device::factory()->create(); $trapText = "$device->hostname UDP: [$device->ip]:46024->[1.1.1.1]:162 DISMAN-EVENT-MIB::sysUpTimeInstance 4:13:08:37.60 -SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onVmBackupJobCompleted +SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onVmBackupCompleted VEEAM-MIB::backupJobName Linux taeglich low VEEAM-MIB::vmName vmname1 VEEAM-MIB::sourceHostName hostname -VEEAM-MIB::vmBackupComment +VEEAM-MIB::vmBackupComment comment VEEAM-MIB::vmBackupResult Success"; $trap = new Trap($trapText); - $message = 'SNMP Trap: VM Backup success - Linux taeglich low vmname1'; + $message = 'SNMP Trap: VM backup Success - vmname1 Job: Linux taeglich low - comment'; Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 1); $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); } + + public function testVeeamVmBackupCompletedWarning(): void + { + $device = Device::factory()->create(); + + $trapText = "$device->hostname +UDP: [$device->ip]:46024->[1.1.1.1]:162 +DISMAN-EVENT-MIB::sysUpTimeInstance 4:13:08:37.60 +SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onVmBackupCompleted +VEEAM-MIB::backupJobName Linux taeglich low +VEEAM-MIB::vmName vmname1 +VEEAM-MIB::sourceHostName hostname +VEEAM-MIB::vmBackupComment comment +VEEAM-MIB::vmBackupResult Warning"; + + $trap = new Trap($trapText); + + $message = 'SNMP Trap: VM backup Warning - vmname1 Job: Linux taeglich low - comment'; + Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 4); + + $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); + } + + public function testVeeamVmBackupCompletedFailed(): void + { + $device = Device::factory()->create(); + + $trapText = "$device->hostname +UDP: [$device->ip]:46024->[1.1.1.1]:162 +DISMAN-EVENT-MIB::sysUpTimeInstance 4:13:08:37.60 +SNMPv2-MIB::snmpTrapOID.0 VEEAM-MIB::onVmBackupCompleted +VEEAM-MIB::backupJobName Linux taeglich low +VEEAM-MIB::vmName vmname1 +VEEAM-MIB::sourceHostName hostname +VEEAM-MIB::vmBackupComment comment +VEEAM-MIB::vmBackupResult Failed"; + + $trap = new Trap($trapText); + + $message = 'SNMP Trap: VM backup Failed - vmname1 Job: Linux taeglich low - comment'; + Log::shouldReceive('event')->once()->with($message, $device->device_id, 'backup', 5); + + $this->assertTrue(Dispatcher::handle($trap), 'Could not handle VEEAM-MIB::traps'); + } }