From ce9dada330ff27dfa26662298d4600ee164197ee Mon Sep 17 00:00:00 2001 From: Michael Erdely Date: Mon, 3 Feb 2025 18:08:38 -0500 Subject: [PATCH] Fix alignment and fix packages for Arch Linux Changes: * Align columns with "column -t" * Add Arch Linux support in packages.sh --- VERSION | 4 ++-- app.manifest | 2 +- bin/bandwidth.sh | 4 +++- bin/cpu.sh | 6 ++++-- bin/cpu_metric.sh | 6 ++++-- bin/df.sh | 4 +++- bin/df_metric.sh | 4 +++- bin/interfaces.sh | 43 +++++++++++++++++++++++----------------- bin/interfaces_metric.sh | 35 +++++++++++++++++++------------- bin/iostat.sh | 6 ++++-- bin/iostat_metric.sh | 6 ++++-- bin/nfsiostat.sh | 2 ++ bin/package.sh | 9 ++++++++- bin/protocol.sh | 4 +++- bin/vmstat.sh | 4 +++- bin/vmstat_metric.sh | 4 +++- default/app.conf | 4 ++-- docs/ReleaseNotes.md | 9 +++++++++ 18 files changed, 104 insertions(+), 52 deletions(-) diff --git a/VERSION b/VERSION index c5a3754..e4b0645 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -9.2.0.12 -9.2.0.12 +9.2.0.13 +9.2.0.13 diff --git a/app.manifest b/app.manifest index 03e205f..d8b132e 100644 --- a/app.manifest +++ b/app.manifest @@ -29,7 +29,7 @@ "id": { "group": null, "name": "TA-nix", - "version": "9.2.0.12" + "version": "9.2.0.13" }, "license": { "name": "Splunk Software License Agreement", diff --git a/bin/bandwidth.sh b/bin/bandwidth.sh index 7499478..671268c 100755 --- a/bin/bandwidth.sh +++ b/bin/bandwidth.sh @@ -7,6 +7,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='Name rxPackets_PS txPackets_PS rxKB_PS txKB_PS' HEADERIZE="BEGIN {print \"$HEADER\"}" PRINTF='{printf "%s %s %s %s %s\n", Name, rxPackets_PS, txPackets_PS, rxKB_PS, txKB_PS}' @@ -92,6 +94,6 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then fi assertHaveCommand "$CMD" -$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FILTER $FORMAT $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FILTER $FORMAT $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK '$HEADERIZE $FILTER $FORMAT $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" # jscpd:ignore-end diff --git a/bin/cpu.sh b/bin/cpu.sh index 0ef0782..92f6698 100755 --- a/bin/cpu.sh +++ b/bin/cpu.sh @@ -5,6 +5,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='CPU pctUser pctNice pctSystem pctIowait pctIdle' HEADERIZE="BEGIN {print \"$HEADER\"}" PRINTF='{printf "%-3s %9s %9s %9s %9s %9s\n", cpu, pctUser, pctNice, pctSystem, pctIowait, pctIdle}' @@ -120,7 +122,7 @@ elif [ "$KERNEL" = "AIX" ] ; then print ""; }' fi - $CMD | tee "$TEE_DEST" | $AWK $DEFINE "$FORMAT" + $CMD | tee "$TEE_DEST" | $AWK $DEFINE "$FORMAT" | column -t echo "Cmd = [$CMD]; | $AWK $DEFINE '$FORMAT'" >> "$TEE_DEST" exit elif [ "$KERNEL" = "Darwin" ] ; then @@ -198,5 +200,5 @@ elif [ "$KERNEL" = "HP-UX" ] ; then FORMAT='{k=0; if(5> "$TEE_DEST" diff --git a/bin/cpu_metric.sh b/bin/cpu_metric.sh index 9e293f1..7f14e60 100755 --- a/bin/cpu_metric.sh +++ b/bin/cpu_metric.sh @@ -6,6 +6,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='CPU pctUser pctNice pctSystem pctIowait pctIdle OSName OS_version IP_address' HEADERIZE="BEGIN {print \"$HEADER\"}" PRINTF='{printf "%-3s %9s %9s %9s %9s %9s %-35s %15s %-16s\n", cpu, pctUser, pctNice, pctSystem, pctIowait, pctIdle, OSName, OS_version, IP_address}' @@ -137,7 +139,7 @@ elif [ "$KERNEL" = "AIX" ] ; then print ""; }' fi - $CMD | tee "$TEE_DEST" | $AWK $DEFINE $DEFINE_LPARSTAT_FIELDS "$FORMAT $FILL_DIMENSIONS" + $CMD | tee "$TEE_DEST" | $AWK $DEFINE $DEFINE_LPARSTAT_FIELDS "$FORMAT $FILL_DIMENSIONS" | column -t echo "Cmd = [$CMD]; | $AWK $DEFINE $DEFINE_LPARSTAT_FIELDS '$FORMAT $FILL_DIMENSIONS'" >>"$TEE_DEST" exit elif [ "$KERNEL" = "Darwin" ] ; then @@ -228,5 +230,5 @@ elif [ "$KERNEL" = "HP-UX" ] ; then FORMAT='{k=0; if(5>"$TEE_DEST" diff --git a/bin/df.sh b/bin/df.sh index e2998d3..6c191ef 100755 --- a/bin/df.sh +++ b/bin/df.sh @@ -6,6 +6,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + # jscpd:ignore-start if [ "$KERNEL" = "Linux" ] ; then assertHaveCommand df @@ -310,5 +312,5 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then fi # jscpd:ignore-end -$CMD | tee "$TEE_DEST" | $AWK "$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK "$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK '$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" diff --git a/bin/df_metric.sh b/bin/df_metric.sh index cb79d07..be4314a 100755 --- a/bin/df_metric.sh +++ b/bin/df_metric.sh @@ -6,6 +6,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + # shellcheck disable=SC2016 FILL_DIMENSIONS='{length(IP_address) || IP_address = "?";length(OS_version) || OS_version = "?";length(OSName) || OSName = "?";length(IPv6_Address) || IPv6_Address = "?"}' @@ -346,5 +348,5 @@ fi # jscpd:ignore-end # shellcheck disable=SC2086 -$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $FILL_DIMENSIONS $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $FILL_DIMENSIONS $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK $DEFINE '$BEGIN $HEADERIZE $FILTER_PRE $MAP_FS_TO_TYPE $FORMAT $FILTER_POST $NORMALIZE $FILL_DIMENSIONS $PRINTF' header=\"$HEADER\"" >>"$TEE_DEST" diff --git a/bin/interfaces.sh b/bin/interfaces.sh index dc37dd1..2177c7c 100755 --- a/bin/interfaces.sh +++ b/bin/interfaces.sh @@ -6,15 +6,17 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh -HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors TXbytes TXerrors Speed Duplex' +#HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors TXbytes TXerrors Speed Duplex' +HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors RXdropped TXbytes TXerrors TXdropped Speed Duplex' FORMAT='{mac = length(mac) ? mac : "?"; collisions = length(collisions) ? collisions : "?"; RXbytes = length(RXbytes) ? RXbytes : "?"; RXerrors = length(RXerrors) ? RXerrors : "?"; TXbytes = length(TXbytes) ? TXbytes : "?"; TXerrors = length(TXerrors) ? TXerrors : "?"; speed = length(speed) ? speed : "?"; duplex = length(duplex) ? duplex : "?"}' -PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-16s %-16s %-12s %-12s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, TXbytes, TXerrors, speed, duplex}' +#PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-16s %-16s %-12s %-12s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, TXbytes, TXerrors, speed, duplex}' +PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-18s %-16s %-16s %-18s %-12s %-12s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, (RXdropped == "") ? 0 : RXdropped, TXbytes, TXerrors, (TXdropped == "") ? 0 : TXdropped, speed, duplex}' if [ "$KERNEL" = "Linux" ] ; then OS_FILE=/etc/os-release - HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors RXdropped TXbytes TXerrors TXdropped Speed Duplex' - PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-18s %-16s %-16s %-18s %-12s %-12s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, RXdropped, TXbytes, TXerrors, TXdropped, speed, duplex}' + #HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors RXdropped TXbytes TXerrors TXdropped Speed Duplex' + #PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-18s %-16s %-16s %-18s %-12s %-12s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, RXdropped, TXbytes, TXerrors, TXdropped, speed, duplex}' queryHaveCommand ip FOUND_IP=$? if [ $FOUND_IP -eq 0 ]; then @@ -253,7 +255,7 @@ if [ "$KERNEL" = "Linux" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do @@ -322,12 +324,13 @@ if [ "$KERNEL" = "Linux" ] ; then GET_MAC='{if ($0 ~ /ether /) { mac = $2; } else if ( NR == 1 ) { mac = $5; }}' fi if [ "$DUPLEX" != 'error' ] && [ "$SPEED" != 'error' ]; then - $CMD "$iface" | tee -a "$TEE_DEST" | awk "$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF" name="$iface" speed="$SPEED" duplex="$DUPLEX" mac="$MAC" + output="$output$($CMD "$iface" | tee -a "$TEE_DEST" | awk "$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF" name="$iface" speed="$SPEED" duplex="$DUPLEX" mac="$MAC")\n" echo "Cmd = [$CMD $iface]; | awk '$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF' name=$iface speed=$SPEED duplex=$DUPLEX mac=$MAC" >> "$TEE_DEST" else echo "ERROR: cat command failed for interface $iface" >> "$TEE_DEST" fi done + printf "$output" | column -t elif [ "$KERNEL" = "SunOS" ] ; then assertHaveCommandGivenPath /usr/sbin/ifconfig @@ -346,7 +349,7 @@ elif [ "$KERNEL" = "SunOS" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do @@ -358,9 +361,10 @@ elif [ "$KERNEL" = "SunOS" ] ; then else CMD_DESCRIBE_INTERFACE="eval kstat -n $iface ; /usr/sbin/ifconfig $iface 2>/dev/null" fi - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | $AWK '$GET_ALL $FORMAT $PRINTF' name=$iface node=$NODE" >> "$TEE_DEST" done + printf "$output" | column -t elif [ "$KERNEL" = "AIX" ] ; then assertHaveCommandGivenPath /usr/sbin/ifconfig assertHaveCommandGivenPath /usr/bin/netstat @@ -378,16 +382,17 @@ elif [ "$KERNEL" = "AIX" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do echo "Cmd = [$CMD_LIST_INTERFACES]" >> "$TEE_DEST" NODE=$(uname -n) CMD_DESCRIBE_INTERFACE="eval netstat -v $iface ; /usr/sbin/ifconfig $iface" - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | $AWK '$GET_ALL $FORMAT $PRINTF' name=$iface node=$NODE" >> "$TEE_DEST" done + printf "$output" elif [ "$KERNEL" = "Darwin" ] ; then assertHaveCommand ifconfig assertHaveCommand netstat @@ -437,15 +442,16 @@ elif [ "$KERNEL" = "Darwin" ] ; then out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do echo "Cmd = [$CMD_LIST_INTERFACES]; | awk '$CHOOSE_ACTIVE' | $UNIQUE" >> "$TEE_DEST" CMD_DESCRIBE_INTERFACE="eval ifconfig $iface ; netstat -b -I $iface" - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk "$GET_ALL $PRINTF" name="$iface" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk "$GET_ALL $PRINTF" name="$iface")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | awk '$GET_ALL $PRINTF' name=$iface" >> "$TEE_DEST" done + printf "$output" | column -t elif [ "$KERNEL" = "HP-UX" ] ; then assertHaveCommand ifconfig assertHaveCommand lanadmin @@ -466,8 +472,7 @@ elif [ "$KERNEL" = "HP-UX" ] ; then out=$($CMD | awk "$LANSCAN_AWK $GET_IP4 $GET_IP6 $GET_SPEED_DUPLEX $PRINTF $FILL_BLANKS") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" - echo "$out" + printf "$HEADER\n$out\n" fi elif [ "$KERNEL" = "OpenBSD" ] ; then assertHaveCommand ifconfig @@ -484,12 +489,13 @@ elif [ "$KERNEL" = "OpenBSD" ] ; then out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do - echo "$iface $(ifconfig $iface | awk "$GET_MAC $GET_IP END {printf \"%s %s %s\", mac, IPv4, IPv6}") $(echo $(netstat -bnI $iface -w1 | head -n4 | tail -n1) $(netstat -neI $iface -w1 | head -n4 | tail -n1) | awk "{printf \"%s %s %s %s %s\", \$9, \$1, \$6, \$2, \$8}") auto auto" + output="$output$iface $(ifconfig $iface | awk "$GET_MAC $GET_IP END {printf \"%s %s %s\", mac, IPv4, IPv6}") $(echo $(netstat -bnI $iface -w1 | head -n4 | tail -n1) $(netstat -neI $iface -w1 | head -n4 | tail -n1) | awk "{printf \"%s %s %s %s %s %s %s\", \$9, \$1, 0, \$6, \$2, \$8, 0}") auto auto\n" done + printf "$output" | column -t elif [ "$KERNEL" = "FreeBSD" ] ; then assertHaveCommand ifconfig assertHaveCommand netstat @@ -536,14 +542,15 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do echo "Cmd = [$CMD_LIST_INTERFACES]; | awk '$CHOOSE_ACTIVE' | $UNIQUE" >> "$TEE_DEST" CMD_DESCRIBE_INTERFACE="eval ifconfig $iface ; netstat -b -I $iface" - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk "$GET_ALL $PRINTF" name="$iface" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk "$GET_ALL $PRINTF" name="$iface")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | awk '$GET_ALL $PRINTF' name=$iface" >> "$TEE_DEST" done + printf "$output" | column -t fi # jscpd:ignore-end diff --git a/bin/interfaces_metric.sh b/bin/interfaces_metric.sh index 017d1c8..b909c7a 100755 --- a/bin/interfaces_metric.sh +++ b/bin/interfaces_metric.sh @@ -7,6 +7,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='Name MAC inetAddr inet6Addr Collisions RXbytes RXerrors TXbytes TXerrors Speed Duplex OSName OS_version IP_address IPv6_Address' FORMAT='{mac = length(mac) ? mac : "?"; collisions = length(collisions) ? collisions : "?"; RXbytes = length(RXbytes) ? RXbytes : "?"; RXerrors = length(RXerrors) ? RXerrors : "?"; TXbytes = length(TXbytes) ? TXbytes : "?"; TXerrors = length(TXerrors) ? TXerrors : "?"; speed = length(speed) ? speed : "?"; duplex = length(duplex) ? duplex : "?"}' PRINTF='END {printf "%-10s %-17s %-15s %-42s %-10s %-16s %-16s %-16s %-16s %-12s %-12s %-35s %15s %-16s %-42s\n", name, mac, IPv4, IPv6, collisions, RXbytes, RXerrors, TXbytes, TXerrors, speed, duplex, OSName, OS_version, IP_address, IPv6_Address}' @@ -260,7 +262,7 @@ if [ "$KERNEL" = "Linux" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do @@ -325,12 +327,13 @@ if [ "$KERNEL" = "Linux" ] ; then fi if [ "$DUPLEX" != 'error' ] && [ "$SPEED" != 'error' ]; then # shellcheck disable=SC2086 - $CMD "$iface" | tee -a "$TEE_DEST" | awk $DEFINE "$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF" name="$iface" speed="$SPEED" duplex="$DUPLEX" mac="$MAC" + output="$output$($CMD "$iface" | tee -a "$TEE_DEST" | awk $DEFINE "$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF" name="$iface" speed="$SPEED" duplex="$DUPLEX" mac="$MAC")\n" echo "Cmd = [$CMD $iface]; | awk $DEFINE '$BEGIN $GET_MAC $GET_ALL $FILL_BLANKS $PRINTF' name=$iface speed=$SPEED duplex=$DUPLEX mac=$MAC" >> "$TEE_DEST" else echo "ERROR: cat command failed for interface $iface" >> "$TEE_DEST" fi done + printf "$output" | column -t elif [ "$KERNEL" = "SunOS" ] ; then assertHaveCommandGivenPath /usr/sbin/ifconfig @@ -352,7 +355,7 @@ elif [ "$KERNEL" = "SunOS" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do @@ -365,9 +368,10 @@ elif [ "$KERNEL" = "SunOS" ] ; then CMD_DESCRIBE_INTERFACE="eval kstat -n $iface ; /usr/sbin/ifconfig $iface 2>/dev/null" fi # shellcheck disable=SC2086 - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK $DEFINE "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK $DEFINE "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | $AWK $DEFINE '$GET_ALL $FORMAT $PRINTF' name=$iface node=$NODE" >> "$TEE_DEST" done + printf "$output" | column -t elif [ "$KERNEL" = "AIX" ] ; then assertHaveCommandGivenPath /usr/sbin/ifconfig assertHaveCommandGivenPath /usr/bin/netstat @@ -389,7 +393,7 @@ elif [ "$KERNEL" = "AIX" ] ; then out=$($CMD_LIST_INTERFACES) lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do @@ -397,9 +401,10 @@ elif [ "$KERNEL" = "AIX" ] ; then NODE=$(uname -n) CMD_DESCRIBE_INTERFACE="eval netstat -v $iface ; /usr/sbin/ifconfig $iface" # shellcheck disable=SC2086 - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK $DEFINE "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | $AWK $DEFINE "$GET_ALL $FORMAT $PRINTF" name="$iface" node="$NODE")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | $AWK $DEFINE '$GET_ALL $FORMAT $PRINTF' name=$iface node=$NODE" >> "$TEE_DEST" done + printf "$output" | column -t elif [ "$KERNEL" = "Darwin" ] ; then assertHaveCommand ifconfig assertHaveCommand netstat @@ -451,16 +456,17 @@ elif [ "$KERNEL" = "Darwin" ] ; then out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do echo "Cmd = [$CMD_LIST_INTERFACES]; | awk '$CHOOSE_ACTIVE' | $UNIQUE" >> "$TEE_DEST" CMD_DESCRIBE_INTERFACE="eval ifconfig $iface ; netstat -b -I $iface" # shellcheck disable=SC2086 - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk $DEFINE "$GET_ALL $PRINTF" name="$iface" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk $DEFINE "$GET_ALL $PRINTF" name="$iface")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | awk $DEFINE '$GET_ALL $PRINTF' name=$iface" >> "$TEE_DEST" done + printf "$output" | column -t elif [ "$KERNEL" = "HP-UX" ] ; then assertHaveCommand ifconfig assertHaveCommand lanadmin @@ -482,8 +488,7 @@ elif [ "$KERNEL" = "HP-UX" ] ; then out=$($CMD | awk "$LANSCAN_AWK $GET_IP4 $GET_IP6 $GET_SPEED_DUPLEX $PRINTF $FILL_BLANKS") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" - echo "$out" + printf "$HEADER\n$out\n" | column -t fi elif [ "$KERNEL" = "OpenBSD" ] ; then assertHaveCommand ifconfig @@ -503,12 +508,13 @@ elif [ "$KERNEL" = "OpenBSD" ] ; then IP4=$(ifconfig $INT | awk '$1=="inet"{print $2;p=1;exit}END{if (p!=1) print ""}') IP6=$(ifconfig $INT | awk '$1=="inet6" && $2!~/%vio0$/{print $2;p=1;exit}END{if (p!=1) print ""}') if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do - echo "$iface $(ifconfig $iface | awk "$GET_MAC $GET_IP END {printf \"%s %s %s\", mac, IPv4, IPv6}") $(echo $(netstat -bnI $iface -w1 | head -n4 | tail -n1) $(netstat -neI $iface -w1 | head -n4 | tail -n1) | awk "{printf \"%s %s %s %s %s\", \$9, \$1, \$6, \$2, \$8}") auto auto $(uname -s) $(uname -r) $IP4 $IP6" + output="$output"$iface $(ifconfig $iface | awk "$GET_MAC $GET_IP END {printf \"%s %s %s\", mac, IPv4, IPv6}") $(echo $(netstat -bnI $iface -w1 | head -n4 | tail -n1) $(netstat -neI $iface -w1 | head -n4 | tail -n1) | awk "{printf \"%s %s %s %s %s\", \$9, \$1, \$6, \$2, \$8}") auto auto $(uname -s) $(uname -r) $IP4 $IP6\n" done + printf "$output" | column -t elif [ "$KERNEL" = "FreeBSD" ] ; then assertHaveCommand ifconfig assertHaveCommand netstat @@ -558,15 +564,16 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then out=$($CMD_LIST_INTERFACES | tee "$TEE_DEST" | awk "$CHOOSE_ACTIVE" | $UNIQUE | tee -a "$TEE_DEST") lines=$(echo "$out" | wc -l) if [ "$lines" -gt 0 ]; then - echo "$HEADER" + output="$HEADER\n" fi for iface in $out do echo "Cmd = [$CMD_LIST_INTERFACES]; | awk '$CHOOSE_ACTIVE' | $UNIQUE" >> "$TEE_DEST" CMD_DESCRIBE_INTERFACE="eval ifconfig $iface ; netstat -b -I $iface" # shellcheck disable=SC2086 - $CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk $DEFINE "$GET_ALL $PRINTF" name="$iface" + output="$output$($CMD_DESCRIBE_INTERFACE | tee -a "$TEE_DEST" | awk $DEFINE "$GET_ALL $PRINTF" name="$iface")\n" echo "Cmd = [$CMD_DESCRIBE_INTERFACE]; | awk $DEFINE '$GET_ALL $PRINTF' name=$iface" >> "$TEE_DEST" done + printf "$output" | column -t fi # jscpd:ignore-end diff --git a/bin/iostat.sh b/bin/iostat.sh index a0c57e8..3f977df 100755 --- a/bin/iostat.sh +++ b/bin/iostat.sh @@ -7,6 +7,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + if [ "$KERNEL" = "Linux" ] ; then CMD='iostat -xky 1 1' assertHaveCommand "$CMD" @@ -49,10 +51,10 @@ elif [ "$KERNEL" = "Darwin" ] ; then LATENCY='function getLatency(disk) {read=getDeltaPS(disk,"Latency Time (Read)"); write=getDeltaPS(disk,"Latency Time (Write)"); return expr read + write;}' FUNC2='function getAllDeltasPS(disk) {rReq_PS=getDeltaPS(disk,"Operations (Read)"); wReq_PS=getDeltaPS(disk,"Operations (Write)"); rKB_PS=getDeltaPS(disk,"Bytes (Read)")/1024; wKB_PS=getDeltaPS(disk,"Bytes (Write)")/1024; avgWaitMillis=getLatency(disk);}' SCRIPT="$HEADERIZE $FILTER $FUNC1 $LATENCY $FUNC2 END {$FORMAT for (device in devices) {getAllDeltasPS(device); $PRINTF}}" - $CMD | tee "$TEE_DEST" | awk "$SCRIPT" header="$HEADER" + $CMD | tee "$TEE_DEST" | awk "$SCRIPT" header="$HEADER" | column -t echo "Cmd = [$CMD]; | awk '$SCRIPT' header=\"$HEADER\"" >> "$TEE_DEST" exit 0 fi -$CMD | tee "$TEE_DEST" | $AWK "$FILTER" +$CMD | tee "$TEE_DEST" | $AWK "$FILTER" | column -t echo "Cmd = [$CMD]; | $AWK '$FILTER'" >> "$TEE_DEST" diff --git a/bin/iostat_metric.sh b/bin/iostat_metric.sh index c171424..0680c86 100755 --- a/bin/iostat_metric.sh +++ b/bin/iostat_metric.sh @@ -8,6 +8,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + if [ "$KERNEL" = "Linux" ] ; then CMD='iostat -xky 1 1' assertHaveCommand "$CMD" @@ -66,10 +68,10 @@ elif [ "$KERNEL" = "Darwin" ] ; then FUNC2='function getAllDeltasPS(disk) {rReq_PS=getDeltaPS(disk,"Operations (Read)"); wReq_PS=getDeltaPS(disk,"Operations (Write)"); rKB_PS=getDeltaPS(disk,"Bytes (Read)")/1024; wKB_PS=getDeltaPS(disk,"Bytes (Write)")/1024; avgWaitMillis=getLatency(disk);}' SCRIPT="$HEADERIZE $FILTER $FUNC1 $LATENCY $FUNC2 END {$FORMAT for (device in devices) {getAllDeltasPS(device); $PRINTF}}" # shellcheck disable=SC2086 - $CMD | tee "$TEE_DEST" | awk $DEFINE "$SCRIPT" header="$HEADER" + $CMD | tee "$TEE_DEST" | awk $DEFINE "$SCRIPT" header="$HEADER" | column -t echo "Cmd = [$CMD]; | awk $DEFINE '$SCRIPT' header=\"$HEADER\"" >> "$TEE_DEST" exit 0 fi # shellcheck disable=SC2086 -$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$FILTER $PRINTF" +$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$FILTER $PRINTF" | column -t echo "Cmd = [$CMD]; | $AWK $DEFINE '$FILTER'" >> "$TEE_DEST" diff --git a/bin/nfsiostat.sh b/bin/nfsiostat.sh index fd32002..bc97af0 100755 --- a/bin/nfsiostat.sh +++ b/bin/nfsiostat.sh @@ -5,6 +5,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='Mount Path r_op/s w_op/s r_KB/s w_KB/s rpc_backlog r_avg_RTT w_avg_RTT r_avg_exe w_avg_exe' HEADERIZE="BEGIN {print \"$HEADER\"}" diff --git a/bin/package.sh b/bin/package.sh index ddccd69..1e0809e 100755 --- a/bin/package.sh +++ b/bin/package.sh @@ -5,12 +5,15 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + HEADER='NAME VERSION RELEASE ARCH VENDOR GROUP' HEADERIZE="BEGIN {print \"$HEADER\"}" PRINTF='{printf "%-55.55s %-20.20s %-20.20s %-10.10s %-30.30s %-20s\n", name, version, release, arch, vendor, group}' CMD='echo There is no flavor-independent command...' if [ "$KERNEL" = "Linux" ] ; then + OSName=$(cat /etc/*release | grep '\bNAME=' | cut -d '=' -f2 | tr ' ' '_' | cut -d\" -f2) if $DEBIAN; then CMD1="eval dpkg-query -W -f='" # shellcheck disable=SC2016 @@ -19,6 +22,10 @@ if [ "$KERNEL" = "Linux" ] ; then CMD=$CMD1$CMD2$CMD3 # shellcheck disable=SC2016 FORMAT='{name=$1;version=$2;sub("\\.?[^0-9\\.:\\-].*$", "", version); release=$2; sub("^[0-9\\.:\\-]*","",release); if(release=="") {release="?"}; arch=$3; if (NF>3) {sub("^.*:\\/\\/", "", $4); sub("^www\\.", "", $4); sub("\\/.*$", "", $4); vendor=$4} else {vendor="?"} group="?"}' + elif [ "$OSName" = "Arch_Linux" ] || [ "$OSName" = "Arch_Linux_ARM" ]; then + CMD="eval pacman -Q" + # shellcheck disable=SC2016 + FORMAT="{name=\$1;version=\$2; release=\"?\"; arch=\"$(eval uname -m | sed -r "s/(armv7l|aarch64)/arm64/;s/x86_64/amd64/")\"; vendor=\"?\"; group=\"?\"}" else CMD='eval rpm --query --all --queryformat "%-56{name} %-21{version} %-21{release} %-11{arch} %-31{vendor} %-{group}\n"' # shellcheck disable=SC2016 @@ -69,5 +76,5 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then fi assertHaveCommand "$CMD" -$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FILTER $FORMAT $SEPARATE_RECORDS $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FILTER $FORMAT $SEPARATE_RECORDS $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK '$HEADERIZE $FILTER $FORMAT $SEPARATE_RECORDS $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" diff --git a/bin/protocol.sh b/bin/protocol.sh index d632313..3aa5d5d 100755 --- a/bin/protocol.sh +++ b/bin/protocol.sh @@ -5,6 +5,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + CMD='netstat -s' HEADER=' IPdropped TCPrexmits TCPreorder TCPpktRecv TCPpktSent UDPpktLost UDPunkPort UDPpktRecv UDPpktSent' HEADERIZE="BEGIN {print \"$HEADER\"}" @@ -77,5 +79,5 @@ elif [ "$KERNEL" = "HP-UX" ] ; then fi assertHaveCommand "$CMD" -$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FIGURE_SECTION $COMMON $SECTION_IP $SECTION_TCP $SECTION_UDP $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $FIGURE_SECTION $COMMON $SECTION_IP $SECTION_TCP $SECTION_UDP $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK '$HEADERIZE $FIGURE_SECTION $COMMON $SECTION_IP $SECTION_TCP $SECTION_UDP $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" diff --git a/bin/vmstat.sh b/bin/vmstat.sh index 47d90d3..187b917 100755 --- a/bin/vmstat.sh +++ b/bin/vmstat.sh @@ -6,6 +6,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + # hardware.sh is called in all commands to get CPU counts. The CPU count is required to determine # the number of threads that waited for execution time. CPU count accounts for hyperthreaded cores so # (load average - CPU count) gives a reasonable estimate of how many threads were waiting to execute. @@ -193,5 +195,5 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then FILL_BLANKS='END {threads=pgSwapOut="?"}' fi -$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $MASSAGE $FILL_BLANKS $PRINTF" header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK "$HEADERIZE $MASSAGE $FILL_BLANKS $PRINTF" header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK '$HEADERIZE $MASSAGE $FILL_BLANKS $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" diff --git a/bin/vmstat_metric.sh b/bin/vmstat_metric.sh index c262588..4c79353 100755 --- a/bin/vmstat_metric.sh +++ b/bin/vmstat_metric.sh @@ -6,6 +6,8 @@ # shellcheck disable=SC1091 . "$(dirname "$0")"/common.sh +assertHaveCommand column + # hardware.sh is called in all commands to get CPU counts. The CPU count is required to determine # the number of threads that waited for execution time. CPU count accounts for hyperthreaded cores so # (load average - CPU count) gives a reasonable estimate of how many threads were waiting to execute. @@ -206,5 +208,5 @@ elif [ "$KERNEL" = "FreeBSD" ] ; then FILL_BLANKS='END {threads=pgSwapOut="?"}' fi # shellcheck disable=SC2086 -$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$HEADERIZE $MESSAGE $FILL_BLANKS $FILL_DIMENSIONS $PRINTF " header="$HEADER" +$CMD | tee "$TEE_DEST" | $AWK $DEFINE "$HEADERIZE $MESSAGE $FILL_BLANKS $FILL_DIMENSIONS $PRINTF " header="$HEADER" | column -t echo "Cmd = [$CMD]; | $AWK $DEFINE '$HEADERIZE $MESSAGE $FILL_BLANKS $FILL_DIMENSIONS $PRINTF' header=\"$HEADER\"" >> "$TEE_DEST" diff --git a/default/app.conf b/default/app.conf index 4c4b6cf..41c30da 100644 --- a/default/app.conf +++ b/default/app.conf @@ -17,7 +17,7 @@ docs_section_override = AddOns:released [launcher] author = Michael Erdely -version = 9.2.0.12 +version = 9.2.0.13 description = Technical Add-on for Unix and Linux #[package] @@ -26,5 +26,5 @@ description = Technical Add-on for Unix and Linux [id] name = TA-unix -version = 9.2.0.12 +version = 9.2.0.13 diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 0775ac2..250fb1b 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -1,5 +1,14 @@ # Technical Add-on for Unix and Linux +## Version 9.2.0.13 (2025-02-03) + +Fix alignment and fix packages for Arch Linux + +Changes: + +* Align columns with "column -t" +* Add Arch Linux support in packages.sh + ## Version 9.2.0.12 (2025-01-25) Add Version to update.sh for Darwin