11-06-2017 08:15 AM - edited 03-01-2019 05:22 AM
Is there a class that can be queried against to obtain the fabric date/time? I need this information to perform various stats check against ACI via script.
For example, I want to check for new faults in the last 5 minute. Using "show" command I can accomplish this via "show faults last-minute 5". How does this translate to moquery with filters ?
I can't really use "bt" filter, because I need a start and end time stamp that's only relative to the fabric, which could be in any time zone. If I can query against the fabric for it's "current time", it would be the best.
Solved! Go to Solution.
11-14-2017 11:59 AM
peterzhang,
To answer your first question, one method I found that will allow you to pull "current time" is the following:
apic1# moquery -c topSystem | grep "dn\|currentTime\|#" # top.System currentTime : 2017-11-14T11:49:18.575-08:00 <<<<<< dn : topology/pod-1/node-1/sys # top.System currentTime : 2017-11-14T11:49:18.576-08:00 dn : topology/pod-1/node-2/sys
To note, you will get one topSystem per node so you will have to do some extra filtering.
As for your second question around how to map NXOS style CLI CMDs to API queries and filters, I ran "show audits detail last-hours 1" and checked the access log to verify what address we use:
apic1# less /var/log/dme/log/access.log 127.0.0.1 - - [14/Nov/2017:11:54:02 -0800] "POST /decoy/exec/cmd.cli HTTP/1.1" 200 0 "-" "python-requests/2.7.0 CPython/2.7.11 Linux/4.4.27.0.1insieme-7" 127.0.0.1 - - [14/Nov/2017:11:54:02 -0800] "GET /api/class/faultInfo.xml?page-size=100&query-target-filter=and(gt(faultInfo.created,%222017-11-14T10:54:02.718222%22))&page=0&order-by=faultInfo.created%7Cdesc HTTP/1.1" 200 63956 "-" "python-requests/2.7.0 CPython/2.7.11 Linux/4.4.27.0.1insieme-7" ...snip...
So that should give you a better idea of what filters it is using.
Cheers,
Gabriel
11-14-2017 11:59 AM
peterzhang,
To answer your first question, one method I found that will allow you to pull "current time" is the following:
apic1# moquery -c topSystem | grep "dn\|currentTime\|#" # top.System currentTime : 2017-11-14T11:49:18.575-08:00 <<<<<< dn : topology/pod-1/node-1/sys # top.System currentTime : 2017-11-14T11:49:18.576-08:00 dn : topology/pod-1/node-2/sys
To note, you will get one topSystem per node so you will have to do some extra filtering.
As for your second question around how to map NXOS style CLI CMDs to API queries and filters, I ran "show audits detail last-hours 1" and checked the access log to verify what address we use:
apic1# less /var/log/dme/log/access.log 127.0.0.1 - - [14/Nov/2017:11:54:02 -0800] "POST /decoy/exec/cmd.cli HTTP/1.1" 200 0 "-" "python-requests/2.7.0 CPython/2.7.11 Linux/4.4.27.0.1insieme-7" 127.0.0.1 - - [14/Nov/2017:11:54:02 -0800] "GET /api/class/faultInfo.xml?page-size=100&query-target-filter=and(gt(faultInfo.created,%222017-11-14T10:54:02.718222%22))&page=0&order-by=faultInfo.created%7Cdesc HTTP/1.1" 200 63956 "-" "python-requests/2.7.0 CPython/2.7.11 Linux/4.4.27.0.1insieme-7" ...snip...
So that should give you a better idea of what filters it is using.
Cheers,
Gabriel
11-14-2017 02:34 PM
This is good stuff, thank you Gabriel !
Peter
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide