svinota / pyroute2

Python Netlink and PF_ROUTE library — network configuration and monitoring
https://pyroute2.org/
Other
951 stars 244 forks source link

How get named counter in pyroute2 #1160

Open Rycroft-Philostrate opened 8 months ago

Rycroft-Philostrate commented 8 months ago

There are named counters in the table:

table ip t_nat_100 { # handle 10
        counter counter_prerouting { # handle 3
                packets 272 bytes 17304
        }
        counter counter_postrouting { # handle 4
                packets 6746 bytes 325668

When using the "get_tables()" function in pyroute2, the output is:

{'nfgen_family': 2, 'version': 0, 'res_id': 8, 'attrs': [('NFTA_TABLE_NAME', 't_nat_100'), ('NFTA_TABLE_FLAGS', "), ('NFTA_TABLE_USE', 5), ('NFTA_TABLE_HANDLE', 10)], 'header': {'length': 64, 'type': 2560, 'flags': 2, 'sequence number': 255, 'pid': 98281, 'error': None, 'target': 'local host', 'statistics': Statistics(qsize=0, delta=0, delay=0)}}

How do I get the data of these counters using pyroute2?