Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b2d8e4d03 | |||
| 7fb60a365e | |||
| fb3b607bd1 | |||
| dad7c24bff |
+21
-17
@@ -129,6 +129,21 @@ function generateTicketHash($data)
|
||||
|
||||
if (stripos($title, 'SMART issues') !== false) {
|
||||
$issueCategory = 'smart';
|
||||
} elseif (stripos($title, 'ZFS pool') !== false) {
|
||||
$issueCategory = 'zfs';
|
||||
// Extract pool name so each pool gets its own ticket
|
||||
if (preg_match("/ZFS pool '([^']+)'/i", $title, $poolMatch)) {
|
||||
$poolName = strtolower(preg_replace('/[^a-z0-9_]/i', '_', $poolMatch[1]));
|
||||
if (stripos($title, 'state:') !== false || preg_match('/DEGRADED|FAULTED|UNAVAIL|OFFLINE/i', $title)) {
|
||||
$issueSubtype = 'pool_state_' . $poolName;
|
||||
} elseif (stripos($title, 'usage') !== false) {
|
||||
$issueSubtype = 'pool_usage_' . $poolName;
|
||||
} elseif (stripos($title, 'errors') !== false) {
|
||||
$issueSubtype = 'pool_errors_' . $poolName;
|
||||
} else {
|
||||
$issueSubtype = 'pool_' . $poolName;
|
||||
}
|
||||
}
|
||||
} elseif (stripos($title, 'LXC') !== false || stripos($title, 'storage usage') !== false) {
|
||||
$issueCategory = 'storage';
|
||||
// Include the LXC container ID so each container gets its own ticket
|
||||
@@ -158,7 +173,7 @@ function generateTicketHash($data)
|
||||
$issueSubtype = 'clock_skew';
|
||||
} elseif (stripos($title, 'cluster usage') !== false) {
|
||||
$issueSubtype = 'usage';
|
||||
} elseif (stripos($title, 'OSD down') !== false || preg_match('/OSD\s+osd\.\d+\s+is\s+DOWN/i', $title)) {
|
||||
} elseif (stripos($title, 'OSD down') !== false || preg_match('/osd\.\d+\s+is\s+DOWN/i', $title)) {
|
||||
// Include the specific OSD ID so each individual OSD gets its own ticket
|
||||
if (preg_match('/osd\.(\d+)/i', $title, $osdMatch)) {
|
||||
$issueSubtype = 'osd_down_' . $osdMatch[1];
|
||||
@@ -228,8 +243,7 @@ if ($existing) {
|
||||
|
||||
if ($existingStatus !== 'Closed') {
|
||||
// Ticket is still active — update title, escalate priority, and refresh
|
||||
// the description with the latest sensor data if the new report is more severe
|
||||
// (lower priority number = higher severity).
|
||||
// description with latest sensor data.
|
||||
$changes = [];
|
||||
$updateSql = "UPDATE tickets SET updated_at = NOW(), updated_by = ?";
|
||||
$bindTypes = "i";
|
||||
@@ -267,20 +281,10 @@ if ($existing) {
|
||||
$updStmt->execute();
|
||||
$updStmt->close();
|
||||
|
||||
// Only add a comment when something meaningful changed (not just a description refresh)
|
||||
$meaningfulChanges = array_diff_key($changes, ['description_refreshed' => true]);
|
||||
if (!empty($meaningfulChanges)) {
|
||||
$changeLines = [];
|
||||
if (isset($changes['title'])) {
|
||||
$changeLines[] = "- **Title updated** to reflect current issue";
|
||||
}
|
||||
// Only post a comment on priority escalation — title and description updates
|
||||
// are silent (title changes like rising counters would spam a comment every run)
|
||||
if (isset($changes['priority'])) {
|
||||
$changeLines[] = "- **Priority escalated** from P{$changes['priority']['from']} to P{$changes['priority']['to']}";
|
||||
}
|
||||
// Wrap description in a fenced code block so ASCII art / box-drawing
|
||||
// characters render correctly instead of collapsing into a paragraph blob
|
||||
$commentText = "**hwmonDaemon reported a worsened condition — ticket updated automatically.**\n\n" .
|
||||
implode("\n", $changeLines) . "\n\nLatest report:\n\n```\n" . $description . "\n```";
|
||||
$commentText = "**hwmonDaemon escalated this ticket from P{$changes['priority']['from']} to P{$changes['priority']['to']}.**\n\n```\n" . $description . "\n```";
|
||||
$commentStmt = $conn->prepare(
|
||||
"INSERT INTO ticket_comments (ticket_id, user_id, user_name, comment_text, markdown_enabled) VALUES (?, ?, 'hwmonDaemon', ?, 1)"
|
||||
);
|
||||
@@ -290,7 +294,7 @@ if ($existing) {
|
||||
}
|
||||
|
||||
$auditLog->log($userId, 'update', 'ticket', $existingId, array_merge(
|
||||
$changes,
|
||||
array_diff_key($changes, ['description_refreshed' => true]),
|
||||
['reason' => 'auto-updated by hwmonDaemon (condition worsened)']
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user