-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
# xsos v0.7.7 last mod 2015/12/31 | ||
# xsos v0.7.8 last mod 2015/02/16 | ||
# Latest version at <http://github.com/ryran/xsos> | ||
# RPM packages available at <http://people.redhat.com/rsawhill/rpms> | ||
# Copyright 2012-2015 Ryan Sawhill Aroha <[email protected]> | ||
|
@@ -2198,7 +2198,7 @@ IPADDR() { | |
done | ||
|
||
# Begin ... | ||
echo -e "${c[H1]}IP${c[0]}" | ||
echo -e "${c[H1]}IP$XSOS_IP_VERSION${c[0]}" | ||
|
||
# The bracket here is like using parens to make a subshell -- allows to capture all stdout | ||
{ | ||
|
@@ -2219,7 +2219,7 @@ IPADDR() { | |
|
||
# Figure out if $i is a slave of some bond / bridge device | ||
slaveof[$i]=$( | ||
if grep -q SLAVE <<<"${iface_input[$i]}"; then | ||
if egrep -q 'SLAVE|master' <<<"${iface_input[$i]}"; then | ||
egrep -o 'master [[:graph:]]+' <<<"${iface_input[$i]}" | gawk '{print $2}' | ||
elif [[ -n $brctl_show_input && -n ${lookup_bridge[$i]} ]]; then | ||
echo ${lookup_bridge[$i]} | ||
|
@@ -2528,23 +2528,37 @@ NETDEV() { | |
RxErrs[$1] = $4 | ||
RxDrop[$1] = $5 | ||
RxFifo[$1] = $6 | ||
RxFram[$1] = $7 | ||
RxComp[$1] = $8 | ||
RxMult[$1] = $9 | ||
RxTotal[$1] = $3 + $4 + $5 + $6 + $7 + $8 + $9 | ||
TxBytes[$1] = $10 | ||
TxPackets[$1] = $11 | ||
TxErrs[$1] = $12 | ||
TxDrop[$1] = $13 | ||
TxFifo[$1] = $14 | ||
TxCols[$1] = $15 | ||
TxCarr[$1] = $16 | ||
TxComp[$1] = $17 | ||
TxTotal[$1] = $11 + $12 + $13 + $14 + $15 + $16 + $17 | ||
# Calculate percentages only if rx/tx packets gt 0 | ||
if ($3 > 0) { | ||
if ($4 > 0) RxErrsPercent[$1] = "(" round($4 * 100 / $3, 0) "%)" | ||
if ($5 > 0) RxDropPercent[$1] = "(" round($5 * 100 / $3, 0) "%)" | ||
if ($6 > 0) RxFifoPercent[$1] = "(" round($6 * 100 / $3, 0) "%)" | ||
if (RxTotal[$1] > 0) { | ||
if ($4 > 0) RxErrsPercent[$1] = "(" round($4 * 100 / RxTotal[$1], 0) "%)" | ||
if ($5 > 0) RxDropPercent[$1] = "(" round($5 * 100 / RxTotal[$1], 0) "%)" | ||
if ($6 > 0) RxFifoPercent[$1] = "(" round($6 * 100 / RxTotal[$1], 0) "%)" | ||
if ($7 > 0) RxFramPercent[$1] = "(" round($7 * 100 / RxTotal[$1], 0) "%)" | ||
if ($8 > 0) RxCompPercent[$1] = "(" round($8 * 100 / RxTotal[$1], 0) "%)" | ||
if ($9 > 0) RxMultPercent[$1] = "(" round($9 * 100 / RxTotal[$1], 0) "%)" | ||
} | ||
if ($11 > 0) { | ||
if ($12 > 0) TxErrsPercent[$1] = "(" round($12 * 100 / $11, 0) "%)" | ||
if ($13 > 0) TxDropPercent[$1] = "(" round($13 * 100 / $11, 0) "%)" | ||
if ($15 > 0) TxColsPercent[$1] = "(" round($15 * 100 / $11, 0) "%)" | ||
if (TxTotal[$1] > 0) { | ||
if ($12 > 0) TxErrsPercent[$1] = "(" round($12 * 100 / TxTotal[$1], 0) "%)" | ||
if ($13 > 0) TxDropPercent[$1] = "(" round($13 * 100 / TxTotal[$1], 0) "%)" | ||
if ($14 > 0) TxFifoPercent[$1] = "(" round($14 * 100 / TxTotal[$1], 0) "%)" | ||
if ($15 > 0) TxColsPercent[$1] = "(" round($15 * 100 / TxTotal[$1], 0) "%)" | ||
if ($16 > 0) TxCarrPercent[$1] = "(" round($16 * 100 / TxTotal[$1], 0) "%)" | ||
if ($17 > 0) TxCompPercent[$1] = "(" round($17 * 100 / TxTotal[$1], 0) "%)" | ||
} | ||
# Figure out what number to divide by to end up with KiB, MiB, GiB, or TiB | ||
|
@@ -2600,29 +2614,59 @@ NETDEV() { | |
} | ||
END { | ||
print " Interface❚Rx"U"ytes❚RxPackets❚RxErrs❚RxDrop❚RxFifo❚Tx"U"ytes❚TxPackets❚TxErrs❚TxDrop❚TxColls" | ||
print " =========❚=========❚=========❚======❚======❚======❚=========❚=========❚======❚======❚=======" | ||
print " Interface❚Rx"U"ytes❚RxPackets❚RxErrs❚RxDrop❚RxFifo❚RxComp❚RxFrame❚RxMultCast" | ||
print " =========❚=========❚=========❚======❚======❚======❚======❚=======❚==========" | ||
n = asorti(Interface, IF) | ||
for (i = 1; i <= n; i++) | ||
# printf " %s❚%.0f❚%.0f%s❚%d %s❚%d %s❚%.0f❚%.0f%s❚%d (%.0f%%)❚%d (%.0f%%)\n", | ||
printf " %s❚%s❚%s%s❚%s %s❚%s %s❚%s %s❚%s❚%s%s❚%s %s❚%s %s❚%s %s\n", | ||
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]], | ||
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]] | ||
for (i = 1; i <= n; i++) { | ||
printf " %s❚", IF[i] | ||
printf "%s❚", RxBytes[IF[i]] | ||
printf "%s%s❚", RxPackets[IF[i]], Packets_Unit | ||
printf "%s %s❚", RxErrs[IF[i]], RxErrsPercent[IF[i]] | ||
printf "%s %s❚", RxDrop[IF[i]], RxDropPercent[IF[i]] | ||
printf "%s %s❚", RxFifo[IF[i]], RxFifoPercent[IF[i]] | ||
printf "%s %s❚", RxComp[IF[i]], RxCompPercent[IF[i]] | ||
printf "%s %s❚", RxFram[IF[i]], RxFramPercent[IF[i]] | ||
printf "%s %s", RxMult[IF[i]], RxMultPercent[IF[i]] | ||
printf "\n" | ||
} | ||
print " Interface❚Tx"U"ytes❚TxPackets❚TxErrs❚TxDrop❚TxFifo❚TxComp❚TxColls❚TxCarrier " | ||
print " =========❚=========❚=========❚======❚======❚======❚======❚=======❚==========" | ||
n = asorti(Interface, IF) | ||
for (i = 1; i <= n; i++) { | ||
printf " %s❚", IF[i] | ||
printf "%s❚", TxBytes[IF[i]] | ||
printf "%s%s❚", TxPackets[IF[i]], Packets_Unit | ||
printf "%s %s❚", TxErrs[IF[i]], TxErrsPercent[IF[i]] | ||
printf "%s %s❚", TxDrop[IF[i]], TxDropPercent[IF[i]] | ||
printf "%s %s❚", TxFifo[IF[i]], TxFifoPercent[IF[i]] | ||
printf "%s %s❚", TxComp[IF[i]], TxCompPercent[IF[i]] | ||
printf "%s %s❚", TxCols[IF[i]], TxColsPercent[IF[i]] | ||
printf "%s %s", TxCarr[IF[i]], TxCarrPercent[IF[i]] | ||
printf "\n" | ||
} | ||
} | ||
' | column -ts❚ | | ||
gawk -vH0="${c[0]}" -vH2="${c[H2]}" -vH3="${c[H3]}" ' | ||
gawk -vH0="${c[0]}" -vH2="${c[H2]}" -vH3="${c[H3]}" -vGREY="${c[DGREY]}" ' | ||
{ | ||
if (NR <= 2) print H2 $0 H0 | ||
else printf gensub(/(^ [[:graph:]]+ )/, H3"\\1"H0, 1)"\n" | ||
if (NR <= 2) | ||
print H2 $0 H0 | ||
else if ($1 == "Interface") { | ||
print GREY " - - - - - - - - - - - - - - - - -" H0 | ||
print H2 $0 H0 | ||
} | ||
else if ($1 == "=========") | ||
print H2 $0 H0 | ||
else | ||
printf gensub(/(^ [[:graph:]]+ )/, H3"\\1"H0, 1)"\n" | ||
}' | ||
|
||
# Disabled this cuz ... well, it took up space and I had no evidence that anyone uses it | ||
# if [[ -d $1 ]]; then | ||
# echo -en $XSOS_HEADING_SEPARATOR | ||
# echo -e "${c[H1]}SOCKSTAT${c[0]}" | ||
# gawk -vS=" " -vH3="${c[H3]}" -vH0="${c[0]}" ' | ||
# { printf gensub(/^(.*:)/, S H3"\\1"H0, 1)"\n" }' <"$1/proc/net/sockstat" | ||
# fi | ||
if [[ -d $1 ]]; then | ||
echo -en $XSOS_HEADING_SEPARATOR | ||
echo -e "${c[H1]}SOCKSTAT${c[0]}" | ||
gawk -vS=" " -vH3="${c[H3]}" -vH0="${c[0]}" ' | ||
{ printf gensub(/^(.*:)/, S H3"\\1"H0, 1)"\n" }' <"$1/proc/net/sockstat" | ||
fi | ||
echo -en $XSOS_HEADING_SEPARATOR | ||
} | ||
|
||
|
@@ -2803,6 +2847,10 @@ SYSCTL() { | |
__P net.ipv4.tcp_sack "[bool] " | ||
__P net.ipv4.tcp_timestamps "[bool] " | ||
__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)"}' | ||
__Pa net.ipv4.ipfrag_high_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}' | ||
__Pa net.ipv4.ipfrag_low_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}' | ||
__Pa net.ipv6.ip6frag_high_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}' | ||
__Pa net.ipv6.ip6frag_low_thresh "[bytes] " '{printf "\"%s\"%s (%d KiB)", $1, H0, $1/1024}' | ||
|
||
echo -e "$XSOS_INDENT_H1${c[H2]}vm.${c[0]}" | ||
__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 | |
SOS_CHECKFILE softirq "proc/net/softnet_stat" && SOFTIRQ "$sosroot" | ||
SOS_CHECKFILE netdev "proc/net/dev" && NETDEV "$sosroot" | ||
SOS_CHECKFILE bonding "proc/net/bonding/" && BONDING "$sosroot" | ||
SOS_CHECKFILE ip "sos_commands/networking/ip_address" && IPADDR "$sosroot" | ||
SOS_CHECKFILE ip "sos_commands/networking/ip_address" && { | ||
IPADDR "$sosroot" | ||
XSOS_IP_VERSION=6 | ||
IPADDR "$sosroot"; } | ||
SOS_CHECKFILE sysctl "proc/sys/" && SYSCTL "$sosroot" 2>/dev/null | ||
SOS_CHECKFILE ps "ps" && PSCHECK "$sosroot" | ||
|
||
|
@@ -3191,6 +3242,7 @@ trap "rm -rf $TMPDIR 2>/dev/null" EXIT | |
[[ -n $netdev ]] && NETDEV / | ||
[[ -n $bonding ]] && BONDING / | ||
[[ -n $ip ]] && IPADDR | ||
[[ -n $all ]] && XSOS_IP_VERSION=6 IPADDR | ||
[[ -n $sysctl ]] && SYSCTL / 2>/dev/null | ||
[[ -n $ps ]] && PSCHECK | ||
|
||
|