Skip to content

Commit 5fa3598

Browse files
committed
SnapshotsRuleDefinition: show oldest snapshot name
fixes #519
1 parent 01065c1 commit 5fa3598

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

library/Vspheredb/Monitoring/Rule/Definition/SnapshotsRuleDefinition.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ public function checkObject(BaseDbObject $object, Settings $settings): array
6464
if ($min && $info->ts_oldest < (time() - $min * 86400)) {
6565
$state->raiseState(CheckPluginState::CRITICAL);
6666
}
67-
$output = sprintf('%d snapshot(s), oldest one from %s', $count, date('Y-m-d H:i', $info->ts_oldest));
67+
$name = $db->fetchOne(
68+
$db->select()->from('vm_snapshot', 'name')
69+
->where('vm_snapshot.vm_uuid = ?', $object->getConnection()->quoteBinary($object->get('uuid')))
70+
->where('FLOOR(ts_create / 1000) = ?', $info->ts_oldest)
71+
);
72+
$output = sprintf(
73+
'%d snapshot(s), oldest one%s from %s',
74+
$count,
75+
is_string($name) && strlen($name) > 0 ? " ($name)" : '',
76+
date('Y-m-d H:i', $info->ts_oldest)
77+
);
6878
}
6979
return [
7080
new SingleCheckResult($state, $output)

0 commit comments

Comments
 (0)