Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grafana module | make PHP 8.2 compatible #332

Open
Danrockan opened this issue Jan 21, 2024 · 6 comments
Open

grafana module | make PHP 8.2 compatible #332

Danrockan opened this issue Jan 21, 2024 · 6 comments

Comments

@Danrockan
Copy link

hello, when im enable graphana modole i have bellow errors in: /icingaweb2/dashboard#!/icingaweb2/icingadb/host?name=

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$permission is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
75

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$dashboard is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
222

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$dashboarduid is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
223

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$panelId is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
228

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$orgId is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
229

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$customVars is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
230

Deprecated
: Creation of dynamic property Icinga\Module\Grafana\ProvidedHook\Icingadb\HostDetailExtension::$pngUrl is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
275

lsb_release -a

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

head -n 2 /etc/icingaweb2/enabledModules/*/module.info

==> /etc/icingaweb2/enabledModules/businessprocess/module.info <==
Name: Businessprocess
Version: 2.5.0

==> /etc/icingaweb2/enabledModules/director/module.info <==
Name: Icinga Director
Version: 1.11.0

==> /etc/icingaweb2/enabledModules/doc/module.info <==
Module: doc
Version: 2.12.1

==> /etc/icingaweb2/enabledModules/elasticsearch/module.info <==
Module: elasticsearch
Version: 1.0.0

==> /etc/icingaweb2/enabledModules/fileshipper/module.info <==
Name: Fileshipper
Version: 1.2.0

==> /etc/icingaweb2/enabledModules/grafana/module.info <==
Name: Grafana
Version: 2.0.3

==> /etc/icingaweb2/enabledModules/icingadb/module.info <==
Module: icingadb
Version: 1.1.1

==> /etc/icingaweb2/enabledModules/incubator/module.info <==
Name: Incubator
Version: 0.20.0

==> /etc/icingaweb2/enabledModules/migrate/module.info <==
Module: migrate
Version: 2.12.1

icingacli module list

MODULE         VERSION   STATE     DESCRIPTION
director       1.11.0    enabled   Director - Config tool for Icinga 2
doc            2.12.1    enabled   Documentation module
incubator      0.20.0    enabled   Incubator provides bleeding-edge libraries
migrate        2.12.1    enabled   Migrate module
monitoring     2.12.1    enabled   Icinga monitoring module

dpkg-query -l icinga php | grep ^ii

ii  icinga-director              1.11.0-1+debian12                       all          Configuration automation and deployment tool in the Icinga ecosystem
ii  icinga-director-daemon       1.11.0-1+debian12                       all          Icinga Director Daemon files
ii  icinga-director-php          1.11.0-1+debian12                       all          Icinga Director PHP files
ii  icinga-director-web          1.11.0-1+debian12                       all          Icinga Director Web files
ii  icinga-l10n                  1.3.0-1+debian12                        all          Icinga localization
ii  icinga-php-incubator         0.20.0-1+debian12                       all          Icinga PHP Incubator Libraries
ii  icinga-php-library           0.13.1-1+debian12                       all          Icinga PHP Library - IPL
ii  icinga-php-thirdparty        0.12.1-1+debian12                       all          Icinga 3rd party PHP libraries
ii  icinga2                      2.14.2-1+debian12                       amd64        host and network monitoring system
ii  icinga2-bin                  2.14.2-1+debian12                       amd64        host and network monitoring system - daemon
ii  icinga2-common               2.14.2-1+debian12                       all          host and network monitoring system - common files
ii  icinga2-doc                  2.14.2-1+debian12                       all          host and network monitoring system - documentation
ii  icingacli                    2.12.1-1+debian12                       all          Icinga CLI
ii  icingadb                     1.1.1-1+debian12                        amd64        Icinga configuration and state database supporting multiple environments
ii  icingadb-redis               7.0.12-1+debian12                       all          Persistent key-value database with network interface (metapackage)
ii  icingadb-redis-server        7.0.12-1+debian12                       amd64        Persistent key-value database with network interface
ii  icingadb-redis-tools         7.0.12-1+debian12                       amd64        Persistent key-value database with network interface (client)
ii  icingadb-web                 1.1.1-1+debian12                        all          Icinga DB Web
ii  icingaweb2                   2.12.1-1+debian12                       all          Icinga Web
ii  icingaweb2-common            2.12.1-1+debian12                       all          Common files for Icinga Web and the Icinga CLI
ii  libapache2-mod-php8.2        8.2.7-1~deb12u1                         amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php                          2:8.2+93                                all          server-side, HTML-embedded scripting language (default)
ii  php-common                   2:93                                    all          Common files for PHP packages
ii  php-curl                     2:8.2+93                                all          CURL module for PHP [default]
ii  php-gd                       2:8.2+93                                all          GD module for PHP [default]
ii  php-icinga                   2.12.1-1+debian12                       all          Icinga Web PHP library
ii  php-intl                     2:8.2+93                                all          Internationalisation module for PHP [default]
ii  php-ldap                     2:8.2+93                                all          LDAP module for PHP [default]
ii  php-mbstring                 2:8.2+93                                all          MBSTRING module for PHP [default]
ii  php-mysql                    2:8.2+93                                all          MySQL module for PHP [default]
ii  php-pear                     1:1.10.13+submodules+notgz+2022032202-2 all          PEAR Base System
ii  php-pgsql                    2:8.2+93                                all          PostgreSQL module for PHP [default]
ii  php-php-gettext              1.0.12-5                                all          read gettext MO files directly, without requiring anything other than PHP
ii  php-soap                     2:8.2+93                                all          SOAP module for PHP [default]
ii  php-xml                      2:8.2+93                                all          DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]
ii  php8.2                       8.2.7-1~deb12u1                         all          server-side, HTML-embedded scripting language (metapackage)
ii  php8.2-cli                   8.2.7-1~deb12u1                         amd64        command-line interpreter for the PHP scripting language
ii  php8.2-common                8.2.7-1~deb12u1                         amd64        documentation, examples and common module for PHP
ii  php8.2-curl                  8.2.7-1~deb12u1                         amd64        CURL module for PHP
ii  php8.2-gd                    8.2.7-1~deb12u1                         amd64        GD module for PHP
ii  php8.2-intl                  8.2.7-1~deb12u1                         amd64        Internationalisation module for PHP
ii  php8.2-ldap                  8.2.7-1~deb12u1                         amd64        LDAP module for PHP
ii  php8.2-mbstring              8.2.7-1~deb12u1                         amd64        MBSTRING module for PHP
ii  php8.2-mysql                 8.2.7-1~deb12u1                         amd64        MySQL module for PHP
ii  php8.2-opcache               8.2.7-1~deb12u1                         amd64        Zend OpCache module for PHP
ii  php8.2-pgsql                 8.2.7-1~deb12u1                         amd64        PostgreSQL module for PHP
ii  php8.2-readline              8.2.7-1~deb12u1                         amd64        readline module for PHP
ii  php8.2-soap                  8.2.7-1~deb12u1                         amd64        SOAP module for PHP
ii  php8.2-xml                   8.2.7-1~deb12u1                         amd64        DOM, SimpleXML, XML, and XSL module for PHP

@gbin2265
Copy link

Hello,

can you also do this for php 8.3?

regards,
Geert

@mvahani
Copy link

mvahani commented Feb 2, 2024

I have solved it in 1.4.2 but I guess it's the same solution in the latest version as well. It's a pretty simple one. Here are the patches I'm using on my master servers.

I guess the first one is already solved in later versions of the grafana module. But for 1.4.2 it is needed.

--- /usr/share/icingaweb2/modules/grafana/library/Grafana/Helpers/Timeranges.php.orig	2024-02-01 17:09:46.976830967 +0000
+++ /usr/share/icingaweb2/modules/grafana/library/Grafana/Helpers/Timeranges.php	2024-02-01 17:10:54.218580572 +0000
@@ -92,7 +92,7 @@
     private function buildTimerangeMenu($timerange = "", $timerangeto = "")
     {
         $clockIcon = $this->view->qlink('', 'dashboard/new-dashlet',
-            ['url' => 'grafana/dashboard?' . http_build_query($this->urlparams, null, '&', PHP_QUERY_RFC3986)],
+            ['url' => 'grafana/dashboard?' . http_build_query($this->urlparams, '', '&', PHP_QUERY_RFC3986)],
             ['icon' => 'clock', 'title' => 'Add graph to dashboard']);

         $menu = '<table class="grafana-table"><tr>';


--- /usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Grapher.php.orig	2024-02-01 17:06:22.991519674 +0000
+++ /usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Grapher.php	2024-02-01 17:08:03.964150996 +0000
@@ -55,6 +55,13 @@
     protected $cacheTime = 300;
     protected $grafanaVersion = "0";
     protected $defaultdashboarduid;
+    protected $permission;
+    protected $object;
+    protected $dashboard;
+    protected $dashboarduid;
+    protected $panelId;
+    protected $orgId;
+    protected $customVars;

     protected function init()
     {

@gbin2265
Copy link

gbin2265 commented Feb 2, 2024

Hello,

based on what @mvahani gave as information, I only added these lines in the file IcingaDbGrapher.php

diff --git a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php

--- a/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
+++ b/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
@@ -68,6 +68,12 @@ trait IcingaDbGrapher

     protected $grafanaVersion = "0";
     protected $defaultdashboarduid;
     protected $object;
+    protected $permission;
+    protected $dashboard;
+    protected $dashboarduid;
+    protected $panelId;
+    protected $orgId;
+    protected $customVars;

Now I have no more errors in icingadb-web in combination with php 8.3

I also add these 2 cases for the iframe provided by @dnsmichi as a pull request:
#318
#328

As a result, I now have the link "see in grafana" above the graph
see_in_grafana

See here all the modification I made
iframe_and_php83.txt

@simon-sebold
Copy link

Thank you. This worked for me

@tectumopticum
Copy link

same issue with PHP 8.1(.28)
Deprecated
: substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated in
/usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Icingadb/IcingaDbGrapher.php
on line
403

@holehner
Copy link

holehner commented Oct 7, 2024

Hello, i have the same Problem with PHP8.2
In my case, I also had to add protected $pngUrl;.

so that the error messages were gone.
However, I still have the problem that only the mini icon is displayed and no graph.
I have already re-downloaded the module and tested it again, but without success. I am using PHP8.2. Do you have any ideas? I have been testing for several days.
The Grafana/Influxdb connection works. When I copy the generated Debug link for iFrame into the browser, I get the graphic. But not within the Icinga plugin or with Indirect Proxy.

Thank you, Heiko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants