cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
452
Views
1
Helpful
2
Replies

How to limit output Show Memory Free Totals using regex

hfakoor222
Spotlight
Spotlight

I'm writing a script to get the memory from devices, with show memory free totals i get the below

 

2023-04-18 08_40_32-IOU1.png

 

I only want to get the first two lines to compare free to total memory and write it into an output file if below a certain percentage.

How can I exclude everything after the first 2 lines?

I use the output modifier 'section Head' and it returns:

2023-04-18 08_44_54-IOU1.png

 

 

I can try 

"show memory free totals | include (Processor).*[0-9]"
 
and it gets me output I want within a single line
2023-04-18 08_40_32-IOU1.png

 

 

However I would like to know is there a way for me to get the first two lines? It doesn't seem like the router has a feature to get the first n lines of an output,  the rest of the show memory free command has a lot of lines, the same with other troubleshooting commands I've come across, and i would like to get the first few lines.

1 Accepted Solution

Accepted Solutions

why you not use SNMP OID for this case ? it can give you free used memory 

View solution in original post

2 Replies 2

why you not use SNMP OID for this case ? it can give you free used memory 

Thanks I will, use that for next time

Review Cisco Networking for a $25 gift card