Migrating plugin to IcingaDB

How do I register a tabhook with the new interface? Is it even possible?

Is there a simple/example plugin for icingadbweb similar to the pnp module?

My plugin seems to show up in some legacy mode (via CompatObject). An attempt to read $object->service to get service name throws an exception: Uncaught Error: Call to undefined method Icinga\Module\Icingadb\Compat\CompatService::fetchService() in /usr/local/www/icingaweb2/modules/icingadb/library/Icingadb/Compat/CompatObject.php:269, although now there is $object->name. Is it intentional or a bug?

How do I register a tabhook with the new interface? Is it even possible?

Yes. By $this->provideHook('Icingadb/Tab') and a class in the usual place.

Is there a simple/example plugin for icingadbweb similar to the pnp module?

No. Not yet.

My plugin seems to show up in some legacy mode (via CompatObject).

Icinga DB Web currently doesn’t even support the legacy integration of Monitoring/ObjectDetailsTab hooks. So I don’t know how you got that error. Which hook are you actually using?

1 Like

Thanks!

What’s the recommended way to distinguish between Monitoring and Icinga DB from run.php, so that I can support both frontends?

The error comes from a Grapher hook in getPreviewHtml() when calling $object->service. Error stack begins as follows:

Uncaught Error: Call to undefined method Icinga\Module\Icingadb\Compat\CompatService::fetchService() in /usr/local/www/icingaweb2/modules/icingadb/library/Icingadb/Compat/CompatObject.php:269
Stack trace:
#0 /home/matlib/src/IcingaPerf/icingaweb2/modules/charts/library/Charts/ProvidedHook/Grapher.php(57): Icinga\Module\Icingadb\Compat\CompatService->__get('service')
#1 /usr/local/www/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/ObjectDetail.php(461): Icinga\Module\Charts\ProvidedHook\Grapher->getPreviewHtml(Object(Icinga\Module\Icingadb\Compat\CompatService))
#2 /usr/local/www/icingaweb2/modules/icingadb/library/Icingadb/Widget/Detail/ServiceDetail.php(35): Icinga\Module\Icingadb\Widget\Detail\ObjectDetail->createExtensions()
#3 /usr/local/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(295): Icinga\Module\Icingadb\Widget\Detail\ServiceDetail->assemble()
...

A Monitoring/Grapher hook! :bulb:

Okay, yes it’s a bug. But one you can easily circumvent by calling ->getName() instead of accessing ->service.

What’s the recommended way to distinguish between Monitoring and Icinga DB from run.php, so that I can support both frontends?

There’s no easy way of showing this, yet. But since you’re using the grapher hook, you could take a look at Icinga’s graphite module.

There you will find occurrences of this:

if (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) {

or:

if(! Module::exists('icingadb') || ! IcingadbSupport::useIcingaDbAsBackend()) {

In run.php or configuration.php for example.

2 Likes

Hi
Is there a migration guide availabel now? Or a guide how to develop icingadbweb modules?