Activate Support Account / Help with XIAPI
Activate Support Account / Help with XIAPI
Hey folks
How do I get my account activated for the Customer section?
Secondly, I am looking for some pointers with the API and ansible. My current ansible playbook adds a machine to the XI server once the agent is installed. However as I add more checks based on hostgroups, I wan't to add specific hosts to the hostgroup. Is there an API call I can use to add the host to the group?
B
How do I get my account activated for the Customer section?
Secondly, I am looking for some pointers with the API and ansible. My current ansible playbook adds a machine to the XI server once the agent is installed. However as I add more checks based on hostgroups, I wan't to add specific hosts to the hostgroup. Is there an API call I can use to add the host to the group?
B
-
jforcier
Re: Activate Support Account / Help with XIAPI
Please contact [email protected] to get your account activated for the customer forum. Or you can add yourself here
https://support.nagios.com/add-contact/
Here is some documentation on how to use the API:
https://assets.nagios.com/downloads/nag ... gement.pdf
You can also go to the help section in Nagios XI and then click on 'Config Reference' on the left hand side for more examples.
Modifying a hostgroup via the REST API would mean "recreating" this hostgroup from scratch. Let's say you have a hostgroup named "HG" with 3 members - "Host1", "Host2", and "Host3".
Now, you need to add one more member - "Host4". You could run something like this from the command line:
Here is an example of how to create a new host and add it to a host group:
https://support.nagios.com/add-contact/
Here is some documentation on how to use the API:
https://assets.nagios.com/downloads/nag ... gement.pdf
You can also go to the help section in Nagios XI and then click on 'Config Reference' on the left hand side for more examples.
Modifying a hostgroup via the REST API would mean "recreating" this hostgroup from scratch. Let's say you have a hostgroup named "HG" with 3 members - "Host1", "Host2", and "Host3".
Code: Select all
define hostgroup {
hostgroup_name HG
alias MyHostGroup
members Host1,Host2,Host3
}Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/hostgroup?apikey=xxxx=1" -d "hostgroup_name=HG&alias=MyHostGroup&members=Host1,Host2,Host3,Host4&force=1&applyconfig=1"Here is an example of how to create a new host and add it to a host group:
Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/host?apikey=xxxx=1" -d "host_name=Host5&address=x.x.x.x&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&hostgroups=HG&force=1&applyconfig=1"Re: Activate Support Account / Help with XIAPI
Thanks mate, have access to customer section now.
I was hoping something easier than recreating would be available, but I guess not. I don't usually do much with APIs, so my ansible play will need to:
- Make an API call to Read HG
- Make an API call to Delete HG
- Make an API call to create HG adding the current ansible_hostname to the end
Is that correct? Does deleting the Hostgroup delete any
Does anyone have any sample plays?
In regards to creating host and hostgroup, all these hosts are already created and in XI [registered to a generic-group using the API at the point of the agent install], they just need to be added to various groups based on the system role.
Thanks for the help.
[If you can move this to the customer XI forum that would be great too]
I was hoping something easier than recreating would be available, but I guess not. I don't usually do much with APIs, so my ansible play will need to:
- Make an API call to Read HG
- Make an API call to Delete HG
- Make an API call to create HG adding the current ansible_hostname to the end
Is that correct? Does deleting the Hostgroup delete any
Does anyone have any sample plays?
In regards to creating host and hostgroup, all these hosts are already created and in XI [registered to a generic-group using the API at the point of the agent install], they just need to be added to various groups based on the system role.
Thanks for the help.
[If you can move this to the customer XI forum that would be great too]
Re: Activate Support Account / Help with XIAPI
What happens if the host is in the API call multiple times - eg I was running the command against a host already in the group ?
Re: Activate Support Account / Help with XIAPI
You don't need to delete a hostgroup, and then recreate it. Simply recreating the group via a REST API call will overwrite what is in it. Basically, it will "recreate it from scratch". That's why, you cannot just add a new host as a member of a hostgroup, and expect that the "old" members will be intact. If you had two hosts added as members to a hostgroup (HostA and HostB), and you wanted to add a third one - HostC, you will have to add ALL three hosts via your API call. If you added only HostC, you would have only one member in the hostgroup.I was hoping something easier than recreating would be available, but I guess not. I don't usually do much with APIs, so my ansible play will need to:
- Make an API call to Read HG
- Make an API call to Delete HG
- Make an API call to create HG adding the current ansible_hostname to the end
Is that correct? Does deleting the Hostgroup delete any
Again, recreating the group will overwrite the "old" one, and add whatever members you specify in your REST API call.What happens if the host is in the API call multiple times - eg I was running the command against a host already in the group ?
As far as ansible playbooks goes - this is out of scope for Nagios support. You can review the REST API documentation under the Help menu in Nagios XI and easily identify the commands that you need to use in your playbooks.
Hope this helps. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Activate Support Account / Help with XIAPI
Thanks for that. I was chancing my arm with the ansible question
I do however have it almost working, but got distracted by something else unfortunately.
I do have a final query though. Is it possible to easily change the data location? I cannot seem to find any option in the settings. I want to move the data to its own FS away from /
Regards
B
I do have a final query though. Is it possible to easily change the data location? I cannot seem to find any option in the settings. I want to move the data to its own FS away from /
Regards
B
Re: Activate Support Account / Help with XIAPI
What kind of data are you talking about? Can you elaborate? Are you asking if Nagios XI can be installed in a custom location (path)?Is it possible to easily change the data location?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Activate Support Account / Help with XIAPI
Well I was hoping the data [/usr/local/nagios/] could be migrated to another location, however as the system is still in the process of being built, I am going to just create a new mount point at /usr/local/nagios
Thanks for all the help.
Thanks for all the help.
Re: Activate Support Account / Help with XIAPI
You can create a mount point at /usr/local/nagios then install Nagios XI - this should be fine. If you already had data in /usr/local/nagios, you would need to move it out of there, create your mount, then moving back in.
Let us know if it's ok to close this topic. Thanks!
Let us know if it's ok to close this topic. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Activate Support Account / Help with XIAPI
Close away!