getDb())->columns('heartbeat')->first(); if ($instance === null) { $this->setState(self::STATE_UNKNOWN); $this->setMessage(t( 'Can\'t check Redis: Icinga DB is not running or not writing into the database' . ' (make sure the icinga feature "icingadb" is enabled)' )); return; } $outdatedDbHeartbeat = $instance->heartbeat->getTimestamp() < time() - 60; if (! $outdatedDbHeartbeat || $instance->heartbeat->getTimestamp() <= $lastIcingaHeartbeat) { $this->setState(self::STATE_OK); $this->setMessage(t('Redis available and up to date.')); } elseif ($instance->heartbeat->getTimestamp() > $lastIcingaHeartbeat) { $this->setState(self::STATE_CRITICAL); $this->setMessage(t('Redis outdated. Make sure Icinga 2 is running and connected to Redis.')); } } catch (Exception $e) { $this->setState(self::STATE_CRITICAL); $this->setMessage(sprintf(t("Can't connect to Redis: %s"), $e->getMessage())); } } }