diff --git a/application/controllers/GraphController.php b/application/controllers/GraphController.php index 986d2c1..b81b2bf 100644 --- a/application/controllers/GraphController.php +++ b/application/controllers/GraphController.php @@ -7,14 +7,13 @@ use Icinga\Exception\Http\HttpBadRequestException; use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Module\Graphite\Graphing\GraphingTrait; use Icinga\Module\Graphite\ProvidedHook\Icingadb\IcingadbSupport; +use Icinga\Module\Graphite\Util\IcingadbUtils; use Icinga\Module\Graphite\Web\Controller\MonitoringAwareController; use Icinga\Module\Graphite\Web\Widget\Graphs; -use Icinga\Module\Icingadb\Common\Auth; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\MonitoredObject; use Icinga\Module\Monitoring\Object\Service; use Icinga\Web\UrlParams; -use Icinga\Module\Icingadb\Common\Database; use Icinga\Module\Icingadb\Model\Service as IcingadbService; use Icinga\Module\Icingadb\Model\Host as IcingadbHost; use ipl\Orm\Model; @@ -23,8 +22,6 @@ use ipl\Stdlib\Filter; class GraphController extends MonitoringAwareController { use GraphingTrait; - use Database; - use Auth; /** * The URL parameters for the graph @@ -121,15 +118,15 @@ class GraphController extends MonitoringAwareController { $hostName = $this->filterParams->getRequired('host.name'); $serviceName = $this->filterParams->getRequired('service.name'); - - $query = IcingadbService::on($this->getDb())->with(['state', 'host']); + $icingadbUtils = IcingadbUtils::getInstance(); + $query = IcingadbService::on($icingadbUtils->getDb())->with(['state', 'host']); $query->filter(Filter::all( Filter::equal('service.name', $serviceName), Filter::equal('service.host.name', $hostName) )); - $this->applyRestrictions($query); + $icingadbUtils->applyRestrictions($query); /** @var IcingadbService $service */ $service = $query->first(); @@ -150,11 +147,11 @@ class GraphController extends MonitoringAwareController private function icingadbHost() { $hostName = $this->filterParams->getRequired('host.name'); - - $query = IcingadbHost::on($this->getDb())->with(['state']); + $icingadbUtils = IcingadbUtils::getInstance(); + $query = IcingadbHost::on($icingadbUtils->getDb())->with(['state']); $query->filter(Filter::equal('host.name', $hostName)); - $this->applyRestrictions($query); + $icingadbUtils->applyRestrictions($query); /** @var IcingadbHost $host */ $host = $query->first(); diff --git a/library/Graphite/Graphing/MetricsQuery.php b/library/Graphite/Graphing/MetricsQuery.php index 1b807ce..b14e9f5 100644 --- a/library/Graphite/Graphing/MetricsQuery.php +++ b/library/Graphite/Graphing/MetricsQuery.php @@ -8,9 +8,9 @@ use Icinga\Data\Filterable; use Icinga\Data\Queryable; use Icinga\Exception\NotImplementedError; use Icinga\Module\Graphite\GraphiteUtil; +use Icinga\Module\Graphite\Util\IcingadbUtils; use Icinga\Module\Graphite\Util\MacroTemplate; use Icinga\Module\Graphite\Util\InternalProcessTracker as IPT; -use Icinga\Module\Icingadb\Common\Macros; use Icinga\Module\Icingadb\Compat\UrlMigrator; use Icinga\Module\Icingadb\Model\Host; use Icinga\Module\Monitoring\Object\Macro; @@ -26,8 +26,6 @@ use ipl\Stdlib\Filter as IplFilter; */ class MetricsQuery implements Queryable, Filterable, Fetchable { - use Macros; - /** * @var MetricsDataSource */ @@ -155,7 +153,8 @@ class MetricsQuery implements Queryable, Filterable, Fetchable $workaroundMacro = $migratedMacro; } - $result = $this->resolveMacro($workaroundMacro, $this->object); + $icingadbMacros = IcingadbUtils::getInstance(); + $result = $icingadbMacros->resolveMacro($workaroundMacro, $this->object); } else { if ($workaroundMacro === 'service_name') { $workaroundMacro = 'service_description'; diff --git a/library/Graphite/Util/IcingadbUtils.php b/library/Graphite/Util/IcingadbUtils.php new file mode 100644 index 0000000..43334e5 --- /dev/null +++ b/library/Graphite/Util/IcingadbUtils.php @@ -0,0 +1,49 @@ +