Exclude state=0 from api call
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Exclude state=0 from api call
Hi
I try to do a report from api and i need to exclude state=o from objects/statehistory i only wanna se values 1, 2 and 3
Thanks for your help
I try to do a report from api and i need to exclude state=o from objects/statehistory i only wanna se values 1, 2 and 3
Thanks for your help
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Re: Exclude state=0 from api call
Hello
i can do it with
Now a have another question:
in objects/hostavailability how can i set the starttime from a specific date for example 25/10/2021 to another dat for example 25/11/2021
i can do it with
Code: Select all
curl -XGET "https://XISERVER/nagiosxi/api/v1/objects/statehistory?apikey=XXXXXXXXXXXXXXXXXXXXXXXX&pretty=1&state_type=1&state=in:1,2,3"
in objects/hostavailability how can i set the starttime from a specific date for example 25/10/2021 to another dat for example 25/11/2021
Re: Exclude state=0 from api call
Hi
This should help: You can find the API documentation by going to the Help page on your XI server: Thanks
This should help: You can find the API documentation by going to the Help page on your XI server: Thanks
You do not have the required permissions to view the files attached to this post.
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Re: Exclude state=0 from api call
Hi gsmith
It uses epoch time, actully i use the powerbi for advanced reports and dashboard, Nevertheless i need to generate a dinamic ability report for some time periods as las 7 days, las 30 days, this month, last mont.
I cant do the expresions in bash
but this expresion only runs on bash but in powerbi how i can generate this expressions with the link and it will be dinamic?
for example
curl -XGET "https://URL/nagiosxi/api/v1/objects/hos ... ]lastmonth[/b]"
Thanks for you help
It uses epoch time, actully i use the powerbi for advanced reports and dashboard, Nevertheless i need to generate a dinamic ability report for some time periods as las 7 days, las 30 days, this month, last mont.
I cant do the expresions in bash
Code: Select all
curl -XGET "https://URL/nagiosxi/api/v1/objects/hostavailability?apikey=APIKEY&pretty=1&host=FLD0013_Puesto_de_Trabajo_PC1&starttime=$(date +'%s' --date='31 days ago')"
for example
curl -XGET "https://URL/nagiosxi/api/v1/objects/hos ... ]lastmonth[/b]"
Thanks for you help
Re: Exclude state=0 from api call
Hi
I don't use power bi so I can't really answer your question.
Do you need to know how to get today's date/time in bash, and calculate the epoch time for 7
days ago?
Thanks
I don't use power bi so I can't really answer your question.
Do you need to know how to get today's date/time in bash, and calculate the epoch time for 7
days ago?
Thanks
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Re: Exclude state=0 from api call
Hi power bi only need a Url
But when i make the url with the epoch, tomorrow will be from 8 days ago, i need a expresion as:
curl -XGET "https://URL/nagiosxi/api/v1/objects/hos ... ]lastmonth[/b]"
But when i make the url with the epoch, tomorrow will be from 8 days ago, i need a expresion as:
curl -XGET "https://URL/nagiosxi/api/v1/objects/hos ... ]lastmonth[/b]"
-
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Exclude state=0 from api call
Hi Don,
So the default end time is now, so determine the timestamp based on now - 30 days.
Current time = 1638225150
1 month = 2629743 seconds
30 Days ago = 1638225150 - 2629743 = 1635595407
starttime = 1635595407
Sample command from my test system would be:
Hopefully, that helps. If not, please provide some more context as we may not be understanding the issue correctly. Thanks, Benjamin
References:
https://www.epochconverter.com/
https://www.unixtimestamp.com/
So the default end time is now, so determine the timestamp based on now - 30 days.
Current time = 1638225150
1 month = 2629743 seconds
30 Days ago = 1638225150 - 2629743 = 1635595407
starttime = 1635595407
Sample command from my test system would be:
Code: Select all
curl -XGET "https://192.168.23.112/nagiosxi/api/v1/objects/hostavailability?apikey=AAXHBIAkAHq5L7nnrHdgah5RKMi7b4uKDrIrqu5ZcukdFKTmH7FRnZInLhtdk0dd&pretty=1&host=localhost&starttime=1635595407"
References:
https://www.epochconverter.com/
https://www.unixtimestamp.com/
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Re: Exclude state=0 from api call
Hi dear Benjamin
Thx for you reply
If i use your method tomorrow will be 31 days 8 days 1 month 1 day.
I need that our parameter allways be 1 week, 1 month, last month, this month. For reporting without change the paremeters in the api.
Greetings
Thx for you reply
If i use your method tomorrow will be 31 days 8 days 1 month 1 day.
I need that our parameter allways be 1 week, 1 month, last month, this month. For reporting without change the paremeters in the api.
Greetings
-
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Exclude state=0 from api call
HI,
Regards,
Benjamin
Reference:
https://www.epochconverter.com/timestamp-lis
The API is using unix timestamps for start and end times, so determining the UNIX timestamp start/endpoints for the last month would have to be done in the script your using to manage the API. Unfortunately, It doesn't have the functionality built-in.I need that our parameter always be 1 week, 1 month, last month, this month. For reporting without change the paremeters in the api
Regards,
Benjamin
Reference:
https://www.epochconverter.com/timestamp-lis
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
- Posts: 94
- Joined: Thu Oct 07, 2021 8:59 pm
Re: Exclude state=0 from api call
Greetings
Ok, then what is the limit of records from api reply
https://XISERVER/nagiosxi/api/v1/object ... b]XXXXXXXX[/b]
Ok, then what is the limit of records from api reply
https://XISERVER/nagiosxi/api/v1/object ... b]XXXXXXXX[/b]