LogoArc Docs

Jetson Discord Notifier

This system sends Discord webhook notifications when your NVIDIA Jetson Orin Nano comes online and when someone connects or disconnects via SSH or VNC (noVNC + x11vnc).
It now runs via cron @reboot, tails your local VNC log files, and includes the Jetson's 172.17.x.x IP at boot.

File locations on the Jetson

  • Main script
    /opt/jetson-notify/jetson_discord_notify.py
    Handles event monitoring and posts JSON payloads to the Discord webhook.

  • Cron wrapper (loads env, then runs the script)
    /opt/jetson-notify/run-notifier.sh

  • Environment file (secrets & paths)
    /etc/jetson-discord.env
    Contains DISCORD_WEBHOOK, NOVNC_LOG, X11VNC_LOG, AUTH_LOG, HOST_MAP_PATH.

  • VNC logs produced by your startup script

    • /home/arc/.local/state/vnc/novnc.log
    • /home/arc/.local/state/vnc/x11vnc.log
    • /home/arc/.local/state/vnc/boot.log
  • Notifier logs (from cron)

    • /home/arc/.local/state/vnc/notifier.log

If you previously used the systemd unit at /etc/systemd/system/jetson-discord.service, disable it to avoid duplicate notifications:

sudo systemctl disable --now jetson-discord.service

How it works

Boot notification

On startup (via cron), the script posts:

βœ… arc-mobile is online β€’ IP: 172.17.xx.yy

SSH detection (login + disconnect)

  • Follows /var/log/auth.log (user arc must be in group adm).
  • On login, extracts client IP, resolves a label (name or IP), and posts:
    πŸ”‘ SSH login: DESKTOP-XYZ (172.17.xx.yy)
  • On disconnect, matches by sshd[PID] and posts:
    πŸ”’ SSH disconnected: DESKTOP-XYZ (172.17.xx.yy)

Name resolution order:

  1. NetBIOS workstation name via nmblookup -A <ip>
  2. getent hosts <ip>
  3. avahi-resolve-address <ip>
  4. fallback to IP

VNC detection (noVNC + x11vnc)

  • Connect events: parse /home/arc/.local/state/vnc/novnc.log lines like:
    172.17.xx.xx - - [...] Plain non-SSL (ws://) WebSocket connection
    β†’ resolve name/IP and post:
    πŸ–₯️ VNC connected: DESKTOP-XYZ (172.17.xx.yy)
  • Disconnect events: watch /home/arc/.local/state/vnc/x11vnc.log for β€œgone/closed/disconnect” and post:
    πŸ”Œ VNC disconnected
    (x11vnc sees localhost due to the proxy, so it’s used only for disconnect signals.)

Setup (one-time)

Install tools and permissions:

sudo apt-get update
sudo apt-get install -y samba-common-bin avahi-utils
sudo usermod -aG adm arc   # allow reading /var/log/auth.log

Create an env file with your webhook and paths (example):

sudo tee /etc/jetson-discord.env >/dev/null <<'EOF'
DISCORD_WEBHOOK=https://discord.com/api/webhooks/REPLACE_ME
NOVNC_LOG=/home/arc/.local/state/vnc/novnc.log
X11VNC_LOG=/home/arc/.local/state/vnc/x11vnc.log
AUTH_LOG=/var/log/auth.log
HOST_MAP_PATH=/opt/jetson-notify/hosts.json
EOF
sudo chmod 600 /etc/jetson-discord.env

Cron wrapper:

sudo tee /opt/jetson-notify/run-notifier.sh >/dev/null <<'EOF'
#!/bin/bash
set -euo pipefail
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
if [[ -f /etc/jetson-discord.env ]]; then
  set -o allexport
  . /etc/jetson-discord.env
  set +o allexport
fi
exec /usr/bin/python3 /opt/jetson-notify/jetson_discord_notify.py
EOF
sudo chmod +x /opt/jetson-notify/run-notifier.sh

User crontab (shown as bash for Shiki compatibility):

crontab -e
# Add the following lines:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@reboot /home/arc/bin/wait_net_start_vnc.sh >>/home/arc/.local/state/vnc/boot.log 2>&1 &
@reboot /opt/jetson-notify/run-notifier.sh   >>/home/arc/.local/state/vnc/notifier.log 2>&1 &

Maintenance

  • Tail notifier output

    tail -f /home/arc/.local/state/vnc/notifier.log
  • Tail VNC stack logs

    tail -f /home/arc/.local/state/vnc/novnc.log
    tail -f /home/arc/.local/state/vnc/x11vnc.log
  • Pin stubborn device names (manual map)

    sudo mkdir -p /opt/jetson-notify
    sudo nano /opt/jetson-notify/hosts.json   # {"172.17.xx.yy":"DESKTOP-XYZ"}

Example notifications

Boot

βœ… arc-mobile is online β€’ IP: 172.17.xx.yy

SSH

πŸ”‘ SSH login: DESKTOP-XYZ (172.17.xx.yy)
πŸ”’ SSH disconnected: DESKTOP-XYZ (172.17.xx.yy)

VNC

πŸ–₯️ VNC connected: DESKTOP-XYZ (172.17.xx.yy)
πŸ”Œ VNC disconnected

Notes

  • Using cron keeps the notifier in the same lifecycle as your VNC starter script and log files.
  • If you ever switch back to systemd, remove the cron entry and re-enable the jetson-discord.service unit, then manage it with journalctl.