How to write my own component

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mopp
Posts: 64
Joined: Thu Aug 20, 2015 7:15 am

How to write my own component

Post by mopp »

Hello,

with Nagios XI 5R1.0 a component freevariabletab is shipped and I wanted to use this as base template to create a new component.
I replaced every free* word by a new component name, but the component does not show? Do I have to register it?

I want to write a component which shows the whole configuration of a host / service in a tab. The data is available, so it should be possible to display it.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to write my own component

Post by lmiltchev »

Here's our official documentation on writing custom components in XI. This should get you started.

https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
mopp
Posts: 64
Joined: Thu Aug 20, 2015 7:15 am

Re: How to write my own component

Post by mopp »

lmiltchev wrote:Here's our official documentation on writing custom components in XI. This should get you started.

https://assets.nagios.com/downloads/nag ... ios-XI.pdf
I already read the document. Is it enough to copy the files into the component directory? It is not mentioned in the document. Will the component automatically register if it is in the component directory or do I have to run a command to register it?

As the free variable tab component is very short I used it as base and just changed the necessary things, but I cannot see it and do not get any error message.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to write my own component

Post by tmcdonald »

As long as
  • The component code does not error
  • The component folder is in the right place
  • The permissions are correct
you should not have to do anything else.
Former Nagios employee
mopp
Posts: 64
Joined: Thu Aug 20, 2015 7:15 am

Re: How to write my own component

Post by mopp »

I managed to add a sample component, hopefully the following information is useful.
There are some more requirements which are mentioned in the document https://assets.nagios.com/downloads/nag ... ios-XI.pdf, but for me these were not marked as a requirement.

Create a directory /usr/local/nagiosxi/html/includes/components/mytest
Create a file mytest.inc.php in the directory mytest. The file mytest.inc.php has to have the same name as the directory.
The COMPONENT_NAME in mytest.inc.php has to have the same name as the diretory, too. In this case mytest

I would recommend to modify an existing component, in my case I used freevariabletab. Replace every occurrence of the word free by a new name. The component will not work if some of the names are duplicate.
In the Nagios XI Admin menu go to Manage Components, the component is visible immediately. If you do not see your component or the page does not load you did a mistake.
I didn' t find any log file which could help to identify the problem, but I' m pretty sure you can enable some kind of debug mode.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: How to write my own component

Post by hsmith »

Did you try uploading your component through the interface? I never had any issues with the directory stuff.
Former Nagios Employee.
me.
Locked