Skip to content

Commit 4b5298a

Browse files
committed
implement/fix: #183 #196 #197 #195
1 parent 443c23f commit 4b5298a

File tree

1 file changed

+80
-28
lines changed

1 file changed

+80
-28
lines changed

xsos

+80-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# xsos v0.7.7 last mod 2015/12/31
2+
# xsos v0.7.8 last mod 2015/02/16
33
# Latest version at <http://github.com/ryran/xsos>
44
# RPM packages available at <http://people.redhat.com/rsawhill/rpms>
55
# Copyright 2012-2015 Ryan Sawhill Aroha <[email protected]>
@@ -2198,7 +2198,7 @@ IPADDR() {
21982198
done
21992199

22002200
# Begin ...
2201-
echo -e "${c[H1]}IP${c[0]}"
2201+
echo -e "${c[H1]}IP$XSOS_IP_VERSION${c[0]}"
22022202

22032203
# The bracket here is like using parens to make a subshell -- allows to capture all stdout
22042204
{
@@ -2219,7 +2219,7 @@ IPADDR() {
22192219

22202220
# Figure out if $i is a slave of some bond / bridge device
22212221
slaveof[$i]=$(
2222-
if grep -q SLAVE <<<"${iface_input[$i]}"; then
2222+
if egrep -q 'SLAVE|master' <<<"${iface_input[$i]}"; then
22232223
egrep -o 'master [[:graph:]]+' <<<"${iface_input[$i]}" | gawk '{print $2}'
22242224
elif [[ -n $brctl_show_input && -n ${lookup_bridge[$i]} ]]; then
22252225
echo ${lookup_bridge[$i]}
@@ -2528,23 +2528,37 @@ NETDEV() {
25282528
RxErrs[$1] = $4
25292529
RxDrop[$1] = $5
25302530
RxFifo[$1] = $6
2531+
RxFram[$1] = $7
2532+
RxComp[$1] = $8
2533+
RxMult[$1] = $9
2534+
RxTotal[$1] = $3 + $4 + $5 + $6 + $7 + $8 + $9
25312535
TxBytes[$1] = $10
25322536
TxPackets[$1] = $11
25332537
TxErrs[$1] = $12
25342538
TxDrop[$1] = $13
2539+
TxFifo[$1] = $14
25352540
TxCols[$1] = $15
2541+
TxCarr[$1] = $16
2542+
TxComp[$1] = $17
2543+
TxTotal[$1] = $11 + $12 + $13 + $14 + $15 + $16 + $17
25362544
25372545
# Calculate percentages only if rx/tx packets gt 0
25382546
2539-
if ($3 > 0) {
2540-
if ($4 > 0) RxErrsPercent[$1] = "(" round($4 * 100 / $3, 0) "%)"
2541-
if ($5 > 0) RxDropPercent[$1] = "(" round($5 * 100 / $3, 0) "%)"
2542-
if ($6 > 0) RxFifoPercent[$1] = "(" round($6 * 100 / $3, 0) "%)"
2547+
if (RxTotal[$1] > 0) {
2548+
if ($4 > 0) RxErrsPercent[$1] = "(" round($4 * 100 / RxTotal[$1], 0) "%)"
2549+
if ($5 > 0) RxDropPercent[$1] = "(" round($5 * 100 / RxTotal[$1], 0) "%)"
2550+
if ($6 > 0) RxFifoPercent[$1] = "(" round($6 * 100 / RxTotal[$1], 0) "%)"
2551+
if ($7 > 0) RxFramPercent[$1] = "(" round($7 * 100 / RxTotal[$1], 0) "%)"
2552+
if ($8 > 0) RxCompPercent[$1] = "(" round($8 * 100 / RxTotal[$1], 0) "%)"
2553+
if ($9 > 0) RxMultPercent[$1] = "(" round($9 * 100 / RxTotal[$1], 0) "%)"
25432554
}
2544-
if ($11 > 0) {
2545-
if ($12 > 0) TxErrsPercent[$1] = "(" round($12 * 100 / $11, 0) "%)"
2546-
if ($13 > 0) TxDropPercent[$1] = "(" round($13 * 100 / $11, 0) "%)"
2547-
if ($15 > 0) TxColsPercent[$1] = "(" round($15 * 100 / $11, 0) "%)"
2555+
if (TxTotal[$1] > 0) {
2556+
if ($12 > 0) TxErrsPercent[$1] = "(" round($12 * 100 / TxTotal[$1], 0) "%)"
2557+
if ($13 > 0) TxDropPercent[$1] = "(" round($13 * 100 / TxTotal[$1], 0) "%)"
2558+
if ($14 > 0) TxFifoPercent[$1] = "(" round($14 * 100 / TxTotal[$1], 0) "%)"
2559+
if ($15 > 0) TxColsPercent[$1] = "(" round($15 * 100 / TxTotal[$1], 0) "%)"
2560+
if ($16 > 0) TxCarrPercent[$1] = "(" round($16 * 100 / TxTotal[$1], 0) "%)"
2561+
if ($17 > 0) TxCompPercent[$1] = "(" round($17 * 100 / TxTotal[$1], 0) "%)"
25482562
}
25492563
25502564
# Figure out what number to divide by to end up with KiB, MiB, GiB, or TiB
@@ -2600,29 +2614,59 @@ NETDEV() {
26002614
}
26012615
26022616
END {
2603-
print " Interface❚Rx"U"ytes❚RxPackets❚RxErrs❚RxDrop❚RxFifo❚Tx"U"ytes❚TxPackets❚TxErrs❚TxDrop❚TxColls"
2604-
print " =========❚=========❚=========❚======❚======❚======❚=========❚=========❚======❚======❚======="
2617+
print " Interface❚Rx"U"ytes❚RxPackets❚RxErrs❚RxDrop❚RxFifo❚RxComp❚RxFrame❚RxMultCast"
2618+
print " =========❚=========❚=========❚======❚======❚======❚======❚=======❚=========="
26052619
n = asorti(Interface, IF)
2606-
for (i = 1; i <= n; i++)
2607-
# printf " %s❚%.0f❚%.0f%s❚%d %s❚%d %s❚%.0f❚%.0f%s❚%d (%.0f%%)❚%d (%.0f%%)\n",
2608-
printf " %s❚%s❚%s%s❚%s %s❚%s %s❚%s %s❚%s❚%s%s❚%s %s❚%s %s❚%s %s\n",
2609-
IF[i], RxBytes[IF[i]], RxPackets[IF[i]], Packets_Unit, RxErrs[IF[i]], RxErrsPercent[IF[i]], RxDrop[IF[i]], RxDropPercent[IF[i]], RxFifo[IF[i]], RxFifoPercent[IF[i]],
2610-
TxBytes[IF[i]], TxPackets[IF[i]], Packets_Unit, TxErrs[IF[i]], TxErrsPercent[IF[i]], TxDrop[IF[i]], TxDropPercent[IF[i]], TxCols[IF[i]], TxColsPercent[IF[i]]
2620+
for (i = 1; i <= n; i++) {
2621+
printf " %s❚", IF[i]
2622+
printf "%s❚", RxBytes[IF[i]]
2623+
printf "%s%s❚", RxPackets[IF[i]], Packets_Unit
2624+
printf "%s %s❚", RxErrs[IF[i]], RxErrsPercent[IF[i]]
2625+
printf "%s %s❚", RxDrop[IF[i]], RxDropPercent[IF[i]]
2626+
printf "%s %s❚", RxFifo[IF[i]], RxFifoPercent[IF[i]]
2627+
printf "%s %s❚", RxComp[IF[i]], RxCompPercent[IF[i]]
2628+
printf "%s %s❚", RxFram[IF[i]], RxFramPercent[IF[i]]
2629+
printf "%s %s", RxMult[IF[i]], RxMultPercent[IF[i]]
2630+
printf "\n"
2631+
}
2632+
print " Interface❚Tx"U"ytes❚TxPackets❚TxErrs❚TxDrop❚TxFifo❚TxComp❚TxColls❚TxCarrier "
2633+
print " =========❚=========❚=========❚======❚======❚======❚======❚=======❚=========="
2634+
n = asorti(Interface, IF)
2635+
for (i = 1; i <= n; i++) {
2636+
printf " %s❚", IF[i]
2637+
printf "%s❚", TxBytes[IF[i]]
2638+
printf "%s%s❚", TxPackets[IF[i]], Packets_Unit
2639+
printf "%s %s❚", TxErrs[IF[i]], TxErrsPercent[IF[i]]
2640+
printf "%s %s❚", TxDrop[IF[i]], TxDropPercent[IF[i]]
2641+
printf "%s %s❚", TxFifo[IF[i]], TxFifoPercent[IF[i]]
2642+
printf "%s %s❚", TxComp[IF[i]], TxCompPercent[IF[i]]
2643+
printf "%s %s❚", TxCols[IF[i]], TxColsPercent[IF[i]]
2644+
printf "%s %s", TxCarr[IF[i]], TxCarrPercent[IF[i]]
2645+
printf "\n"
2646+
}
26112647
}
26122648
' | column -ts❚ |
2613-
gawk -vH0="${c[0]}" -vH2="${c[H2]}" -vH3="${c[H3]}" '
2649+
gawk -vH0="${c[0]}" -vH2="${c[H2]}" -vH3="${c[H3]}" -vGREY="${c[DGREY]}" '
26142650
{
2615-
if (NR <= 2) print H2 $0 H0
2616-
else printf gensub(/(^ [[:graph:]]+ )/, H3"\\1"H0, 1)"\n"
2651+
if (NR <= 2)
2652+
print H2 $0 H0
2653+
else if ($1 == "Interface") {
2654+
print GREY " - - - - - - - - - - - - - - - - -" H0
2655+
print H2 $0 H0
2656+
}
2657+
else if ($1 == "=========")
2658+
print H2 $0 H0
2659+
else
2660+
printf gensub(/(^ [[:graph:]]+ )/, H3"\\1"H0, 1)"\n"
26172661
}'
26182662

26192663
# Disabled this cuz ... well, it took up space and I had no evidence that anyone uses it
2620-
# if [[ -d $1 ]]; then
2621-
# echo -en $XSOS_HEADING_SEPARATOR
2622-
# echo -e "${c[H1]}SOCKSTAT${c[0]}"
2623-
# gawk -vS=" " -vH3="${c[H3]}" -vH0="${c[0]}" '
2624-
# { printf gensub(/^(.*:)/, S H3"\\1"H0, 1)"\n" }' <"$1/proc/net/sockstat"
2625-
# fi
2664+
if [[ -d $1 ]]; then
2665+
echo -en $XSOS_HEADING_SEPARATOR
2666+
echo -e "${c[H1]}SOCKSTAT${c[0]}"
2667+
gawk -vS=" " -vH3="${c[H3]}" -vH0="${c[0]}" '
2668+
{ printf gensub(/^(.*:)/, S H3"\\1"H0, 1)"\n" }' <"$1/proc/net/sockstat"
2669+
fi
26262670
echo -en $XSOS_HEADING_SEPARATOR
26272671
}
26282672

@@ -2803,6 +2847,10 @@ SYSCTL() {
28032847
__P net.ipv4.tcp_sack "[bool] "
28042848
__P net.ipv4.tcp_timestamps "[bool] "
28052849
__Pa net.ipv4.tcp_fastopen "[bitmap] " '{printf "\"%s\"%s (", $1, H0; if ($1==0) printf "disabled"; else if ($1==1) printf "enable send"; else if ($1==2) printf "enable receive"; else if ($1==3 || $1==7) printf "enable send/receive"; else if ($1==4) printf "invalid value"; else printf "no logic for higher values"; if ($1==7) printf " + send regardless of cookies"; printf "; see ip-sysctl.txt)"}'
2850+
__Pa net.ipv4.ipfrag_high_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}'
2851+
__Pa net.ipv4.ipfrag_low_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}'
2852+
__Pa net.ipv6.ip6frag_high_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}'
2853+
__Pa net.ipv6.ip6frag_low_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}'
28062854

28072855
echo -e "$XSOS_INDENT_H1${c[H2]}vm.${c[0]}"
28082856
__Pa vm.dirty_ratio "" '{if ($1>0) printf "\"%s\"%s (%% of total system memory)", $1, H0; else printf "\"0\"%s (disabled -- check dirty_bytes)", H0}'
@@ -3171,7 +3219,10 @@ trap "rm -rf $TMPDIR 2>/dev/null" EXIT
31713219
SOS_CHECKFILE softirq "proc/net/softnet_stat" && SOFTIRQ "$sosroot"
31723220
SOS_CHECKFILE netdev "proc/net/dev" && NETDEV "$sosroot"
31733221
SOS_CHECKFILE bonding "proc/net/bonding/" && BONDING "$sosroot"
3174-
SOS_CHECKFILE ip "sos_commands/networking/ip_address" && IPADDR "$sosroot"
3222+
SOS_CHECKFILE ip "sos_commands/networking/ip_address" && {
3223+
IPADDR "$sosroot"
3224+
XSOS_IP_VERSION=6
3225+
IPADDR "$sosroot"; }
31753226
SOS_CHECKFILE sysctl "proc/sys/" && SYSCTL "$sosroot" 2>/dev/null
31763227
SOS_CHECKFILE ps "ps" && PSCHECK "$sosroot"
31773228

@@ -3191,6 +3242,7 @@ trap "rm -rf $TMPDIR 2>/dev/null" EXIT
31913242
[[ -n $netdev ]] && NETDEV /
31923243
[[ -n $bonding ]] && BONDING /
31933244
[[ -n $ip ]] && IPADDR
3245+
[[ -n $all ]] && XSOS_IP_VERSION=6 IPADDR
31943246
[[ -n $sysctl ]] && SYSCTL / 2>/dev/null
31953247
[[ -n $ps ]] && PSCHECK
31963248

0 commit comments

Comments
 (0)