Icinga / icingaweb2-module-businessprocess

Create top-level views of your applications in a graphical editor. Rules express dependencies between existing hosts and services and let you alert on application level. Business processes are displayed in a tree or list overview.
https://icinga.com/docs/businessprocess/latest
GNU General Public License v2.0
108 stars 44 forks source link

Issue with IcingaDB #373

Closed alamp1360 closed 1 year ago

alamp1360 commented 1 year ago

The BusinessProzess Module displays an error: Could not retrieve process state: Object of class DateTime could not be converted to number when using the module in combination with IcingaDB.

After some debugging i found the issue: In file library/BusinessProcess/State/IcingaDbState.php on line 125 there is a division:

    if ($row->state->last_state_change !== null) {
        $node->setLastStateChange($row->state->last_state_change/1000);
    }

But since that last_state_change is a DateTime Object, this cannot be done.

I fixed at least the error by adding a "->getTimeStamp()" at the end:

    if ($row->state->last_state_change !== null) {
        $node->setLastStateChange($row->state->last_state_change->getTimeStamp());
    }

I am not sure about the "/1000". I guess the the code expects some timestamp in milliseconds. But since getTimeStamp() returns seconds, i think it is safe to remove the /1000 as well...

Hope this helps...