59 lines
1.9 KiB
Bash
59 lines
1.9 KiB
Bash
#!/bin/bash
|
|
# Bash script to check BGP server status on Linux
|
|
# BGP Server Status Check Script
|
|
|
|
echo -e "\033[36mChecking BGP Server Status...\033[0m"
|
|
|
|
# Check if Docker is running
|
|
if ! docker version >/dev/null 2>&1; then
|
|
echo -e "\033[31m✗ Docker is not running\033[0m"
|
|
exit 1
|
|
fi
|
|
echo -e "\033[32m✓ Docker is running\033[0m"
|
|
|
|
# Check container status
|
|
echo -e "\n\033[33mContainer Status:\033[0m"
|
|
container_status=$(docker ps --filter "name=bgp-server" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}")
|
|
if [ -n "$container_status" ] && ! echo "$container_status" | grep -q "NAMES"; then
|
|
echo -e "\033[32m$container_status\033[0m"
|
|
else
|
|
echo -e "\033[31m✗ BGP container is not running\033[0m"
|
|
echo -e "\033[33mTo start the server, run: ./start-bgp-server.sh\033[0m"
|
|
exit 1
|
|
fi
|
|
|
|
# Check network ports
|
|
echo -e "\n\033[33mNetwork Ports:\033[0m"
|
|
if netstat -tuln 2>/dev/null | grep -q ":179 "; then
|
|
echo -e "\033[32m✓ BGP port 179 is listening\033[0m"
|
|
else
|
|
echo -e "\033[31m✗ BGP port 179 is not listening\033[0m"
|
|
fi
|
|
|
|
if netstat -tuln 2>/dev/null | grep -q ":2601 "; then
|
|
echo -e "\033[32m✓ vtysh port 2601 is listening\033[0m"
|
|
else
|
|
echo -e "\033[31m✗ vtysh port 2601 is not listening\033[0m"
|
|
fi
|
|
|
|
# Check BGP status inside container
|
|
echo -e "\n\033[33mBGP Status:\033[0m"
|
|
bgp_summary=$(docker exec bgp-server vtysh -c "show ip bgp summary" 2>/dev/null)
|
|
if [ -n "$bgp_summary" ]; then
|
|
echo -e "\033[32m✓ BGP daemon is running\033[0m"
|
|
echo -e "\033[36mBGP Summary:\033[0m"
|
|
echo -e "\033[37m$bgp_summary\033[0m"
|
|
else
|
|
echo -e "\033[31m✗ BGP daemon is not responding\033[0m"
|
|
fi
|
|
|
|
# Check recent logs
|
|
echo -e "\n\033[33mRecent Logs:\033[0m"
|
|
recent_logs=$(docker-compose logs --tail=10 bgp-server 2>/dev/null)
|
|
if [ -n "$recent_logs" ]; then
|
|
echo -e "\033[37m$recent_logs\033[0m"
|
|
else
|
|
echo -e "\033[90mNo recent logs available\033[0m"
|
|
fi
|
|
|
|
echo -e "\n\033[32mStatus check completed!\033[0m" |