From 533f77c738bac614f6701ed99c1f83437204abc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Wed, 6 May 2026 18:39:15 +0900 Subject: [PATCH] Add console dashboard script --- scripts/virtuality_console_dashboard.sh | 93 +++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 scripts/virtuality_console_dashboard.sh diff --git a/scripts/virtuality_console_dashboard.sh b/scripts/virtuality_console_dashboard.sh new file mode 100644 index 0000000..97e5045 --- /dev/null +++ b/scripts/virtuality_console_dashboard.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +set -euo pipefail + +refresh_interval="${VIRTUALITY_DASHBOARD_INTERVAL:-5}" + +has_cmd() { + command -v "$1" >/dev/null 2>&1 +} + +service_state() { + local unit="$1" + if systemctl list-unit-files "$unit" >/dev/null 2>&1; then + systemctl is-active "$unit" 2>/dev/null || echo "inactive" + else + echo "missing" + fi +} + +while true; do + clear + echo "============================================================" + echo " VIRTUALITY NODE DASHBOARD" + echo "============================================================" + echo "Date: $(date '+%Y-%m-%d %H:%M:%S')" + echo "Hostname: $(hostname)" + echo "Uptime: $(uptime -p 2>/dev/null || true)" + echo "Kernel: $(uname -r)" + if [[ -f /etc/os-release ]]; then + . /etc/os-release + echo "OS: ${PRETTY_NAME}" + fi + echo + + echo "[SYSTEM]" + echo "Load: $(awk '{print $1, $2, $3}' /proc/loadavg)" + echo "CPU virt: $(grep -E -q '(vmx|svm)' /proc/cpuinfo && echo OK || echo WARNING)" + free -h | awk '/Mem:/ {print "Memory: used " $3 " / total " $2}' + df -h / | awk 'NR==2 {print "Root FS: used " $3 " / total " $2 " (" $5 ")"}' + echo + + echo "[NETWORK]" + ip -br a 2>/dev/null | sed 's/^/ /' || true + echo "Gateway: $(ip route | awk '/default/ {print $3 " via " $5; exit}')" + echo + + echo "[VIRTUALITY SERVICES]" + printf " %-24s %s\n" "libvirtd.service" "$(service_state libvirtd.service)" + printf " %-24s %s\n" "virtlogd.service" "$(service_state virtlogd.service)" + printf " %-24s %s\n" "cockpit.socket" "$(service_state cockpit.socket)" + printf " %-24s %s\n" "libvirt-guests.service" "$(service_state libvirt-guests.service)" + echo + + echo "[LIBVIRT STORAGE POOLS]" + if has_cmd virsh; then + virsh pool-list --all 2>/dev/null | sed 's/^/ /' || echo " virsh pool-list unavailable" + else + echo " virsh not installed" + fi + echo + + echo "[VIRTUAL MACHINES]" + if has_cmd virsh; then + virsh list --all 2>/dev/null | sed 's/^/ /' || echo " virsh list unavailable" + else + echo " virsh not installed" + fi + echo + + echo "[STORAGE PATHS]" + for dir in /var/lib/virtuality/iso /var/lib/virtuality/images /var/lib/virtuality/backups /var/log/virtuality; do + if [[ -d "$dir" ]]; then + used="$(du -sh "$dir" 2>/dev/null | awk '{print $1}')" + printf " %-34s %s\n" "$dir" "$used" + else + printf " %-34s %s\n" "$dir" "missing" + fi + done + echo + + echo "[FIREWALL]" + if has_cmd ufw; then + ufw status 2>/dev/null | head -n 12 | sed 's/^/ /' || true + else + echo " ufw not installed" + fi + echo + + echo "============================================================" + echo "Refresh: ${refresh_interval}s | btop: press Ctrl+Alt+F2 login and run bt" + echo "Stop dashboard temporarily: sudo systemctl stop virtuality-console-dashboard" + echo "============================================================" + sleep "$refresh_interval" +done