GoAdmio

usertop

Show the busiest domains in the access log and, when server load is high, check for bots or switch on Cloudflare Under Attack Mode

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/usertop shows which of your domains received the most requests recently. It:

[!WARNING] Without an argument, /go/usertop is not read-only. If the server load is high, it changes Cloudflare settings and sends alerts, even when you run it by hand. To only look at the numbers, use /go/usertop history.


Quick start

# Busiest domains right now (and automatic load protection)
/go/usertop

# Busiest domains over a longer period, with no actions
/go/usertop history

Syntax

/go/usertop [history]

Arguments

Argument Required Notes
history No Counts the last 10,000 log lines and stops. No load check and no actions.

Any other first argument is ignored and behaves like no argument, including the load actions.


Output

Mode Lines counted What you see
Default Last 100 Up to 10 lines: <count> <domain>, then messages from any action.
history Last 10,000 Up to 10 lines: <count> <domain>.
   41 example.com
   27 shop.example.net
    9 blog.example.org

The sample above is illustrative. The leading www. is removed, so www.example.com and example.com are counted together.

Other messages:

Message Meaning
Instance (<value>) already running. A backup is running. The command stopped with exit code 1.
Turn On Under Attack Mode: <domain> The load was 100% or more and the command switched protection on for that domain.

Examples

# Recent busiest domains, plus automatic actions if the server is overloaded
/go/usertop
# Longer view, safe to run any time
/go/usertop history
# Work out the load percentage by hand (first number divided by the CPU count)
cat /proc/loadavg
nproc
# See when Under Attack Mode was switched on automatically
tail /var/log/go/underattack.log

Troubleshooting

Symptom Likely cause Fix
Instance (...) already running. A backup lock file less than one hour old exists. Wait for the backup to finish. A lock file older than one hour is ignored.
Under Attack Mode switched on unexpectedly The load average reached the number of CPU threads, and the busiest domain was picked. That domain may not be the cause. Turn protection off with securitylevel or in the Cloudflare dashboard, then look at cpu and iptop.
Alerts repeat Each run with load at 100% or more repeats the actions and alerts. Fix the cause of the load, or stop the scheduled runs while you work.
The alert says "Under DDoS Attack" but nothing changed in Cloudflare The domain is not on Cloudflare, or the Cloudflare access is not set up. The alert is sent whether or not underattack worked. Check the domain's Cloudflare setup.
The "CPU" percentage looks wrong It is the 1-minute load average divided by CPU threads, not real CPU use. Backups and disk waits raise it too. Use cpu and mem for real usage.
Empty list The log is empty or was just rotated. Check again after traffic arrives.
A domain name looks changed www followed by any character is removed from every name, even in the middle. Treat names such as mywwwsite.com with care.
Slow start The server's public IPv4 and IPv6 addresses are looked up first. Wait a few seconds.

Details

What it does

flowchart TD
    A["/go/usertop [history]"] --> B["Append the command to /var/log/go/usertop.log"]
    B --> C{"Backup lock under 1 hour old?"}
    C -- "Yes" --> D["Print message and exit"]
    C -- "No" --> E["Calculate server load %"]
    E --> F{"Argument is history?"}
    F -- "Yes" --> G["Print top 10 of the last 10,000 lines"]
    F -- "No" --> H["Print top 10 of the last 100 lines"]
    H --> I{"Server load"}
    I -- "Below 10%" --> J["Done"]
    I -- "10% to 99%" --> K["Run iptop robot"]
    I -- "100% or more" --> L["Under Attack Mode for the busiest domain, iptop underattack, email and WhatsApp alerts"]

Server load

The server load is the 1-minute load average divided by the number of CPU threads, as a percentage. On a server with 4 threads, a load average of 4.2 is 105%.

Server load What happens
Below 10% The list is printed and nothing else happens.
10% to 99% Runs iptop robot, which checks for non-human traffic.
100% or more Switches on Under Attack Mode for the busiest domain, runs iptop underattack, and sends an email and a WhatsApp alert.

Steps in order

  1. Appends a timestamped line with the arguments to /var/log/go/usertop.log.
  2. Finds the access log.
  3. Stops if a backup lock file (/usr/local/goadmio/lock/backup.lock) was changed within the last hour.
  4. Looks up the server's public IPv4 and IPv6 addresses. The result is not used.
  5. Calculates the server load percentage.
  6. With history: prints the top 10 domains from the last 10,000 lines and stops.
  7. Otherwise: prints the top 10 domains from the last 100 lines, then acts on the load as shown above.

Under Attack Mode

When the load is 100% or more:

  1. The busiest domain among the last 250 log lines is chosen. This is a longer window than the 100 lines shown in the list, so the two can differ.
  2. The action is written to /var/log/go/underattack.log.
  3. underattack is run for the domain, which turns on Cloudflare Under Attack Mode.
  4. iptop underattack is run (see iptop).
  5. An email and a WhatsApp message are sent: "Under DDoS Attack (CPU: <load>%)".

Under Attack Mode shows visitors a short browser check before the site loads. Nothing in this command turns it off again.

Notes


See also

Command Description
underattack Enable Cloudflare Under Attack Mode for a domain
securitylevel Set the Cloudflare security level for a domain or all hosted domains
iptop Track the most visited IP addresses on a server
ddos Track and block DDoS attack IPs in GoAdmio
httptop Display active HTTP requests in real time
cpu Check the top ten CPU-consuming commands or services
loadavg Check the weekly server load average
visits Check daily visits and estimate capacity