Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions library/Vspheredb/Addon/CohesityBackup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Icinga\Module\Vspheredb\Addon;

use Icinga\Module\Vspheredb\DbObject\CustomValues;

class CohesityBackup extends SimpleBackupTool
{
public const CV_BACKUP_TIME = 'Last Cohesity Backup Attempt Time';
public const CV_BACKUP_STATUS = 'Last Cohesity Backup Status';

protected $customValues = [
self::CV_BACKUP_TIME,
self::CV_BACKUP_STATUS,
];

public function getName()
{
return 'Cohesity Backup';
}

protected function parseCustomValues(CustomValues $values)
{
$attributes = [];

if ($values->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;
}
}
49 changes: 49 additions & 0 deletions library/Vspheredb/Addon/DellNetworker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Icinga\Module\Vspheredb\Addon;

use Icinga\Module\Vspheredb\DbObject\CustomValues;

class DellNetworker extends SimpleBackupTool
{
public const CV_LAST_BACKUP = 'Last EMC vProxy Backup';

protected $customValues = [
self::CV_LAST_BACKUP,
];

public function getName()
{
return 'Dell Networker (EMC vProxy)';
}

protected function parseCustomValues(CustomValues $values)
{
if (!$values->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;
}
}
28 changes: 28 additions & 0 deletions library/Vspheredb/Addon/SimpleBackupTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
4 changes: 4 additions & 0 deletions library/Vspheredb/Web/Widget/CustomValueDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +61,8 @@ protected function assemble()
protected function stripBackupToolCustomValues(CustomValues $values)
{
$tools = [
new CohesityBackup(),
new DellNetworker(),
new IbmSpectrumProtect(),
new NetBackup(),
new VRangerBackup(),
Expand Down
4 changes: 4 additions & 0 deletions library/Vspheredb/Web/Widget/Vm/BackupToolInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,6 +57,8 @@ protected function assemble()
protected function getBackupTools()
{
return [
new CohesityBackup(),
new DellNetworker(),
new IbmSpectrumProtect(),
new NetBackup(),
new VeeamBackup(),
Expand Down