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 ?
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?
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
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;
}
}
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: