I'm looking to do a custom "Availability Report" using the JSON query api.
For the life of me I can't figure out the "start/end" time.
I'm happy to read docs and figure this out, but I have not found ANY documentation on how the (new and awesome APIs actaully work) which is a surprise considering how well documented CORE is.
+ the APIs are awesome.
Any help is much appreciated!
Here are details:
https://MyHost/nagios/jsonquery.html
CGI: Archive Json
Query: availability
Availability Object Type: hosts
Hostname: MyHost
Service Desc: PING
Start Time: ???
End Time: ???
When I enter:
Start: 1
End Time: -30
"host": {
"name": "MyHost",
"time_up": 1569920418, <-- How do I translate this into something meaningful?
"time_down": 38115,
"time_unreachable": 0,
"scheduled_time_up": 0,
"scheduled_time_down": 0,
"scheduled_time_unreachable": 0,
"time_indeterminate_nodata": 0,
"time_indeterminate_notrunning": 0
}
}
}
JSON api start/ent
Re: JSON api start/ent
That looks like a Unix epoch to me:swissarmychainsaw wrote: "time_up": 1569920418, <-- How do I translate this into something meaningful?
https://www.epochconverter.com/
Practically every main-stream programming language has standard libraries/tools for turning that into something human-readable. Also, practically every flavor of Linux:
Code: Select all
[root@ahri ~]# date +%s
1570018475
[root@ahri ~]# date +%s | perl -pe 's/(\d+)/localtime($1)/e'
Wed Oct 2 12:15:16 2019
[root@ahri ~]# date -d @$(date +%s)
Wed Oct 2 12:16:02 UTC 2019
[root@ahri ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> ts = int("1569920418")
>>> print(datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))
2019-10-01 09:00:18
https://github.com/NagiosEnterprises/na ... il.c#L3698
https://github.com/NagiosEnterprises/na ... il.c#L3704
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: JSON api start/ent
Thanks @mcapra!
The JSON query api uses Unix timestamps. Let us know if you have any other questions.
The JSON query api uses Unix timestamps. Let us know if you have any other questions.
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!