API for ServiceNow

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

API for ServiceNow

Post by FCC_Nagios_Support »

Hi,

Can I procces several Nagios Tables from ServiceNow in order to get the Service Group to which event/service belongs to.
Do you have documentation of the API
Thanks
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

Re: API for ServiceNow

Post by FCC_Nagios_Support »

I am querying:
curl -XGET "http://10.5.1.159/nagiosxi/api/v1/objec ... 7&pretty=1"


{
"host_name": "mad63205.se.gr.fcc.es",
"service_description": "OS_Windows_1_7_CPU Usage Template",
"objecttype_id": "2",
"object_id": "21047",
"state_time": "2021-02-11 12:23:43",
"state_change": "1",
"state": "1",
"state_type": "1",
"current_check_attempt": "5",
"max_check_attempts": "5",
"last_state": "1",
"last_hard_state": "0",
"instance_id": "1",
"output": "could not fetch information from server"
},

And I obtain all the events
I would like to know to what ServiceGroup belongs to each "service_description"
Do you know the syntax?

Thanks
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

Re: API for ServiceNow

Post by FCC_Nagios_Support »

Is It possible to create a VIEW that can be plublished in the API

Many Thanks
jweijters
Posts: 63
Joined: Thu Feb 06, 2020 3:50 am

Re: API for ServiceNow

Post by jweijters »

Hi,

I Think wat you are loooking for is the "/nagiosxi/api/v1/objects/servicegroupmembers"
In this API call you get the servicegroups, and all members of this servicegroup.

In the Help of NagiosXI you can find all API refrence documentation



Kind regards,

Joris Weijters
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

Re: API for ServiceNow

Post by FCC_Nagios_Support »

Many Thanks
What I want is to call the api for the statehistory and chain/join with service groupmembers in order to obtain event and its servicegroup
Thanks again
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: API for ServiceNow

Post by benjaminsmith »

Hi @FCC_Nagios_Support,

The REST API is fully documented in the user interface with example commands, just go to Help > API Docs.

We do not provide custom scripting/programming as part of product support, but I believe what you want to do here is run a command to get all the members of a particular service using the GET objects/servicegroupmember endpoint.

Code: Select all

curl -XGET "https://192.168.23.113/nagiosxi/api/v1/objects/servicegroupmembersapikey=<YOURAPIKEY>&pretty=1" -k -k
Once you have created a sequence containing all those members, you can gather the state history by using a limited query on those service group members on the GET objects/statehistory endpoint by object id.

Code: Select all

curl -XGET "https://192.168.23.113/nagiosxi/api/v1/objects/statehistory?apikey=<YOURAPIKEY>&object_id=<OBJECTID>&pretty=1" -k
Let us know how it goes.

Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
FCC_Nagios_Support
Posts: 161
Joined: Tue Mar 10, 2020 11:07 am

Re: API for ServiceNow

Post by FCC_Nagios_Support »

Hi

I create a View in Laboratory
called
FER
CREATE VIEW FER
AS
SELECT s.object_id as object_id, n.display_name as display_name, n.service_object_id as service_id
ON s.object_id=n.service_object_id


But I cannot query by the API
[root@osboxes ~]# curl -XGET "http://192.168.1.117//nagiosxi/api/v1/o ... D&pretty=1" {
"error": "Unknown API endpoint."
}
[root@osboxes ~]#


How can I publish the VIEW in order to query it

Thanks
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API for ServiceNow

Post by ssax »

You cannot call a MySQL view directly from the API, you would need to write your own custom API endpoint that calls the view and does with it what you want programmatically, see here on your system:

Code: Select all

http://YOURXISERVER/nagiosxi/help/custom-api-endpoints.php
I can submit a request to development to see if they'll add what servicegroups the service is in to the State History API endpoint if you'd like?
Locked