#!/bin/bash set -uo pipefail ZARYA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "${ZARYA_DIR}/lib/common.sh" has_errors=false echo -e "${YELLOW}=== ТРИАЖ АВАРИЙ И СБОЕВ (K8s / Host / VyOS) ===${NC}" bad_pods=$(kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers 2>/dev/null | grep -v 'Completed' || true) if [[ -n "${bad_pods}" ]]; then has_errors=true echo -e "${RED}[K8S] Проблемные поды:${NC}" echo "${bad_pods}" | awk '{printf " %-16s %-36s %s\n", $1, $2, $3}' fi pve_failed=$(ssh -n -o BatchMode=yes -o ConnectTimeout=1 proxmox "systemctl --failed --no-legend --plain" 2>/dev/null || echo "UNREACHABLE") if [[ "${pve_failed}" == "UNREACHABLE" ]]; then has_errors=true echo -e "${RED}[PVE] Гипервизор недоступен по SSH${NC}" elif [[ -n "${pve_failed}" ]]; then has_errors=true echo -e "${RED}[PVE] Упавшие systemd-сервисы:${NC}" echo "${pve_failed}" | awk '{print " " $1}' fi vyos_failed=$(ssh -n -o BatchMode=yes -o ConnectTimeout=1 vyos_router "systemctl --failed --no-legend --plain" 2>/dev/null || echo "UNREACHABLE") if [[ "${vyos_failed}" == "UNREACHABLE" ]]; then has_errors=true echo -e "${RED}[VyOS] Роутер недоступен по SSH${NC}" elif [[ -n "${vyos_failed}" ]]; then has_errors=true echo -e "${RED}[VyOS] Упавшие systemd-сервисы:${NC}" echo "${vyos_failed}" | awk '{print " " $1}' fi if [[ "$has_errors" == false ]]; then echo -e "${GREEN}✔ Все системы в норме. Сбоев не обнаружено.${NC}" fi