formatted netstat -i output

From thelinuxwiki
Revision as of 00:09, 6 August 2013 by Nighthawk (Talk | contribs)

Jump to: navigation, search

ugly command, nice output

# netstat -i | awk '{printf "%-10s%-8s%-4s%-12s%-12s%-12s%-12s%-12s%-12s%-12s%-12s%-12s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12}'
Kernel    Interfacetable                                                                                                            
Iface     MTU     Met RX-OK       RX-ERR      RX-DRP      RX-OVR      TX-OK       TX-ERR      TX-DRP      TX-OVR      Flg         
Mgmt      1500    0   42972148    0           0           0           33031384    0           0           0           BMRU        
Sync      1500    0   1437259126  0           26123       0           2901286795  0           0           0           BMRU        
eth1-01   1500    0   3233895885  2214590     104401      104401      3882612740  0           0           0           BMRU        
eth1-02   1500    0   2452483619  0           10073       10073       224938863   0           0           0           BMRU        
eth1-03   1500    0   47909283    0           0           0           48619886    0           0           0           BMRU        
eth1-04   1500    0   2121393793  0           0           0           1424110895  0           0           0           BMRU        
eth1-06   1500    0   3075729697  0           0           0           2825892631  0           0           0           BMRU        
eth1-07   1500    0   2083045577  0           2642073     2642073     3603188807  0           0           0           BMRU        
eth1-07:0 1500    0   0           0           0           0           0           0           0           0           BMRU        
eth1-08   1500    0   72183182    0           0           0           47803770    0           0           0           BMRU        
eth2-01   1500    0   25896575    0           0           0           26463789    0           0           0           BMRU        
lo        16436   0   265912531   0           0           0           265912531   0           0           0           LRU
# netstat -i | awk '{for (i=1; i<=12; i++) printf "%-12s",$i; printf "\n" }'
Kernel      Interface   table                                                                                                              
Iface       MTU         Met         RX-OK       RX-ERR      RX-DRP      RX-OVR      TX-OK       TX-ERR      TX-DRP      TX-   OVR      Flg    
Mgmt        1500        0           44798753    0           0           0           27975618    0           0           0            BMRU   
Sync        1500        0           2963537772  3           0           0           1468012913  0           0           0           BMRU   
eth1-01     1500        0           1411174596  900025      0           0           1700760266  0           0           0           BMRU   
eth1-02     1500        0           621545020   0           0           0           699950334   0           0           0           BMRU   

eth1-03 1500 0 42298254 0 0 0 41409697 0 0 0 BMRU

eth1-04     1500        0           118450353   0           0           0           91272698    0           0           0           BMRU   
eth1-06     1500        0           842911465   0           0           0           769682478   0           0           0           BMRU   
eth1-07     1500        0           1678630674  0           0           0           1262833128  0           0           0           BMRU   

eth1-07:0 1500 0 0 0 0 0 0 0 0 0 BMRU

eth1-08     1500        0           66948888    0           0           0           42575976    0           0           0           BMRU   
eth2-01     1500        0           27193173    0           0           0           26951616    0           0           0           BMRU   
lo          16436       0           14102710    0           0           0           14102710    0           0           0           LRU  

regular, unformatted command...

# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
Mgmt       1500   0 42971857      0      0      0 33031217      0      0      0 BMRU
Sync       1500   0 1437253374      0  26123      0 2901278387      0      0      0 BMRU
eth1-01    1500   0 3233824068 2214586 104401 104401 3882515746      0      0      0 BMRU
eth1-02    1500   0 2452468224      0  10073  10073 224918415      0      0      0 BMRU
eth1-03    1500   0 47909107      0      0      0 48619706      0      0      0 BMRU
eth1-04    1500   0 2121384593      0      0      0 1424105000      0      0      0 BMRU
eth1-06    1500   0 3075678521      0      0      0 2825847210      0      0      0 BMRU
eth1-07    1500   0 2082965114      0 2642073 2642073 3603131206      0      0      0 BMRU
eth1-07:0  1500   0        0      0      0      0        0      0      0      0 BMRU
eth1-08    1500   0 72183010      0      0      0 47803595      0      0      0 BMRU
eth2-01    1500   0 25896410      0      0      0 26463622      0      0      0 BMRU
lo        16436   0 265912189      0      0      0 265912189      0      0      0 LRU