[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: No ifconfig [Was: no /etc/inittab]



On Tue, Aug 15, 2017 at 09:29:37AM -0400, Greg Wooledge wrote:
On Tue, Aug 15, 2017 at 03:03:35PM +0200, Dejan Jocic wrote:
And what exactly do you miss in ifconfig and net-tools package, that you
can not do with ip, which is part of iproute2 package that comes as part
of base system?

What iproute2 and net-tools are BOTH missing is a sane, script-friendly,
user-controllable output format.

Agreed. systemd's "journalctl" gets it right here - a human readable "short" output (admittedly, journalctl then goes overboard with the number of options for timestamps, but they ARE a thorny issue), a verbose output showing all the information and a json output which is MUCH more easily parsed by scripts (none of this "The third field from the left, except for the first line, which is a header" malarkey).


What iproute2 is specifically missing (as far as I can determine):
consistent option syntax, and any report analogous to "netstat -in":

wooledg:~$ netstat -in
Kernel Interface table
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0      1500  8254258      0      0 0       7682795      0      0      0 BMRU
lo       65536   579959      0      0 0        579959      0      0      0 LRU

In a world where virtually every possible output of every reporting
command is atrociously hard to read, that one is the least bad.  You can
actually get the interface names with only two reasonably simple parsing
operations (strip the first line, then strip everything from the first
whitespace to EOL).

The closest analog I've found in iproute2 is "ip link", which looks like:

wooledg:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
   link/ether a0:8c:fd:c3:89:e0 brd ff:ff:ff:ff:ff:ff

Parsing the interface names out of THAT is significantly harder.

Have you looked at "ip -s link"? It's not quite as easy to parse as "netstat -in", but all the information's there.


The real tragedy is the missed opportunity.  Linux developers wrote
iproute2 from scratch, but they failed to add any kind of user-specified
output format (cf. ps h -o ppid, find -printf %h, etc.), or to sit down
and THINK about how the user interface should be designed.  Instead of
a clean, friendly, consistent, useful new tool we just got this weird
monstrosity that feels like someone decided to change things just because
they were bored one day, without any rhyme or reason or plan.


util-linux is, arguably, going the right way here. libsmartcols[1] allows for some rather flexible output options: trees, tables, UTF8 handling, terminal-width truncation etc.

[1] http://karelzak.blogspot.co.uk/2014/05/libsmartcols-pretty-output-for-everyone.html


--
For more information, please reread.

Attachment: signature.asc
Description: PGP signature


Reply to: