Hi;
what is the difference between using :
http://nagiosserver/nagios/jsonquery.html
or
http://nagiosserver/nagiosxi/api/v1/
Is one preferred over the other?
from what I can tell it appears that the first one, jsonquery, seems to have some better capabilities when querying for status(i.e. hostlisting based on groups, hostcount and so on..)
Nagios REST API's
Re: Nagios REST API's
The first one is the JSON CGI for Nagios Core, which while it has some better filtering right now, does not have the ability to do things such as modify the configs, restart core, apply configs, etc. Besides those, most of the same data should show up unless it's XI-specific, which will only show up in the second one.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios REST API's
so for querying, at that moment anyways, the nagios core JSON may be a better option?? sounds like that will change in the future.
I'm wanting to check the health of a number of network switches at a particular site(we have hundreds of sites across the province) and using the nagmap plugin plot the overall group health of the switches at each site for display to management. My plan was to group those switches in hosts groups and then develop a plugin to check the overall group health of each of those groups using a JSON query. Does that make sense or is there an easier way to tackle that??
I just stumbled across the xi api this morning, I do use the \etc\import folder for importing new hosts and services through automation, do the post commands support inserting free variables as well? is there any additional documentation on the XI api outside of what is in the online help?
I'm wanting to check the health of a number of network switches at a particular site(we have hundreds of sites across the province) and using the nagmap plugin plot the overall group health of the switches at each site for display to management. My plan was to group those switches in hosts groups and then develop a plugin to check the overall group health of each of those groups using a JSON query. Does that make sense or is there an easier way to tackle that??
I just stumbled across the xi api this morning, I do use the \etc\import folder for importing new hosts and services through automation, do the post commands support inserting free variables as well? is there any additional documentation on the XI api outside of what is in the online help?
Re: Nagios REST API's
This presentation has a bit of information - http://www.slideshare.net/nagiosinc/eri ... -nagios/46
On top of that, you can take a look at what's possible through the API by navigating to Backend API URL -> Click 'wrench icon' -> Select the user. From here you'll see all the information that can be used with the API.
More documentation can be found by going to your Nagios XI Home page and clicking 'Help', you'll see a section for 'Nagios XI API Docs' on the left side.
Is that what you were looking for?
On top of that, you can take a look at what's possible through the API by navigating to Backend API URL -> Click 'wrench icon' -> Select the user. From here you'll see all the information that can be used with the API.
More documentation can be found by going to your Nagios XI Home page and clicking 'Help', you'll see a section for 'Nagios XI API Docs' on the left side.
Is that what you were looking for?
Former Nagios Employee
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios REST API's
Yes. There is a bug that will be fixed in the next release of core. Sometimes a complete JSON is not returned. If you come across this, I know it's fixed in core pre 4.1.2 on Github.paul.jobb wrote:so for querying, at that moment anyways, the nagios core JSON may be a better option?? sounds like that will change in the future.
BPI might also be an option.paul.jobb wrote:I'm wanting to check the health of a number of network switches at a particular site(we have hundreds of sites across the province) and using the nagmap plugin plot the overall group health of the switches at each site for display to management. My plan was to group those switches in hosts groups and then develop a plugin to check the overall group health of each of those groups using a JSON query. Does that make sense or is there an easier way to tackle that??
https://support.nagios.com/kb/article.php?id=280
Basically any directive that can be configured in an object that is defined in the nagios core documentation. However I just did some quick tests and it does not appear these are currently supported. Perhaps define these in a template and "use=" those templates might be a work around.paul.jobb wrote:I just stumbled across the xi api this morning, I do use the \etc\import folder for importing new hosts and services through automation, do the post commands support inserting free variables as well? is there any additional documentation on the XI api outside of what is in the online help?
https://support.nagios.com/kb/article.php?id=356
Some directives are mandatory, however when using templates you might not want to define some directives. You need to use &force=1 to allow that.
Code: Select all
curl -k -XPOST "https://xitest.box293.local/nagiosxi/api/v1/config/host?apikey=5goacg8s&pretty=1" -d "host_name=my_test_host&address=127.0.0.1&use=linux-server&force=1&applyconfig=1"As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios REST API's
Thank you Troy
force=1 was a good tip thanks for the heads up on that, I don't need free variables for network devices so I can get away without those for now, the following is the powershell I got working this morning with your suggestion.
$body = @{
host_name="AGSGSFL2SW1"
address="255.255.255.255"
alias="AGSGSFL2SW1"
notes="latlng: 51.046259,-114.053315"
_testvar="some string"
use="GOA-Network-Device"
force=1
}
$url="http://nagiosserver.gov.ab.ca/nagiosxi/ ... x&pretty=1"
$result=Invoke-RestMethod -Method Post -Uri $url -Body $body
$result
Thanks also for pointing out BPI, I do use that currently for some other stuff but have sort of moved away from that towards check_multi, BPI is a bit of a chore to maintain and for availability measurement it doesnt seem to filter out soft states which check_multi does.
With the network stuff switches are being added and removed from the environment daily so its just easier to reconcile nagios with there inventory DB through automation scripts a few times a day, group them on location and then measure the availability of the group health of the site .
I really appreciate your input.
force=1 was a good tip thanks for the heads up on that, I don't need free variables for network devices so I can get away without those for now, the following is the powershell I got working this morning with your suggestion.
$body = @{
host_name="AGSGSFL2SW1"
address="255.255.255.255"
alias="AGSGSFL2SW1"
notes="latlng: 51.046259,-114.053315"
_testvar="some string"
use="GOA-Network-Device"
force=1
}
$url="http://nagiosserver.gov.ab.ca/nagiosxi/ ... x&pretty=1"
$result=Invoke-RestMethod -Method Post -Uri $url -Body $body
$result
Thanks also for pointing out BPI, I do use that currently for some other stuff but have sort of moved away from that towards check_multi, BPI is a bit of a chore to maintain and for availability measurement it doesnt seem to filter out soft states which check_multi does.
With the network stuff switches are being added and removed from the environment daily so its just easier to reconcile nagios with there inventory DB through automation scripts a few times a day, group them on location and then measure the availability of the group health of the site .
I really appreciate your input.
Re: Nagios REST API's
Great! Is there anything other questions about the APIs we can help with?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Nagios REST API's
Great to hear you got it working.
Just curious, did this custom variable make it through into the object, or did the API drop it?paul.jobb wrote:_testvar="some string"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios REST API's
no it didn't make it, hopefully in the next release it does.
Re: Nagios REST API's
FYI, we already have an internal feature request for adding free variables to the REST API (TASK ID 7853).
Be sure to check out our Knowledgebase for helpful articles and solutions!