Created
February 28, 2024 16:55
-
-
Save knabben/bd7081b398087119ab9e0e0b4be0c40c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> cat .\conntrack_dump.ps1 | |
$stop=$true | |
$interval=300 | |
$max_connection_entry = 2000000 | |
$max_file_count=30 | |
$collection_directory="collections" | |
$conntrack_dump_directory="${collection_directory}/ovs_conntracks" | |
$logs_directory="${collection_directory}/logs" | |
$windows_eventlog_path="C:\Windows\System32\winevt\Logs" | |
$config_dump_directory="${collection_directory}/ovs_configs" | |
$ct_state_file="${collection_directory}/ct_limit_state" | |
$conntrack_file_prefix="conntrack" | |
mkdir -p $conntrack_dump_directory | |
mkdir -p $logs_directory | |
mkdir -p $config_dump_directory | |
$file_count=0 | |
$start=Get-Date | |
do { | |
$now=Get-Date | |
echo $now >> ${ct_state_file} | |
$total_count=0 | |
$output=$(ovs-appctl dpctl/ct-get-limits zone=65520,65521) | |
$output -split "`r?`n" | ForEach-Object { | |
# Extract zone, limit, and count using -split and splitting on "," | |
$zone, $limit, $count = ($_ -split ',|=' | Select-String '\d+').Matches.Value | |
if ($limit) { | |
echo "Zone: $zone, Limit: $limit, Count: $count" >> ${ct_state_file} | |
$total_count=$count+$tocal_count | |
} | |
} | |
$time_diff = New-TimeSpan -Start $start -End $now | |
if ((${total_count} -ge ${max_connection_entry}) -or ($timeDiff.TotalHours -gt 1)) { | |
ovs-dpctl dump-conntrack -s > ${conntrack_dump_directory}/${conntrack_file_prefix}_${file_count}.txt | |
$file_count = $file_count + 1 | |
} | |
if ($timeDiff.TotalHours -gt 1) { | |
$start=$now | |
} | |
if (${file_count} -gt ${max_file_count}) { | |
$stop=$false | |
} else { | |
sleep $interval | |
} | |
} while ($stop) | |
cp -r /var/log/antrea ${logs_directory}/antrea | |
cp -r /openvswitch/var/log/openvswitch ${logs_directory}/openvswitch | |
cp ${windows_eventlog_path}/System.evtx ${logs_directory}/ | |
cp ${windows_eventlog_path}/Application.evtx ${logs_directory}/ | |
ovs-vsctl.exe show > ${config_dump_directory}/ovs_vsctl_show | |
ovs-ofctl.exe -OOpenFlow15 dump-flows br-int > ${config_dump_directory}/ovs_ofctl_dump | |
ovs-ofctl.exe show br-int > ${config_dump_directory}/ovs_ofctl_show | |
ovs-dpctl.exe show > ${config_dump_directory}/ovs_dpctl_show | |
ovs-dpctl.exe dump-flows > ${config_dump_directory}/ovs_dpctl_dump_flows | |
Get-HNSNetwork > ${config_dump_directory}/get_hnsnetwork | |
Get-NetAdapter > ${config_dump_directory}/get_netadapter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment