first commit

This commit is contained in:
Carlos Tello
2026-09-20 13:43:58 -03:00
commit bdf42e74a3
9 changed files with 1188 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
################################################################################
# MONITOR SCRIPT
# Monitorea servicios y hardware en tiempo real
################################################################################
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
clear_screen() {
clear
}
print_header() {
echo -e "${BLUE}=================================================${NC}"
echo -e "${BLUE} LLM SERVER MONITOR - $(date '+%Y-%m-%d %H:%M:%S')${NC}"
echo -e "${BLUE}=================================================${NC}"
}
print_section() {
echo -e "\n${YELLOW}>>> $1${NC}"
}
check_service() {
local service=$1
if sudo systemctl is-active --quiet "$service"; then
echo -e "${GREEN}✅ $service - ACTIVO${NC}"
sudo systemctl status "$service" --no-pager | grep -E "(Active|ExecStart)" | sed 's/^/ /'
else
echo -e "${RED}❌ $service - INACTIVO${NC}"
fi
}
get_ip() {
hostname -I | awk '{print $1}'
}
main() {
while true; do
clear_screen
print_header
# System Info
print_section "SISTEMA"
echo "Hostname: $(hostname)"
echo "IP: $(get_ip)"
echo "Uptime: $(uptime -p)"
echo "Usuarios conectados: $(who | wc -l)"
# CPU & RAM
print_section "CPU & MEMORIA"
free -h | awk 'NR==1 {print ""; print $0} NR==2 {print $0}'
echo ""
top -bn1 | head -3 | tail -1
# Disk
print_section "DISCO"
df -h / | awk 'NR==2 {printf "Root: %s used / %s total (%.1f%%)\n", $3, $2, ($3/$2)*100}'
# GPU
print_section "GPU - NVIDIA RTX 3090"
nvidia-smi --query-gpu=index,name,driver_version,memory.used,memory.total,temperature.gpu,utilization.gpu \
--format=csv,noheader | while read line; do
echo " $line"
done
# Services
print_section "SERVICIOS"
check_service "ollama"
echo ""
check_service "llm-api"
# Network
print_section "RED"
echo "API (port 8000): $(curl -s http://localhost:8000/health | jq '.' 2>/dev/null || echo 'NO RESPONDE')"
echo "Ollama (port 11434): $(curl -s http://localhost:11434/api/tags | jq '.models | length' 2>/dev/null || echo '0') modelos"
# Logs recientes
print_section "ÚLTIMOS ERRORES (últimas 5 líneas)"
echo "Ollama:"
sudo journalctl -u ollama -n 3 --no-pager | sed 's/^/ /'
echo ""
echo "API:"
sudo journalctl -u llm-api -n 3 --no-pager | sed 's/^/ /'
# Footer
echo ""
echo -e "${BLUE}=================================================${NC}"
echo "Presiona Ctrl+C para salir | Se actualiza cada 10 segundos"
echo -e "${BLUE}=================================================${NC}"
sleep 10
done
}
main