Skip to content

Commit 5796a7e

Browse files
committed
Add hhnet logging
Signed-off-by: Pau Capdevila <pau@githedgehog.com>
1 parent a2953f5 commit 5796a7e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pkg/hhfab/hhnet.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
set -e
77

8+
LOG_FILE="/var/log/hhnet.log"
9+
sudo touch "$LOG_FILE"
10+
sudo chmod 666 "$LOG_FILE"
11+
exec >> "$LOG_FILE" 2>&1
12+
813
function cleanup() {
914
for i in {0..3}; do
1015
sudo ip l d "bond$i" 2> /dev/null || true
@@ -22,6 +27,7 @@ function cleanup() {
2227

2328
function setup_bond() {
2429
local bond_name=$1
30+
local start_time=$(date +%s)
2531

2632
sudo ip l a "$bond_name" type bond miimon 100 mode 802.3ad
2733

@@ -32,15 +38,21 @@ function setup_bond() {
3238
done
3339

3440
sudo ip l s "$bond_name" up
41+
local end_time=$(date +%s)
42+
echo "setup_bond completed in $((end_time - start_time)) seconds" >> "$LOG_FILE"
3543
}
3644

3745
function setup_vlan() {
3846
local iface_name=$1
3947
local vlan_id=$2
48+
local start_time=$(date +%s)
4049

4150
sudo ip l s "$iface_name" up
4251
sudo ip l a link "$iface_name" name "$iface_name.$vlan_id" type vlan id "$vlan_id"
4352
sudo ip l s "$iface_name.$vlan_id" up
53+
54+
local end_time=$(date +%s)
55+
echo "setup_vlan completed in $((end_time - start_time)) seconds" >> "$LOG_FILE"
4456
}
4557

4658
function get_ip() {
@@ -55,10 +67,18 @@ function get_ip() {
5567
[ "$attempt" -ge "$max_attempts" ] && break
5668
sleep 1
5769
done
70+
71+
if [ -z "$ip" ]; then
72+
sudo dhclient "$iface_name" || true
73+
sleep 3
74+
ip=$(ip a s "$iface_name" | awk '/inet / {print $2}')
75+
fi
76+
5877
if [ -z "$ip" ]; then
5978
echo "Failed to get IP address for $iface_name" >&2
6079
exit 1
6180
fi
81+
6282
echo "$ip"
6383
}
6484

pkg/hhfab/show-tech/server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ OUTPUT_FILE="/tmp/show-tech.log"
107107
# Logs & Kernel Information
108108
# ---------------------------
109109
{
110+
echo -e "\n=== hhnet logs ==="
111+
cat /var/log/hhnet.log
112+
110113
echo -e "\n=== systemd-networkd logs ==="
111114
journalctl -u systemd-networkd 2>/dev/null
112115

0 commit comments

Comments
 (0)