Single Flask codebase runs in agent mode (serves /api/stats from local /proc) or dashboard mode (aggregates local + remote agents). Currently monitors compute1 (64-core, podman container) and console (16-core, bare systemd service). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
HOST="${1:-console}"
|
|
|
|
echo "Deploying sysmon agent to $HOST..."
|
|
|
|
# Create directory and copy app
|
|
ssh "$HOST" 'mkdir -p ~/sysmon-agent/templates'
|
|
scp ~/sysmon/app.py "$HOST":~/sysmon-agent/
|
|
scp ~/sysmon/templates/index.html "$HOST":~/sysmon-agent/templates/
|
|
|
|
# Install dependencies and set up systemd service
|
|
ssh "$HOST" bash <<'REMOTE'
|
|
set -e
|
|
|
|
pip3 install --break-system-packages --quiet flask gunicorn 2>/dev/null || \
|
|
pip3 install --quiet flask gunicorn
|
|
|
|
# Create systemd service
|
|
sudo tee /etc/systemd/system/sysmon-agent.service > /dev/null <<EOF
|
|
[Unit]
|
|
Description=Sysmon Agent
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=kamaji
|
|
WorkingDirectory=/home/kamaji/sysmon-agent
|
|
Environment=SYSMON_PROC=/proc
|
|
ExecStart=/home/kamaji/.local/bin/gunicorn -b 0.0.0.0:8083 -w 1 --threads 2 app:app
|
|
Restart=always
|
|
RestartSec=5
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable sysmon-agent
|
|
sudo systemctl restart sysmon-agent
|
|
|
|
echo "Agent status:"
|
|
sudo systemctl status sysmon-agent --no-pager -l
|
|
REMOTE
|
|
|
|
echo ""
|
|
echo "Verify: curl http://$HOST:8083/api/stats"
|