How can I pick up the advertised bandwidth of a Tor relay by looking at cached-microdesc-consensus file?
You can't directly since this information is not contained in the microdescriptor. The microdescriptors contain only the information needed for the client to build circuits, and the advertised bandwidth isn't needed for that. You will need to download the larger server descriptor if you want this information. Tor clients do not download this server descriptor by default, but I think this can be enabled with the
router privater 126.96.36.199 9000 0 0
-----BEGIN ED25519 CERT-----
-----END ED25519 CERT-----
platform Tor 0.4.7.10 on Linux
proto Cons=1-2 Desc=1-2 DirCache=2 FlowCtrl=1-2 HSDir=2 HSIntro=4-5 HSRend=1-2 Link=1-5 LinkAuth=1,3 Microdesc=1-2 Padding=2 Relay=1-4
published 2022-09-20 09:42:36
fingerprint 57A2 9537 7F31 67AD 554B 521F 4615 1849 43C3 9CE1
bandwidth 31457280 1073741824 41959424
extra-info-digest 4BFE0FF549703B8D72D3199B398404B176D5633B WKIRVM/PrRj3aA8QpM67lwpIBxnfgKuYz+YHFpcZXws
"bandwidth" bandwidth-avg bandwidth-burst bandwidth-observed NL
Estimated bandwidth for this router, in bytes per second. The
"average" bandwidth is the volume per second that the OR is willing to
sustain over long periods; the "burst" bandwidth is the volume that
the OR is willing to sustain in very short intervals. The "observed"
value is an estimate of the capacity this relay can handle. The
relay remembers the max bandwidth sustained output over any ten
second period in the past 5 days, and another sustained input. The
"observed" value is the lesser of these two numbers.
Tor versions released before 2018 only kept bandwidth-observed for one
day. These versions are no longer supported or recommended.