What do the counters in /proc/[pid]/io mean?

While the proc manpage is woefully behind (and so are most manpages/documentation on anything not relating to cookie-cutter user-space development), this stuff is fortunately documented completely in the Linux kernel source under Documentation/filesystems/proc.rst. Here are the relevant bits: rchar —– I/O counter: chars read The number of bytes which this task has caused to be … Read more

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

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

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

Is it safe to parse a /proc/ file?

In general, no. (So most of the answers here are wrong.) It might be safe, depending on what property you want. But it’s easy to end up with bugs in your code if you assume too much about the consistency of a file in /proc. For example, see this bug which came from assuming that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)