0

I have started exploring TextFSM by google, its great for screen scraping. But I'm stuck. Here is the template for the command: vsh_lc -c "show platform internal bcm-usd funcstats"

Value Filldown Chassis (.*)
Value FUNC (.*)
Value COUNT (.*)
Value TOTAL (.*)
Value MIN (.*)
Value AVG (.*)
Value MAX (.*)

Start
  ^${Chassis}:
  ^\s+${FUNC}\s+${COUNT}\s+${TOTAL}\s+${MIN}\s+${AVG}\s+${MAX} -> Record

Raw Output:

FUNC ID Stats:
==============================================================================================================================
Func Name                                          Count        Total        Min          Avg          Max
==============================================================================================================================
OPT_TLV_DISPATCH                                   374599       195554872    32           522          82953
TLV Process                                        2209072      193806960    21           87           49448
TLV Type Stats:
==============================================================================================================================
Func Name                                          Count        Total        Min          Avg          Max
==============================================================================================================================
bcm_l2_addr_add                                    26337        903799       24           34           1020
bcm_l2_addr_delete                                 27893        1462054      25           52           16169
bcm_l3_egress_create                               13           1127         55           86           120
bcm_l3_egress_destroy                              96172        2829352      16           29           4445
bcm_l3_host_add                                    374240       15358864     33           41           2267
bcm_l3_host_delete                                 96166        5105960      33           53           1930
bcm_l3_route_add                                   1197940      87904190     53           73           49366
bcm_field_entry_policer_get                        36768        81346        1            2            4436
bcm_field_entry_prio_get                           41364        105509       1            2            2707
bcm_field_entry_stat_get                           36768        46577        0            1            43
bcm_field_stat_get                                 147072       2331072      13           15           4378
bcm_policer_get                                    36768        76539        1            2            4199
my_l3_host_create                                  96167        14690261     83           152          38770
==============================================================================================================================
Retry Count: 0, Retry Success Count: 0
Parity Errors: 0, Parity Errors Uncorrectable: 0
Port Restarts on PHY error: 0

For some reason not parsing into the table values. Please help!!!

Saeed Zhiany
  • 2,051
  • 9
  • 30
  • 41
  • `Value Filldown Chassis (.*) Value FUNC (.*) Value COUNT (\d+) Value TOTAL (\d+) Value MIN (\d+) Value AVG (\d+) Value MAX (\d+) Start ^${Chassis}: ^\s+Func Name\s+\s+\s+Count\s+Total\s+Min\s+Avg\s+Max -> Continue ^\S+${FUNC}\s+${COUNT}\s+${TOTAL}\s+${MIN}\s+${AVG}\s+${MAX} -> Record` This template gives some output, but not showing the value first column. – sam chel Aug 19 '18 at 06:35

1 Answers1

1

The below mentioned template would give you the required output.

Value Filldown Chassis (.+)
Value FUNC (\w+|.+)
Value COUNT (\d+)
Value TOTAL (\d+)
Value MIN (\d+)
Value AVG (\d+)
Value MAX (\d+)

Start
  ^${Chassis} Stats:
  ^${FUNC}\s+${COUNT}\s+${TOTAL}\s+${MIN}\s+${AVG}\s+${MAX} -> Record

The regex (.*) matches any character, always keep the regex specific to what has to be matched.

Use online regex tools to test your regex. try Regexr

Kreyszigan
  • 21
  • 2