Custom module

Hi everyone,

I am trying to create a custom module . What I want to do is really simple however I couldn’t make it .
There are not good tutorials and examples on the internet.

I want to see 2 buttons after clicking a service to see service details . Under the graph would be great .

I am not using monitoring module I use Icingadbweb instead .
Can anyone lead me ?

for that you either need the ServiceActionHook in you module

here an example:
https://github.com/nbuchwitz/icingaweb2-module-map/blob/master/library/Map/ProvidedHook/Icingadb/ServiceActions.php

if you want just an url for the button / link you can use icinga navigation feature

https://your-icinga/icingaweb2/navigation/add

  • select service action

There is the training web module that was made to help get started with module development.
It’s a bit dated and on the list of things we want to work on and improve, but maybe that would be a good place to start learning the basics? :slight_smile:
For me it was also really helpful to look at different modules and how they do what they do to kind of reverse engineer how to build a module that does what you want it to do :slight_smile:

Thanks Moreamazingnick !

I tried ServiceActionsHook , it works.

However , I wanted to add new section in service details .
I saw some examples of people who use monitoring module and DetailviewExtensionHook .

I am not using monitoring module .

This is the script I wrote just for testing . It does not create a new section .

Tbh, I just want to create a new section and put 2 buttons there . When I click buttons I want to send a cURL, that is all . It sounds easy but I spend a few days and I am still stuck at the beginning.

<?php
namespace Icinga\Module\Ssc;

use Icinga\Module\Icingadb\Hook\ServiceDetailExtensionHook;
use Icinga\Module\Icingadb\Model\Service;
use ipl\Html\ValidHtml;

class Ssc extends ServiceDetailExtensionHook
{
    public function getHtmlForObject(Service $service): ValidHtml
    {
        $htmlContent = '<div class="my-custom-section">';
        $htmlContent .= '<h2>My Custom Section</h2>';
        $htmlContent .= '<p>This is my custom content.</p>';
        $htmlContent .= '</div>';

        return $htmlContent;
    }
}

please put the whole thing on github, otherwise it’s hard to debug

Hi moreamazingnick,

To be honest I don’t have any other scripts now . My aim is creating a new section in service details and putting 2 buttons there. And I want to send cURL requests to run a command on hosts after clicking these buttons . I am still stuck , I feel like it would have been a lot easier If I have used monitoring module instead icingadbweb.

without any other file there is not loading of that file in place.
here an example from the grafana module by Mikesch-mp that created DetailExtensions:

https://github.com/Mikesch-mp/icingaweb2-module-grafana/blob/master/run.php

https://github.com/Mikesch-mp/icingaweb2-module-grafana/blob/master/library/Grafana/ProvidedHook/Icingadb/HostDetailExtension.php

https://github.com/Mikesch-mp/icingaweb2-module-grafana/blob/master/library/Grafana/ProvidedHook/Icingadb/ServiceDetailExtension.php