Installs scalyr-agent-2 into a Python venv under /opt, with config + state + logs under /etc/scalyr-agent-2/ (matching your working layout).
This revision uses a single scalyr control wrapper that:
- always uses
-c /etc/scalyr-agent-2/agent.json - always suppresses the
pkg_resourcesdeprecation warning - supports
scalyr start,scalyr stop,scalyr status -v - is used by systemd (full path) and humans (via
$PATH) - lets you keep the API key out of
agent.jsonby reading it from an env file
Tip
Want the TLDR? Run the TURBO installer (Rocky 9 specific):
# Note: Requires 'curl' to be installed
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/sva-s1/collector/main/scripts/turbo-collector-setup-rocky9.sh)"The installer will automatically install any missing system dependencies (like ca-certificates) using dnf.
curl- Required to download the installer scriptdnf- Package manager for installing dependencies (included in Rocky Linux)
sudo dnf -y update
# Install required tools if not already present
if ! command -v curl >/dev/null 2>&1; then
sudo dnf install -y curl
fi
# Additional dependencies that will be installed automatically if missing:
# - git: required because pip installs from a Git tag (pip shells out to git)
# - build tooling: compile wheels if needed on your platform
# - nmap-ncat: provides `nc` for the tests
sudo dnf -y install \
python3 python3-pip git \
gcc make python3-devel \
openssl-devel libffi-devel \
nmap-ncat tcpdumpQuick sanity (avoids the “Cannot find command 'git'” surprise):
command -v git
git --version
command -v nc
nc -h | head -n 1 || trueThis matches:
agent_log_path:/etc/scalyr-agent-2/logagent_data_path:/etc/scalyr-agent-2/data
sudo mkdir -p /etc/scalyr-agent-2/{agent.d,data,log}
sudo chown -R root:root /etc/scalyr-agent-2
sudo chmod 755 /etc/scalyr-agent-2Create the /opt home for the venv + wrapper:
sudo mkdir -p /opt/scalyr-agent-2
sudo chown -R root:root /opt/scalyr-agent-2
sudo chmod 755 /opt/scalyr-agent-2sudo python3 -m venv /opt/scalyr-agent-2/venv
sudo /opt/scalyr-agent-2/venv/bin/pip install --upgrade pip setuptools wheel
# Install from tag
sudo /opt/scalyr-agent-2/venv/bin/pip install \
"git+https://github.com/scalyr/scalyr-agent-2.git@v2.2.19"The noisy pkg_resources deprecation warning shows up when running the agent CLI directly.
So at this stage we do a simple import-only sanity check.
sudo /opt/scalyr-agent-2/venv/bin/python -c "import scalyr_agent; print('scalyr_agent import: OK')"We’ll run the real scalyr status -v check after the wrapper exists (the wrapper suppresses the warning).
Create /etc/scalyr-agent-2/scalyr.env (root-only). This keeps the key out of agent.json.
sudo tee /etc/scalyr-agent-2/scalyr.env >/dev/null <<'ENV'
# Required (this is your "Log Access Write" API key)
#
# Get your key from: https://community.sentinelone.com/s/article/000006763
# 1) Log into your Singularity Data Lake console
# 2) Navigate to Settings > API Keys
# 3) Generate a "Log Access Write" key
# 4) Paste it below
SCALYR_API_KEY="REPLACE_ME"
# SentinelOne Regional Endpoint
# US1 is the default region. For other regions, see:
# https://community.sentinelone.com/s/article/000004961
#
# Common regions:
# US1: https://xdr.us1.sentinelone.net
# US2: https://xdr.us2.sentinelone.net
# EU1: https://xdr.eu1.sentinelone.net
# AP1: https://xdr.ap1.sentinelone.net
# AP2: https://xdr.ap2.sentinelone.net
#
# Optional: set server via env instead of JSON:
# SCALYR_SERVER="https://xdr.us1.sentinelone.net"
ENV
sudo chmod 600 /etc/scalyr-agent-2/scalyr.env
sudo chown root:root /etc/scalyr-agent-2/scalyr.envLoad it for your current shell (optional, for immediate testing):
set -a
source /etc/scalyr-agent-2/scalyr.env
set +aImportant: omit api_key here if you want the env var to be used.
sudo tee /etc/scalyr-agent-2/agent.json >/dev/null <<'JSON'
{
"ca_cert_path": "/etc/ssl/certs/ca-bundle.crt",
"scalyr_server": "https://xdr.us1.sentinelone.net",
"agent_log_path": "/etc/scalyr-agent-2/log",
"agent_data_path": "/etc/scalyr-agent-2/data",
"implicit_metric_monitor": false,
"implicit_agent_process_metrics_monitor": false,
"server_attributes": {
"serverHost": "localhost"
},
"monitors": [
{
"module": "scalyr_agent.builtin_monitors.syslog_monitor",
"protocols": "tcp:514, udp:514",
"accept_remote_connections": true,
"message_log": "fortigate.log",
"parser": "marketplace-fortinetfortigate-latest"
}
]
}
JSONLock it down:
sudo chmod 600 /etc/scalyr-agent-2/agent.json
sudo chown root:root /etc/scalyr-agent-2/agent.jsonThis wrapper bakes in:
- the config path (
-c /etc/scalyr-agent-2/agent.json) - warning suppression (
PYTHONWARNINGS=...) - loads
/etc/scalyr-agent-2/scalyr.envso humans + systemd behave the same
sudo tee /opt/scalyr-agent-2/scalyr >/dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
CONFIG="/etc/scalyr-agent-2/agent.json"
ENVFILE="/etc/scalyr-agent-2/scalyr.env"
PY="/opt/scalyr-agent-2/venv/bin/python"
# Load secrets if present (SCALYR_API_KEY, optionally SCALYR_SERVER, etc.)
if [[ -f "$ENVFILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$ENVFILE"
set +a
fi
# Suppress the noisy warning:
# /.../repoze/__init__.py: UserWarning: pkg_resources is deprecated as an API...
export PYTHONWARNINGS='ignore:pkg_resources is deprecated as an API:UserWarning'
# Optional: quiet "already running" noise on `start`
if [[ "${1:-}" == "start" ]]; then
set +e
out="$("$PY" -m scalyr_agent.agent_main -c "$CONFIG" "$@" 2>&1)"
rc=$?
set -e
if echo "$out" | grep -qi "already running"; then
exit 0
fi
if [[ $rc -ne 0 ]]; then
echo "$out" >&2
exit $rc
fi
echo "$out"
exit 0
fi
exec "$PY" -m scalyr_agent.agent_main -c "$CONFIG" "$@"
EOF
sudo chmod 0755 /opt/scalyr-agent-2/scalyrOn Rocky, sudo often uses a restricted secure_path which may not include /usr/local/bin. The simplest fix is to symlink into /usr/bin.
sudo ln -sf /opt/scalyr-agent-2/scalyr /usr/bin/scalyr
sudo chmod 0755 /opt/scalyr-agent-2/scalyr /usr/bin/scalyr
command -v scalyr
sudo command -v scalyrNow we can do the real sanity check without the warning:
sudo scalyr status -v || trueIf this host should accept remote syslog on 514:
sudo firewall-cmd --permanent --add-port=514/tcp
sudo firewall-cmd --permanent --add-port=514/udp
sudo firewall-cmd --reloadCreate:
/etc/systemd/system/scalyr-agent-2.service
sudo tee /etc/systemd/system/scalyr-agent-2.service >/dev/null <<'INI'
[Unit]
Description=Scalyr Agent 2 (venv wrapper)
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
# Wrapper already loads /etc/scalyr-agent-2/scalyr.env, but systemd can too (harmless redundancy)
EnvironmentFile=-/etc/scalyr-agent-2/scalyr.env
ExecStart=/opt/scalyr-agent-2/scalyr start
ExecStop=/opt/scalyr-agent-2/scalyr stop
ExecReload=/opt/scalyr-agent-2/scalyr stop && /opt/scalyr-agent-2/scalyr start
# Helpful: dump verbose agent status into the journal right after starting
ExecStartPost=/opt/scalyr-agent-2/scalyr status -v
Restart=on-failure
RestartSec=5s
User=root
Group=root
[Install]
WantedBy=multi-user.target
INIEnable + start:
sudo systemctl daemon-reload
sudo systemctl enable --now scalyr-agent-2Note: If you change values in
scalyr.env, you must restart the service for them to take effect.
sudo systemctl status scalyr-agent-2 --no-pager -l
sudo scalyr status -vsudo ss -luntp | egrep ':(514)\b'Running the test on the agent host itself, using 127.0.0.1:
UDP:
printf '<189>1 2025-12-17T00:00:00Z nc-local FortiGate-40F-SVA - - - msg="local udp test"\n' \
| nc -u -v 127.0.0.1 514TCP:
printf '<189>1 2025-12-17T00:00:00Z nc-local FortiGate-40F-SVA - - - msg="local tcp test"\n' \
| nc -v 127.0.0.1 514sudo tail -n 200 -f /etc/scalyr-agent-2/log/agent.log
sudo tail -n 200 -f /etc/scalyr-agent-2/log/fortigate.log- Give it 60+ seconds
- Go to Search
- Choose XDR view
- Search:
logfile = '/etc/scalyr-agent-2/log/fortigate.log'
- Time range: Last 10 minutes
- If empty, switch view to All Data
You’re installing from a Git tag, so pip shells out to git. Fix:
sudo dnf -y install git
command -v git
git --versionYou likely symlinked only into /usr/local/bin. Rocky sudo can ignore that path. Fix:
sudo ln -sf /opt/scalyr-agent-2/scalyr /usr/bin/scalyr
sudo command -v scalyr- Confirm firewall is open:
sudo firewall-cmd --list-ports
- Confirm the process is listening:
sudo ss -luntp | grep -E ':(514)\b'
- Confirm packets are arriving:
sudo tcpdump -ni any port 514
Environment-aware variables apply only at startup. Restart:
sudo systemctl restart scalyr-agent-2
sudo scalyr status -v# Verbose agent status
sudo scalyr status -v
# Restart + immediately show recent logs
sudo systemctl restart scalyr-agent-2 && sudo journalctl -u scalyr-agent-2 -n 200 --no-pager