# Custom module

**URL:** <https://community.icinga.com/t/custom-module/12777>\
**Category:** Icinga Web Modules\
**Tags:** icingaweb2, icinga2\
**Created:** [October 19, 2023, 9:31am UTC](https://community.icinga.com/t/custom-module/12777 "2023-10-19T09:31:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurhan](https://community.icinga.com/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gurhan](https://community.icinga.com/u/gurhan)\
**Post date:** [October 19, 2023, 9:31am UTC](https://community.icinga.com/t/custom-module/12777/1 "2023-10-19T09:31:16Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 19, 2023, 11:26am UTC](https://community.icinga.com/t/custom-module/12777/2 "2023-10-19T11:26:27Z")

</div>

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](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](https://your-icinga/icingaweb2/navigation/add)

- select service action

---

<div class="post-metadata">

**Author:** ![theFeu](https://community.icinga.com/user_avatar/community.icinga.com/thefeu/32/7277_2.png) [@theFeu](https://community.icinga.com/u/theFeu)\
**Post date:** [October 20, 2023, 8:32am UTC](https://community.icinga.com/t/custom-module/12777/3 "2023-10-20T08:32:11Z")

</div>

There is the [training web module](https://github.com/Icinga/icingaweb2-module-training) 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? 🙂  
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 🙂

---

<div class="post-metadata">

**Author:** ![gurhan](https://community.icinga.com/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gurhan](https://community.icinga.com/u/gurhan)\
**Post date:** [October 20, 2023, 8:44am UTC](https://community.icinga.com/t/custom-module/12777/4 "2023-10-20T08:44:55Z")

</div>

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.

```auto
<?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;
    }
}

```

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 20, 2023, 9:36am UTC](https://community.icinga.com/t/custom-module/12777/5 "2023-10-20T09:36:26Z")

</div>

> [@gurhan](#):
>
> 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

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

---

<div class="post-metadata">

**Author:** ![gurhan](https://community.icinga.com/letter_avatar_proxy/v4/letter/g/f17d59/32.png) [@gurhan](https://community.icinga.com/u/gurhan)\
**Post date:** [October 23, 2023, 7:41am UTC](https://community.icinga.com/t/custom-module/12777/6 "2023-10-23T07:41:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [October 23, 2023, 7:53am UTC](https://community.icinga.com/t/custom-module/12777/7 "2023-10-23T07:53:13Z")

</div>

> [@gurhan](#):
>
> To be honest I don’t have any other scripts now

without any other file there is not loading of that file in place.  
here an example from the [grafana module](https://github.com/Mikesch-mp/icingaweb2-module-grafana) 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/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/HostDetailExtension.php)

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