22 lines
418 B
Bash
22 lines
418 B
Bash
#!/usr/bin/env bash
|
|
|
|
function get_network_state() {
|
|
set -x
|
|
ip route
|
|
echo
|
|
ip --brief address show
|
|
echo
|
|
docker network list
|
|
}
|
|
|
|
MAX_KEPT={{ net_debug_keep_logs }}
|
|
LOG_DIR="{{ net_debug_logs_dir }}"
|
|
TSTAMP=$(date -u +%Y%m%d%H%M%S)
|
|
|
|
# Save network state
|
|
get_network_state > 2>&1 "${LOG_DIR}/${TSTAMP}.log"
|
|
|
|
# Clean old states
|
|
OLD_LOGS=$(ls -Art ${LOG_DIR} | head -n -${MAX_KEPT})
|
|
rm -vf ${OLD_LOGS}
|