Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Missing Grafana host configuration results in Undefined property: Icinga\Module\Grafana\ProvidedHook\Grapher::$view #26

Closed
dnsmichi opened this issue Apr 20, 2017 · 5 comments · Fixed by #28
Labels

Comments

@dnsmichi
Copy link
Collaborator

The latest addition of the timerange qlink breaks Icinga Web 2.

  • CentOS7, SELinux is disabled
  • Module is just a git clone (master, v1.0.10) and enabled, no configuration applied yet
  • Icinga Web 2: icingaweb2-2.4.0-2.snapshot201704192326.el7.centos.noarch
Undefined property: Icinga\Module\Grafana\ProvidedHook\Grapher::$view

#0 /usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Grapher.php(142): Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(8, 'Undefined prope...', '/usr/share/icin...', 142, Array)
#1 /usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Grapher.php(249): Icinga\Module\Grafana\ProvidedHook\Grapher->getTimerangeLink(Object(Icinga\Module\Monitoring\Object\Service), '5 minutes', '5m')
#2 zend.view:///usr/share/icingaweb2/modules/monitoring/application/views/scripts/show/components/grapher.phtml(2): Icinga\Module\Grafana\ProvidedHook\Grapher->getPreviewHtml(Object(Icinga\Module\Monitoring\Object\Service))
#3 /usr/share/php/Icinga/Web/View.php(231): include('zend.view:///us...')
#4 /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php(877): Icinga\Web\View->_run('/usr/share/icin...')
#5 zend.view:///usr/share/icingaweb2/modules/monitoring/application/views/scripts/partials/object/detail-content.phtml(3): Zend_View_Abstract->render('show/components...')
#6 /usr/share/php/Icinga/Web/View.php(231): include('zend.view:///us...')
#7 /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php(877): Icinga\Web\View->_run('/usr/share/icin...')
#8 zend.view:///usr/share/icingaweb2/modules/monitoring/application/views/scripts/service/show.phtml(8): Zend_View_Abstract->render('partials/object...')
#9 /usr/share/php/Icinga/Web/View.php(231): include('zend.view:///us...')
#10 /usr/share/icingaweb2/library/vendor/Zend/View/Abstract.php(877): Icinga\Web\View->_run('/usr/share/icin...')
#11 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/Helper/ViewRenderer.php(904): Zend_View_Abstract->render('service/show.ph...')
#12 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/Helper/ViewRenderer.php(925): Zend_Controller_Action_Helper_ViewRenderer->renderScript('service/show.ph...', NULL)
#13 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/Helper/ViewRenderer.php(964): Zend_Controller_Action_Helper_ViewRenderer->render()
#14 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action/HelperBroker.php(272): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#15 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(518): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#16 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch('showAction')
#17 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#18 /usr/share/php/Icinga/Application/Web.php(389): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#19 /usr/share/php/Icinga/Application/webrouter.php(104): Icinga\Application\Web->dispatch()
#20 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...')
#21 {main}
@Mikesch-mp
Copy link
Owner

Please use the bugfix for bugfix release v1.0.11 :)

@dnsmichi
Copy link
Collaborator Author

Hm, it still exists unfortunately. I'm on

commit 5bc0637f752f0339270801b1a36e9cfb9d0244cf
Author: Carsten <[email protected]>
Date:   Thu Apr 20 20:46:43 2017 +0200

    Update README.md

I'm using the icinga2x Vagrant box which provides me with a running Graphite and Grafana. Cloned and enabled the module. Imported the Grafana dashboards (but this seems unrelated, since I did not configure the global settings yet).

Somehow $this->view does not exist in the scope where it is used (ProvidedHook vs Controller).

@Mikesch-mp
Copy link
Owner

Hmm maybe its the Icingaweb2 version. My icingaweb2 version is:

Installed Packages
Name : icingaweb2
Arch : noarch
Version : 2.4.1
Release : 1.el7.centos
Size : 5.7 M
Repo : installed
From repo : icinga-stable-release
Summary : Icinga Web 2
URL : https://icinga.com
License : GPLv2+ and MIT and BSD
Description : Icinga Web 2

PHP Version is 7.1.4

@Mikesch-mp
Copy link
Owner

Just downloaded icingaweb2 2.4.0 and it works also. Can you please configure the module and test it again.

@dnsmichi
Copy link
Collaborator Author

I'm not a web developer and I don't know the consequences, but $this->view->qlink is definitely used in a scope where $this->view is not initialized.

@@ -141,6 +139,8 @@ class Grapher extends GrapherHook
             $link = 'monitoring/service/show';
         }
 
+        $this->view = $this->getView();
+
         return $this->view->qlink(
                                 $rangeName,
                                 $link,

kills the exception, but looks like an ugly workaround with unknown behaviour afterwards. The graphs with Graphite do work then.

auswahl_120

I've also changed back to v2.4.1 stable, and then I've configured the Grafana data source. Voilá - it is a matter of having that properly configured. If the image fetcher cannot retrieve anything which could be rendered properly, that error is thrown.

I've found a way to reproduce it - just comment all the settings in config.ini.

;[grafana]
;username = "admin"
;password = "admin"
;host = "192.168.33.5:8004"
;protocol = "http"
;height = "280"
;width = "640"
;enableLink = "yes"
;defaultdashboard = "icinga2-default"
;defaultdashboardstore = "db"
;datasource = "graphite"

If enabled ;host = "192.168.33.5:8004" the renderer works again and attempts to fetch an image. So there's proper error handling missing somewhere inside the init() function, or the one which fetches an image.

    protected function init()
    {
        $this->config = Config::module('grafana')->getSection('grafana');
        $this->username = $this->config->get('username', $this->username);
        $this->grafanaHost = $this->config->get('host', $this->grafanaHost);
        if ( $this->grafanaHost == null)
        {
           return "<p>No Grafana host configured!</p>";
        }

Returning HTML in the init() function will do nothing, it won't even stop the caller. You must throw an exception. Then it works.

I'll send a PR soon.

@dnsmichi dnsmichi changed the title timerange qlink results in Undefined property: Icinga\Module\Grafana\ProvidedHook\Grapher::$view Missing Grafana host configuration results in Undefined property: Icinga\Module\Grafana\ProvidedHook\Grapher::$view Apr 20, 2017
@dnsmichi dnsmichi added the bug label Jun 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants