From 25bcb6c30e036b9007eee85e16bd1ad0eefe11be Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Wed, 11 Jan 2023 13:02:17 +0100 Subject: [PATCH] Add object last state change time to issue description --- library/Jira/MonitoringInfo.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/Jira/MonitoringInfo.php b/library/Jira/MonitoringInfo.php index 4f3ef2e..82ce816 100644 --- a/library/Jira/MonitoringInfo.php +++ b/library/Jira/MonitoringInfo.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Jira; +use Icinga\Date\DateFormatter; use Icinga\Exception\IcingaException; use Icinga\Module\Icingadb\Model\CustomvarFlat; use Icinga\Module\Monitoring\Object\Host; @@ -121,6 +122,15 @@ public function getStateName() return strtoupper($this->object->state->getStateText()); } + public function getLastStateChange() + { + if ($this->object instanceof MonitoredObject) { + return DateFormatter::formatDateTime($this->object->last_state_change); + } + + return DateFormatter::formatDateTime($this->object->state->last_state_change); + } + public function getOutput() { if ($this->object instanceof MonitoredObject) { @@ -199,6 +209,8 @@ public function getDescriptionHeader() $description = ''; } + $description .= sprintf("Last state change: %s\n", $this->getLastStateChange()); + $hostLink = $this->object instanceof MonitoredObject ? LinkHelper::linkToIcingaHost($this->getHostname()) : LinkHelper::linkToIcingadbHost($this->getHostname());