cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1752
Views
0
Helpful
2
Replies

datetime class in ACI

peterzhang
Level 1
Level 1

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.

1 Accepted Solution

Accepted Solutions

gmonroy
Cisco Employee
Cisco Employee

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

 

 

View solution in original post

2 Replies 2

gmonroy
Cisco Employee
Cisco Employee

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

 

 

This is good stuff, thank you Gabriel !

 

Peter

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License