GoAdmio

visits

Count access-log requests and unique IP addresses for the last hour, day, or week, and estimate how many requests the server could handle

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


Overview

/go/visits answers two questions: how much traffic did the server get, and roughly how much more could it take? It:

It only reads logs. Nothing is changed.

[!NOTE] The capacity figure is a rough guide. It assumes all the load comes from visits and that load grows in step with them. See How the estimate works.


Quick start

# Last 24 hours
/go/visits

Syntax

/go/visits [hour|day|week|<seconds>]

Arguments

Argument Window Notes
none Last 24 hours The default.
hour Last 3,600 seconds
day Last 86,400 seconds
week Last 604,800 seconds
<seconds> The given number of seconds before now A whole number, for example 1800 for 30 minutes.
anything else Last 24 hours No error. An unknown word such as month silently falls back to the default.

Output

12840 / 58363
Count Unique IPs: 3120

The sample above is illustrative.

Line Meaning
First line, left number Requests in the window.
First line, right number Estimated requests the server could handle in the same window at 100% of its busiest resource.
Count Unique IPs Distinct client addresses in the window.

Examples

# Last 24 hours
/go/visits
# Last hour
/go/visits hour
# Last week
/go/visits week
# Last 30 minutes
/go/visits 1800

Troubleshooting

Symptom Likely cause Fix
division by zero attempted or an empty right-hand number The average load or memory figure is 0 (or the log is empty), so the estimate cannot be calculated. Run loadavg and memoryavg, and try again when they have data.
[: -ge: unary operator expected The load or memory log is empty. Same as above.
Visits is 0 No traffic in the window, the log was rotated, or the log format is different. Try a longer window, and check the access log.
week or day shows less than expected Only the current access log is read. If logs rotate daily, older requests are not in it. Check the rotation with logrotate.
A typo such as weeks still works Unknown words fall back to 24 hours. Use hour, day, week, or a number of seconds.
Visits looks too high Every request is counted: images, CSS, scripts, bots, and health checks. Look closer with httptop, bots, or iptop.
Capacity looks too low or too high The load average covers a longer period than the window, and non-visit work such as backups or cron raises it. Treat it as a rough guide.
Slow on a busy server The whole log is read twice. Wait, or run at a quiet time.

Details

What it does

flowchart TD
    A["/go/visits [window]"] --> B["Append the command to /var/log/go/visits.log"]
    B --> C["Find the access log"]
    C --> D["Work out the cutoff time from the window"]
    D --> E{"load.log and memory.log exist?"}
    E -- "No" --> F["Run loadavg and memoryavg"]
    E -- "Yes" --> G["Average the load and memory logs"]
    F --> G
    G --> H["Count requests newer than the cutoff"]
    H --> I["Count unique IP addresses"]
    I --> J["Estimate capacity and print"]

Steps in order

  1. Appends a timestamped line with the arguments to /var/log/go/visits.log.
  2. Finds the access log.
  3. Works out the cutoff time (now minus the window).
  4. If /var/log/load.log or /var/log/memory.log is missing, creates it with loadavg or memoryavg.
  5. Averages the first column of each log, rounded down to a whole number.
  6. Counts the access-log lines newer than the cutoff.
  7. Counts the unique IP addresses in those lines.
  8. Prints the requests, the capacity estimate, and the unique IP count.

How the estimate works

capacity = requests / busiest resource % x 100

The busiest resource is whichever is higher, the average memory percentage or the average load percentage.

Example value Number
Requests in the window 12,840
Average load 14%
Average memory 22%
Busiest resource Memory (22%)
Estimate 12,840 / 22 x 100 = 58,363

Limits of this method:

What is counted

Item Rule
Requests One per access-log line with a time in field 6 newer than the cutoff. Every request counts, not only page views.
Unique IPs Distinct values of field 4 when it is not -, otherwise field 3.

The log must be pipe-separated, with the request time as a Unix timestamp in field 6. Other formats give zero or wrong results.

Notes


See also

Command Description
loadavg Check the weekly server load average
memoryavg Check the weekly server memory average
usertop Check recent visitors per domain
iptop Track the most visited IP addresses on a server
httptop Display active HTTP requests in real time
bots Track all bot visits to your server (good and bad bots)
compare Compare multiple GoAdmio servers based on visits and resource usage
logrotate Configure daily or default log rotation for Apache and Nginx