Issue with repeating disk graphs in icinga2-module-grafana

Hi guys. I having some problems to configure the disk graphs repeating in the Icinga2 grafana module. The issue is that only one graphs is showed, and I think I have detected the “bug”.

In the file: /usr/share/icingaweb2/modules/grafana/library/Grafana/ProvidedHook/Grapher.php

I found this piece of code:

if ($this->repeatable == "yes") {
            $this->panelId = implode(',', range($this->panelId,
                ($this->panelId - 1) + intval(substr_count($object->perfdata, '=') / $this->numberMetrics)));

Well, the problem is that $object->perfdata is supposed to return the perfdata output, to know the number of disks checked by this service, and this way it can calculate the number of graphs to show. But $object->perfdata is returning “1” (I think that it means “Perfdata enabled”) but not the perfdata output string as expected.

And here is my question: is there any way to get the perfdata output string? I have readed the doc and I can’t find a way to do it. Thanks in advance.

  • Icinga Web 2 version 2.11.4

  • Loaded Modules
    director 1.10.2
    fileshipper 1.2.0
    grafana 1.4.3
    icingadb 1.0.2
    incubator 0.20.0

  • Web browser used (Chrome, Firefox and Edge)

  • Icinga 2 version used r2.13.6-1

  • PHP version used 7.4.33

  • Server operating system and version Debian 11 bullseye

Come on guys, nobody is able to tell how to get a service performance data output string within a icingaweb2 module?

I think there is a bug in the CompatService CompatHost used if there is no IcingaDb implementation:

here is a my workarround:

use Icinga\Module\Monitoring\Plugin\PerfdataSet;

        if(get_class($object) ==="Icinga\Module\Icingadb\Compat\CompatService" || get_class($object) ==="Icinga\Module\Icingadb\Compat\CompatHost") {
            $p= PerfdataSet::fromString($object->state->performance_data)->asArray();
            $isIcingaDB = true;
            $p= PerfdataSet::fromString($object->perfdata)->asArray();
            $isIcingaDB = false;

or just

if(get_class($object) ==="Icinga\Module\Icingadb\Compat\CompatService" || get_class($object) ==="Icinga\Module\Icingadb\Compat\CompatHost") {
      $perfdata = $object->state->performance_data;
      $isIcingaDB = true;
      $perfdata = $object->perfdata;
      $isIcingaDB = false;
1 Like

Thanks for you workaround mate!

Mine is a little bit more complex cos I don’t know how to manage icinga2 classes, so I have created a new class on module grafana. This new class in a client that make a call to Icinga2 API and it get the performance_data. Yep, I know, your solution is more elegant, so I will implement it asap.

1 Like

This is actually a bug in Icinga DB Web. Here’s the fix: Fix that repeated grafana graphs are not shown properly by nilmerg · Pull Request #720 · Icinga/icingadb-web · GitHub

1 Like

Thanks for the notice, Johannes!