Files
brocade-monitor/brocade-status.sh
Nova 3db6162b10 Initial commit: Brocade ICX 6610-48P monitoring scripts
- brocade-status.sh: Full status dump with uptime, temps, ports, logs
- Color-coded health summary
- Detects RTC battery issues, high temps, recent reboots
2026-04-03 15:41:11 +00:00

129 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# Brocade ICX 6610-48P Status Dumper
# Connects via telnet and dumps switch info
SWITCH_IP="${BROCADE_IP:-192.168.1.2}"
SWITCH_USER="${BROCADE_USER:-root}"
SWITCH_PASS="${BROCADE_PASS:-palm7}"
TIMEOUT="${TIMEOUT:-30}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Function to run telnet command
telnet_cmd() {
local cmds="$1"
echo -e "enable\n$SWITCH_USER\n$SWITCH_PASS\n$cmds\nexit" | nc -w $TIMEOUT $SWITCH_IP 23 2>/dev/null
}
# Header
echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ Brocade ICX 6610-48P Status Report ║${NC}"
echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Timestamp
echo -e "${YELLOW}Timestamp:${NC} $(date '+%Y-%m-%d %H:%M:%S %Z')"
echo ""
# Uptime
echo -e "${CYAN}━━━ UPTIME ━━━${NC}"
uptime_output=$(telnet_cmd 'show version | include uptime' | grep -E 'uptime is')
echo "$uptime_output"
echo ""
# System Info
echo -e "${CYAN}━━━ SYSTEM INFO ━━━${NC}"
sys_info=$(telnet_cmd 'show version' | grep -E '(SW:|HW:|compiled|Serial)')
echo "$sys_info"
echo ""
# Clock
echo -e "${CYAN}━━━ CLOCK ━━━${NC}"
clock=$(telnet_cmd 'show clock' | tail -2 | head -1)
echo "System Clock: $clock"
echo ""
# Temperature
echo -e "${CYAN}━━━ TEMPERATURE ━━━${NC}"
temps=$(telnet_cmd 'show chassis' | grep -A 20 'Temperature Readings')
echo "$temps" | grep -E '(MAC|CPU|sensor|stacking|Current)'
echo ""
# Power Supply
echo -e "${CYAN}━━━ POWER SUPPLY ━━━${NC}"
power=$(telnet_cmd 'show chassis' | grep -A 5 'Power supply')
echo "$power"
echo ""
# Fans
echo -e "${CYAN}━━━ FANS ━━━${NC}"
fans=$(telnet_cmd 'show chassis' | grep -E 'Fan')
echo "$fans"
echo ""
# PoE Status
echo -e "${CYAN}━━━ PoE STATUS ━━━${NC}"
poe=$(telnet_cmd 'show inline power' | grep -E '(Power Capacity|Power Allocations|Total)' | head -5)
echo "$poe"
echo ""
# Active Ports
echo -e "${CYAN}━━━ ACTIVE PORTS ━━━${NC}"
ports=$(telnet_cmd 'show interface brief' | grep 'Up' | grep 'Forward')
port_count=$(echo "$ports" | wc -l)
echo "Active ports: $port_count"
echo "$ports" | head -10
if [ $port_count -gt 10 ]; then
echo "... and $((port_count - 10)) more"
fi
echo ""
# Recent Logs
echo -e "${CYAN}━━━ RECENT LOGS (last 10) ━━━${NC}"
logs=$(telnet_cmd 'show log' | grep -E '^\d+ days' | tail -10)
echo "$logs"
echo ""
# Health Summary
echo -e "${CYAN}━━━ HEALTH SUMMARY ━━━${NC}"
# Check uptime for stability
uptime_mins=$(echo "$uptime_output" | grep -oE '[0-9]+ hour' | awk '{print $1}' 2>/dev/null || echo "0")
uptime_mins=$((uptime_mins * 60))
uptime_mins=$((uptime_mins + $(echo "$uptime_output" | grep -oE '[0-9]+ minute' | awk '{print $1}' 2>/dev/null || echo "0")))
# Check temps
max_temp=$(telnet_cmd 'show chassis' | grep 'Current temperature' | grep -oE '[0-9]+\.[0-9]+' | sort -rn | head -1)
# Check clock
clock_year=$(echo "$clock" | grep -oE '[0-9]{4}' | tail -1)
# Health status
if [ "$uptime_mins" -lt 30 ]; then
echo -e "${RED}⚠ UPTIME:${NC} Less than 30 minutes - recent reboot detected!"
elif [ "$uptime_mins" -lt 60 ]; then
echo -e "${YELLOW}⚠ UPTIME:${NC} Less than 1 hour - monitor for stability"
else
echo -e "${GREEN}✓ UPTIME:${NC} Stable ($((uptime_mins / 60)) hours $((uptime_mins % 60)) minutes)"
fi
if [ -n "$max_temp" ] && (( $(echo "$max_temp > 70" | bc -l) )); then
echo -e "${RED}⚠ TEMPERATURE:${NC} High (${max_temp}°C)"
elif [ -n "$max_temp" ] && (( $(echo "$max_temp > 60" | bc -l) )); then
echo -e "${YELLOW}⚠ TEMPERATURE:${NC} Warm (${max_temp}°C)"
else
echo -e "${GREEN}✓ TEMPERATURE:${NC} Normal (${max_temp}°C)"
fi
if [ "$clock_year" = "0" ] || [ "$clock_year" = "2036" ]; then
echo -e "${RED}⚠ CLOCK:${NC} RTC battery dead - showing year $clock_year"
else
echo -e "${GREEN}✓ CLOCK:${NC} OK (${clock_year})"
fi
echo ""
echo -e "${CYAN}══════════════════════════════════════════════════════════════${NC}"