#!/bin/bash
# NEMS Central Command Live Daemon Monitor

if [ "$EUID" -ne 0 ]; then
  echo -e "\e[31mError: nems-ncc-monitor must be run as root (or using sudo).\e[0m" >&2
  exit 1
fi

echo -e "\e[36m⚡ NEMS Central Command Live Monitor\e[0m"

# Check if nems-ncc service is running
if ! systemctl is-active --quiet nems-ncc.service; then
  echo -e "\e[33mWarning: NEMS Central Command is currently offline or not running.\e[0m"
  echo -e "\e[90mYou may need to enable or start it using: systemctl start nems-ncc.service\e[0m\n"
fi

# Check NEMS AI Engine Status
if [ -f /usr/local/share/nems/nems-ai/api.php ]; then
  echo -e "\e[32m🤖 NEMS AI Engine: Detected\e[0m"
else
  echo -e "\e[33m🤖 NEMS AI Engine: Not Found (Using baseline text)\e[0m"
fi

echo -e "\e[90mListening for live events (Press Ctrl+C to exit)...\e[0m\n"

journalctl -u nems-ncc.service -f -n 0 -o cat
