From b3bcd87320278a5819f1173b18dca3c064a58a73 Mon Sep 17 00:00:00 2001 From: burnziii Date: Fri, 30 Jan 2026 16:07:21 +0100 Subject: [PATCH] Add Dell Networker (EMC vProxy) and Cohesity Backup support - Add DellNetworker.php: Parses 'Last EMC vProxy Backup' custom attribute Format: Backup Server=x, Policy=x, Workflow=x, Action=x, JobId=x, StartTime=x, EndTime=x - Add CohesityBackup.php: Parses Cohesity custom attributes - 'Last Cohesity Backup Attempt Time' (format: YYYY/MM/DD-HH:MM:SS-GMT+XXXX) - 'Last Cohesity Backup Status' - Extend SimpleBackupTool with generic getInfoRenderer() method Eliminates need for separate *RunDetails.php widgets for simple backup tools - Register new backup tools in BackupToolInfo and CustomValueDetails Closes #552 Co-Authored-By: Claude Opus 4.5 --- library/Vspheredb/Addon/CohesityBackup.php | 43 ++++++++++++++++ library/Vspheredb/Addon/DellNetworker.php | 49 +++++++++++++++++++ library/Vspheredb/Addon/SimpleBackupTool.php | 28 +++++++++++ .../Web/Widget/CustomValueDetails.php | 4 ++ .../Web/Widget/Vm/BackupToolInfo.php | 4 ++ 5 files changed, 128 insertions(+) create mode 100644 library/Vspheredb/Addon/CohesityBackup.php create mode 100644 library/Vspheredb/Addon/DellNetworker.php diff --git a/library/Vspheredb/Addon/CohesityBackup.php b/library/Vspheredb/Addon/CohesityBackup.php new file mode 100644 index 00000000..ba91c70b --- /dev/null +++ b/library/Vspheredb/Addon/CohesityBackup.php @@ -0,0 +1,43 @@ +has(self::CV_BACKUP_TIME)) { + $timeStr = $values->get(self::CV_BACKUP_TIME); + // Format: 2026/01/30-15:10:26-GMT+0100 + $normalized = preg_replace( + '/^(\d{4})\/(\d{2})\/(\d{2})-(\d{2}:\d{2}:\d{2})-GMT([+-]\d{4})$/', + '$1-$2-$3 $4 $5', + $timeStr + ); + $attributes['Time'] = strtotime($normalized); + } + + if ($values->has(self::CV_BACKUP_STATUS)) { + $attributes['Status'] = $values->get(self::CV_BACKUP_STATUS); + } + + $this->lastAttributes = $attributes; + } +} diff --git a/library/Vspheredb/Addon/DellNetworker.php b/library/Vspheredb/Addon/DellNetworker.php new file mode 100644 index 00000000..1f9e6e44 --- /dev/null +++ b/library/Vspheredb/Addon/DellNetworker.php @@ -0,0 +1,49 @@ +has(self::CV_LAST_BACKUP)) { + return; + } + + $string = $values->get(self::CV_LAST_BACKUP); + $attributes = []; + + // Format: Backup Server=backup01.local, Policy=RZ, Workflow=vm_day_backup, ... + foreach (preg_split('/,\s*/', $string) as $part) { + if (preg_match('/^([^=]+)=(.*)$/', trim($part), $m)) { + $key = trim($m[1]); + $value = trim($m[2]); + + if (in_array($key, ['StartTime', 'EndTime'])) { + $attributes[$key] = strtotime($value); + } else { + $attributes[$key] = $value; + } + } + } + + if (isset($attributes['EndTime'])) { + $attributes['Time'] = $attributes['EndTime']; + } + + $this->lastAttributes = $attributes; + } +} diff --git a/library/Vspheredb/Addon/SimpleBackupTool.php b/library/Vspheredb/Addon/SimpleBackupTool.php index d5fc39e1..9032de9a 100644 --- a/library/Vspheredb/Addon/SimpleBackupTool.php +++ b/library/Vspheredb/Addon/SimpleBackupTool.php @@ -2,6 +2,8 @@ namespace Icinga\Module\Vspheredb\Addon; +use gipfl\IcingaWeb2\Widget\NameValueTable; +use Icinga\Date\DateFormatter; use Icinga\Module\Vspheredb\DbObject\CustomValues; use Icinga\Module\Vspheredb\DbObject\VirtualMachine; use RuntimeException; @@ -152,4 +154,30 @@ public function removeCustomValues(CustomValues $values) $values->remove($name); } } + + /** + * Returns a generic info renderer for backup tools. + * Override this method for custom rendering. + * + * @return NameValueTable|null + */ + public function getInfoRenderer() + { + $attributes = $this->getAttributes(); + + if ($attributes === null) { + return null; + } + + $table = new NameValueTable(); + + foreach ($attributes as $key => $value) { + if (is_int($value) && preg_match('/time/i', $key)) { + $value = DateFormatter::formatDateTime($value); + } + $table->addNameValueRow($key, $value); + } + + return $table; + } } diff --git a/library/Vspheredb/Web/Widget/CustomValueDetails.php b/library/Vspheredb/Web/Widget/CustomValueDetails.php index 7d8da5e9..af382279 100644 --- a/library/Vspheredb/Web/Widget/CustomValueDetails.php +++ b/library/Vspheredb/Web/Widget/CustomValueDetails.php @@ -4,6 +4,8 @@ use gipfl\Translation\TranslationHelper; use gipfl\Web\Table\NameValueTable; +use Icinga\Module\Vspheredb\Addon\CohesityBackup; +use Icinga\Module\Vspheredb\Addon\DellNetworker; use Icinga\Module\Vspheredb\Addon\IbmSpectrumProtect; use Icinga\Module\Vspheredb\Addon\SimpleBackupTool; use Icinga\Module\Vspheredb\Addon\NetBackup; @@ -59,6 +61,8 @@ protected function assemble() protected function stripBackupToolCustomValues(CustomValues $values) { $tools = [ + new CohesityBackup(), + new DellNetworker(), new IbmSpectrumProtect(), new NetBackup(), new VRangerBackup(), diff --git a/library/Vspheredb/Web/Widget/Vm/BackupToolInfo.php b/library/Vspheredb/Web/Widget/Vm/BackupToolInfo.php index 337bb805..9115b698 100644 --- a/library/Vspheredb/Web/Widget/Vm/BackupToolInfo.php +++ b/library/Vspheredb/Web/Widget/Vm/BackupToolInfo.php @@ -4,6 +4,8 @@ use gipfl\Translation\TranslationHelper; use Icinga\Module\Vspheredb\Addon\BackupTool; +use Icinga\Module\Vspheredb\Addon\CohesityBackup; +use Icinga\Module\Vspheredb\Addon\DellNetworker; use Icinga\Module\Vspheredb\Addon\IbmSpectrumProtect; use Icinga\Module\Vspheredb\Addon\NetBackup; use Icinga\Module\Vspheredb\Addon\VeeamBackup; @@ -55,6 +57,8 @@ protected function assemble() protected function getBackupTools() { return [ + new CohesityBackup(), + new DellNetworker(), new IbmSpectrumProtect(), new NetBackup(), new VeeamBackup(),