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

Outputting Moquery results to CSV - With formatting

AukeyPeach
Level 1
Level 1

Hello All!

 

I am required to cleanup our enterprise fabric and that means I need to deep-dive into the underlying data.

 

I have already found a query to return the exact data I want - That data being "Every EPG" - Essentially.

 

moquery -c fvAEPg | grep "dn" | awk '{print $3}'

 

The result is exactly what I want and is formatted as follows:

 

uni/tn-TEST123/ap-AP123/epg-EPG123
 
I have already got a JSON script ready to go which will essentially go through all 922 EPGs in our env and remove specific domains.
 
The script works great but It needs 3 variables from a CSV file in order for it to work:
 
tenant, ap, epg - In this exact format.
 
Since the format of the output returns all 3 attributes, what I would really love is to find a way to export the results of the above query so that it reads as follows:
 
tenant ap epg
TENANT123 AP123 EPG123

 

At the moment I have a file which is 923 lines long which needs to be formatted one way or another.

 

If this is possible, can anyone with this experience share with me how best to go about this on the APIC? 

 

Thanks so much in advanced!

 

~Aukey

1 Accepted Solution

Accepted Solutions

Sergiu.Daniluk
VIP Alumni
VIP Alumni

There are multiple ways to handle this, like awking just for specific info you want, or manipulating the text file (search&replace using regex), but I think it's easier to simply import the data into excel and use "/" as delimiter.

Data -> Insert From Text -> select "/" in step 2:

Screenshot 2022-07-07 102450.png

You will have to adjust your script, to not add automatically the "tn-", "ap-" and "epg-", but I think is faster this way.

 

Take care,

Sergiu

View solution in original post

2 Replies 2

Sergiu.Daniluk
VIP Alumni
VIP Alumni

There are multiple ways to handle this, like awking just for specific info you want, or manipulating the text file (search&replace using regex), but I think it's easier to simply import the data into excel and use "/" as delimiter.

Data -> Insert From Text -> select "/" in step 2:

Screenshot 2022-07-07 102450.png

You will have to adjust your script, to not add automatically the "tn-", "ap-" and "epg-", but I think is faster this way.

 

Take care,

Sergiu

Once Again @Sergiu.Daniluk you have come to save the day!

 

I was over complicating matters as usual and didn't think about where I was storing the data to be able to manipulate it there.

 

To expand this, just for my own sake in case I come back to it, because a tenant, epg and AP, are appended "tn- ap- epg-" I used the substitute command on Excel - This works perfectly remove any appendages and presents clean data, exactly what I wanted!

 

Thank you once again Sergiu

Review Cisco Networking for a $25 gift card

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