Jakub Sokołowski 1b23e1a4e7
network-debug-script: add networkctl list
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2020-09-16 14:38:05 +02:00

21 lines
420 B
Bash

#!/usr/bin/env bash
function get_network_state() {
set -x
ip route
ip --brief address show
networkctl list
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 > "${LOG_DIR}/${TSTAMP}.log" 2>&1
# Clean old states
OLD_LOGS=$(ls -Art ${LOG_DIR} | head -n -${MAX_KEPT})
rm -vf ${OLD_LOGS}