Module development documentation

This forum was archived to /woltlab and is now in read-only mode.
  • Hello all,

    I'm looking at creating an Icinga Web 2 module and can't seem to find documentation on module development anywhere. I've looked at other modules and was able to create a simple framework (application, controllers, views, etc.) but I need a better understanding. The base documentation does not say anything about it. Could anybody direct me where I might find docs/how-to for this?

    Thanks in advance

  • There are instructions for a workshop I did quite some time ago, but most if not all of it should still work I guess. It's German, sorry for that. However, someone started to fork and translate it, did a good job - but it is still unfinished.

    Hope that helps!


  • Thanks Thomas. I had a look and between my familiarity with Icinga, the partial translation and Google translate for the rest I should be able to get what I need. Your document is very good from what I've seen in the English part, look forward to the rest of the translation.

  • Thomas, one last question

    Using your documentation I was able to create a module the proper way, i.e. controllers views, libraries etc. and everything works fine. Even picked up a little bit of German along the way. :D

    The only thing missing from your document was how to manage the config.ini from the module/web page instead of editing the file directly. Looking at other modules I've been able to figure out some of it. So far I've got the following done:

    - Added a config tab in the module config page
    - Created a form prepopulated with the current values and that can be used to capture new values

    The only thing I'm missing is how to push the captured values back to the config.ini file. I can use a PHP script to do it in the back end but I thought there might already be an existing mechanism in Icingaweb2 to do this. What would be the recommended way?

  • Hi pcimon,

    for my module i copied (stole :) ) most of the code from the pnp-module. Ini file will be created when a user clicks first time on the "save changes" button, and in my controller is use this code

    1. $factor = $this->Config()->get('globe', 'factor', '0.01');

    This searches for the section "globe" and read the value factor,if nothing is found it uses "0.01" for factor.

  • Hi Mikesch,

    Had a look at pnp-module and you're right it's doing exactly what I'm trying to do. The only thing I can't figure out is where are the modified values pushed back to the config file? The form action submitted by "Save Changes" points to the view index script under /pnp/config which has nothing about saving data in it. Is there such a thing as

    1. $this-Config()->set('globe', 'factor', '0.01');
  • Ok, figured it out. I wanted the config values to be auto populated with the content of the ini file and not have to enter the values in the "addElement" statement of the form but I misunderstood that those values are only used when no config file exists. Once you've hit save changes and the file is created the file values are used to pre populate the form the next time you open it and the values in the "addElement" statements are ignored. From what I can see the file is recreated every time you hit save. That works for me.