Get local network interface addresses using only proc?

/proc/net/fib_trie holds the network topography To simply print the addresses of all adapters: $ awk ‘/32 host/ { print f } {f=$2}’ <<< “$(</proc/net/fib_trie)” 127.0.0.1 192.168.0.5 192.168.1.14 To determine the adapter of those addresses (a) consult the adapters’ destination networks from /proc/net/route, (b) match those networks with the ones of /proc/net/fib_trie and (c) print the … Read more

sscanf in Python

There is also the parse module. parse() is designed to be the opposite of format() (the newer string formatting function in Python 2.6 and higher). >>> from parse import parse >>> parse(‘{} fish’, ‘1’) >>> parse(‘{} fish’, ‘1 fish’) <Result (‘1’,) {}> >>> parse(‘{} fish’, ‘2 fish’) <Result (‘2’,) {}> >>> parse(‘{} fish’, ‘red fish’) … Read more

How to know linux scheduler time slice?

The quantum allocated for a particular process may vary: You can tune “slice” by adjusting sched_latency_ns and sched_min_granularity_ns, but note that “slice” is not a fixed quantum. Also note that CFS preemption decisions are based upon instantaneous state. A task may have received a full (variable) “slice” of CPU time, but preemption will be triggered … Read more