docs: Network infrastructure cleanup - static IPs, local DNS, SSH access
- Complete static IP migration for all containers - Configure Pi-hole local DNS with .kav hostnames - Add SSH provisioning script for all containers - Create NETWORK-MAP.md with complete IP allocation - Create network-map.sh for dynamic map generation - Update INFRASTRUCTURE.md with new service map - Add .kav TLD and SSH policy decisions to DECISIONS.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
170
scripts/monitoring/network-map.sh
Executable file
170
scripts/monitoring/network-map.sh
Executable file
@@ -0,0 +1,170 @@
|
||||
#!/bin/bash
|
||||
# network-map.sh - Generate network map from Proxmox cluster
|
||||
#
|
||||
# Usage:
|
||||
# ./network-map.sh # Print to stdout
|
||||
# ./network-map.sh --json # Output as JSON
|
||||
# ./network-map.sh --markdown # Output as Markdown table
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Node configuration
|
||||
declare -A NODES=(
|
||||
["pm1"]="10.4.2.2"
|
||||
["pm2"]="10.4.2.6"
|
||||
["pm3"]="10.4.2.3"
|
||||
["pm4"]="10.4.2.5"
|
||||
["elantris"]="10.4.2.14"
|
||||
)
|
||||
|
||||
OUTPUT_FORMAT="${1:-text}"
|
||||
|
||||
get_container_info() {
|
||||
local node=$1
|
||||
ssh -o ConnectTimeout=5 "$node" "
|
||||
# Get LXC containers
|
||||
for vmid in \$(pct list 2>/dev/null | tail -n +2 | awk '{print \$1}'); do
|
||||
config=\$(pct config \$vmid 2>/dev/null)
|
||||
hostname=\$(echo \"\$config\" | grep -E '^hostname:' | awk '{print \$2}')
|
||||
net0=\$(echo \"\$config\" | grep -E '^net0:' | sed 's/net0: //')
|
||||
ip=\$(echo \"\$net0\" | grep -oP 'ip=\\K[^/,]+' || echo 'dhcp')
|
||||
status=\$(pct status \$vmid 2>/dev/null | awk '{print \$2}')
|
||||
echo \"lxc|\$vmid|\$hostname|\$ip|\$status|$node\"
|
||||
done
|
||||
|
||||
# Get VMs
|
||||
for vmid in \$(qm list 2>/dev/null | tail -n +2 | awk '{print \$1}'); do
|
||||
config=\$(qm config \$vmid 2>/dev/null)
|
||||
name=\$(echo \"\$config\" | grep -E '^name:' | awk '{print \$2}')
|
||||
ipconfig=\$(echo \"\$config\" | grep -E '^ipconfig0:' | sed 's/ipconfig0: //')
|
||||
ip=\$(echo \"\$ipconfig\" | grep -oP 'ip=\\K[^/,]+' || echo 'dhcp')
|
||||
status=\$(qm status \$vmid 2>/dev/null | awk '{print \$2}')
|
||||
echo \"vm|\$vmid|\$name|\$ip|\$status|$node\"
|
||||
done
|
||||
" 2>/dev/null || true
|
||||
}
|
||||
|
||||
print_header() {
|
||||
echo "========================================"
|
||||
echo " KAVCORP NETWORK MAP"
|
||||
echo " Generated: $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_nodes() {
|
||||
echo "PROXMOX NODES"
|
||||
echo "----------------------------------------"
|
||||
printf " %-15s %s\n" "IP" "HOSTNAME"
|
||||
echo "----------------------------------------"
|
||||
for node in "${!NODES[@]}"; do
|
||||
printf " %-15s %s\n" "${NODES[$node]}" "$node"
|
||||
done | sort -t. -k4 -n
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_resources() {
|
||||
local resources="$1"
|
||||
|
||||
echo "LXC CONTAINERS"
|
||||
echo "----------------------------------------"
|
||||
printf " %-15s %-6s %-20s %-10s %s\n" "IP" "VMID" "NAME" "NODE" "STATUS"
|
||||
echo "----------------------------------------"
|
||||
echo "$resources" | grep "^lxc|" | sort -t'|' -k4 -V | while IFS='|' read -r type vmid name ip status node; do
|
||||
printf " %-15s %-6s %-20s %-10s %s\n" "$ip" "$vmid" "$name" "$node" "$status"
|
||||
done
|
||||
echo ""
|
||||
|
||||
echo "VIRTUAL MACHINES"
|
||||
echo "----------------------------------------"
|
||||
printf " %-15s %-6s %-20s %-10s %s\n" "IP" "VMID" "NAME" "NODE" "STATUS"
|
||||
echo "----------------------------------------"
|
||||
echo "$resources" | grep "^vm|" | sort -t'|' -k4 -V | while IFS='|' read -r type vmid name ip status node; do
|
||||
printf " %-15s %-6s %-20s %-10s %s\n" "$ip" "$vmid" "$name" "$node" "$status"
|
||||
done
|
||||
}
|
||||
|
||||
print_json() {
|
||||
local resources="$1"
|
||||
|
||||
echo "{"
|
||||
echo " \"generated\": \"$(date -Iseconds)\","
|
||||
echo " \"nodes\": ["
|
||||
first=true
|
||||
for node in "${!NODES[@]}"; do
|
||||
if [ "$first" = true ]; then first=false; else echo ","; fi
|
||||
printf " {\"name\": \"%s\", \"ip\": \"%s\"}" "$node" "${NODES[$node]}"
|
||||
done
|
||||
echo ""
|
||||
echo " ],"
|
||||
echo " \"containers\": ["
|
||||
first=true
|
||||
echo "$resources" | grep "^lxc|" | while IFS='|' read -r type vmid name ip status node; do
|
||||
if [ "$first" = true ]; then first=false; else echo ","; fi
|
||||
printf " {\"vmid\": %s, \"name\": \"%s\", \"ip\": \"%s\", \"status\": \"%s\", \"node\": \"%s\"}" "$vmid" "$name" "$ip" "$status" "$node"
|
||||
done
|
||||
echo ""
|
||||
echo " ],"
|
||||
echo " \"vms\": ["
|
||||
first=true
|
||||
echo "$resources" | grep "^vm|" | while IFS='|' read -r type vmid name ip status node; do
|
||||
if [ "$first" = true ]; then first=false; else echo ","; fi
|
||||
printf " {\"vmid\": %s, \"name\": \"%s\", \"ip\": \"%s\", \"status\": \"%s\", \"node\": \"%s\"}" "$vmid" "$name" "$ip" "$status" "$node"
|
||||
done
|
||||
echo ""
|
||||
echo " ]"
|
||||
echo "}"
|
||||
}
|
||||
|
||||
print_markdown() {
|
||||
local resources="$1"
|
||||
|
||||
echo "# Network Map"
|
||||
echo ""
|
||||
echo "Generated: $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
echo ""
|
||||
echo "## Proxmox Nodes"
|
||||
echo ""
|
||||
echo "| IP | Hostname |"
|
||||
echo "|---|---|"
|
||||
for node in "${!NODES[@]}"; do
|
||||
echo "| ${NODES[$node]} | $node |"
|
||||
done | sort -t. -k4 -n
|
||||
echo ""
|
||||
echo "## LXC Containers"
|
||||
echo ""
|
||||
echo "| IP | VMID | Name | Node | Status |"
|
||||
echo "|---|---|---|---|---|"
|
||||
echo "$resources" | grep "^lxc|" | sort -t'|' -k4 -V | while IFS='|' read -r type vmid name ip status node; do
|
||||
echo "| $ip | $vmid | $name | $node | $status |"
|
||||
done
|
||||
echo ""
|
||||
echo "## Virtual Machines"
|
||||
echo ""
|
||||
echo "| IP | VMID | Name | Node | Status |"
|
||||
echo "|---|---|---|---|---|"
|
||||
echo "$resources" | grep "^vm|" | sort -t'|' -k4 -V | while IFS='|' read -r type vmid name ip status node; do
|
||||
echo "| $ip | $vmid | $name | $node | $status |"
|
||||
done
|
||||
}
|
||||
|
||||
# Main
|
||||
resources=""
|
||||
for node in "${!NODES[@]}"; do
|
||||
node_resources=$(get_container_info "$node")
|
||||
resources="${resources}${node_resources}"$'\n'
|
||||
done
|
||||
|
||||
case "$OUTPUT_FORMAT" in
|
||||
--json)
|
||||
print_json "$resources"
|
||||
;;
|
||||
--markdown)
|
||||
print_markdown "$resources"
|
||||
;;
|
||||
*)
|
||||
print_header
|
||||
print_nodes
|
||||
print_resources "$resources"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user