Skip to content

Commit

Permalink
Add object last state change time to issue description
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Feb 23, 2023
1 parent 5955dc0 commit 25bcb6c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/Jira/MonitoringInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 25bcb6c

Please sign in to comment.