mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
A parse_ethtools() that actually works
This commit is contained in:
@@ -1444,15 +1444,15 @@ parse_ethtool () {
|
||||
|
||||
|
||||
awk '
|
||||
/^Setting for / {
|
||||
device = $3;
|
||||
/^Settings for / {
|
||||
device = substr($3, 0, index($3, ":") ? index($3, ":")-1 : length($3));
|
||||
device_names[device] = device;
|
||||
}
|
||||
/Speed:/ { devices[device, ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device, ",duplex"] = $2 }
|
||||
/Speed:/ { devices[device ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device ",duplex"] = $2 }
|
||||
END {
|
||||
for ( device in device_names ) {
|
||||
printf(" %-10s %-10s %-10s",
|
||||
printf(" %-10s %-10s %-10s\n",
|
||||
device,
|
||||
devices[device ",speed"],
|
||||
devices[device ",duplex"]);
|
||||
|
@@ -280,15 +280,15 @@ parse_ethtool () {
|
||||
|
||||
|
||||
awk '
|
||||
/^Setting for / {
|
||||
device = $3;
|
||||
/^Settings for / {
|
||||
device = substr($3, 0, index($3, ":") ? index($3, ":")-1 : length($3));
|
||||
device_names[device] = device;
|
||||
}
|
||||
/Speed:/ { devices[device, ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device, ",duplex"] = $2 }
|
||||
/Speed:/ { devices[device ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device ",duplex"] = $2 }
|
||||
END {
|
||||
for ( device in device_names ) {
|
||||
printf(" %-10s %-10s %-10s",
|
||||
printf(" %-10s %-10s %-10s\n",
|
||||
device,
|
||||
devices[device ",speed"],
|
||||
devices[device ",duplex"]);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 44
|
||||
plan 46
|
||||
|
||||
. "$LIB_DIR/alt_cmds.sh"
|
||||
. "$LIB_DIR/log_warn_die.sh"
|
||||
@@ -38,6 +38,98 @@ EOF
|
||||
parse_proc_cpuinfo "$samples/proc_cpuinfo002.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "parse_proc_cpuinfo, proc_cpuinfo002.txt"
|
||||
|
||||
# parse_ethtool
|
||||
cat <<EOF > "$TMPDIR/in"
|
||||
Settings for eth0:
|
||||
Supported ports: [ TP MII ]
|
||||
Supported link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Supports auto-negotiation: Yes
|
||||
Advertised link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Advertised pause frame use: Symmetric Receive-only
|
||||
Advertised auto-negotiation: Yes
|
||||
Speed: 10Mb/s
|
||||
Duplex: Half
|
||||
Port: MII
|
||||
PHYAD: 0
|
||||
Transceiver: internal
|
||||
Auto-negotiation: on
|
||||
Supports Wake-on: pumbg
|
||||
Wake-on: d
|
||||
Current message level: 0x00000033 (51)
|
||||
drv probe ifdown ifup
|
||||
Link detected: no
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Device Speed Duplex
|
||||
========= ========= =========
|
||||
eth0 10Mb/s Half
|
||||
EOF
|
||||
|
||||
parse_ethtool "$TMPDIR/in" > "$TMPDIR/got"
|
||||
no_diff \
|
||||
"$TMPDIR/expected" \
|
||||
"$TMPDIR/got" \
|
||||
"parse_ethtool works"
|
||||
|
||||
cat <<EOF > "$TMPDIR/in"
|
||||
Settings for eth0:
|
||||
Supported ports: [ TP MII ]
|
||||
Supported link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Supports auto-negotiation: Yes
|
||||
Advertised link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Advertised pause frame use: Symmetric Receive-only
|
||||
Advertised auto-negotiation: Yes
|
||||
Speed: 10Mb/s
|
||||
Duplex: Half
|
||||
Port: MII
|
||||
PHYAD: 0
|
||||
Transceiver: internal
|
||||
Auto-negotiation: on
|
||||
Supports Wake-on: pumbg
|
||||
Wake-on: d
|
||||
Current message level: 0x00000033 (51)
|
||||
drv probe ifdown ifup
|
||||
Link detected: no
|
||||
Settings for eth4:
|
||||
Supported ports: [ TP MII ]
|
||||
Supported link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Supports auto-negotiation: Yes
|
||||
Advertised link modes: 10baseT/Half 10baseT/Full
|
||||
100baseT/Half 100baseT/Full
|
||||
Advertised pause frame use: Symmetric Receive-only
|
||||
Advertised auto-negotiation: Yes
|
||||
Speed: 100Mb/s
|
||||
Duplex: Full
|
||||
Port: MII
|
||||
PHYAD: 0
|
||||
Transceiver: internal
|
||||
Auto-negotiation: on
|
||||
Supports Wake-on: pumbg
|
||||
Wake-on: d
|
||||
Current message level: 0x00000033 (51)
|
||||
drv probe ifdown ifup
|
||||
Link detected: no
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Device Speed Duplex
|
||||
========= ========= =========
|
||||
eth0 10Mb/s Half
|
||||
eth4 100Mb/s Full
|
||||
EOF
|
||||
|
||||
parse_ethtool "$TMPDIR/in" > "$TMPDIR/got"
|
||||
no_diff \
|
||||
"$TMPDIR/expected" \
|
||||
"$TMPDIR/got" \
|
||||
"parse_ethtool works if there are multiple devices"
|
||||
|
||||
# parse_netstat
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
Reference in New Issue
Block a user