GoAdmio

loadavg

Record the server's current CPU load, print this week's average as a percentage of CPU capacity, and alert the administrator by email and WhatsApp when it passes 70%

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


Overview

/go/loadavg tells you how busy the server has been over the current week. Each time it runs, it:

The weekly log is cleared on Sunday just after midnight, so every week starts fresh.

The command does not schedule itself. It is meant to run regularly (every few minutes or hourly, for example) from a cron job. The more often it runs, the more samples the average is built from. See cron for GoAdmio's scheduled jobs.


Quick start

/go/loadavg

The command prints a number such as 37, meaning the average load this week is 37% of the server's CPU capacity.


Syntax

/go/loadavg

The command takes no arguments. Anything you add is written to the log and otherwise ignored.


Output

A single whole number:

37
Value Meaning
0 to 99 The average load is below the capacity of the CPU.
100 The CPU is fully used on average.
Above 100 More work is waiting than the CPU can handle on average.
Above 70 An alert is sent.

The number is rounded down, so a very small load shows as 0.

Alert messages

When the average is above 70, the administrator receives:

High Load Averages (82 %)

by email (as both the subject and the message) and by WhatsApp. The number in brackets is the weekly average.


Examples

# Take a sample and show the weekly average
/go/loadavg
# Look at the samples collected so far this week
cat /var/log/load.log
# Count the samples
wc -l < /var/log/load.log
# See the latest samples, one per run
tail -5 /var/log/load.log

Troubleshooting

Symptom Likely cause Fix
The output is 0 The load is very low (the value is rounded down), or this is the first run after the weekly reset. Run it again later, or check the current load with cpu.
The average jumps or restarts on Sunday just after midnight The sample file is deleted on every run between 00:00 and 00:59 on Sunday. This is expected. See Weekly reset.
The average is low but the server feels slow right now The result is an average of the whole week, so a short spike barely moves it. Use cpu or top to see what is busy right now.
Alerts keep arriving There is no cooldown: every run with an average above 70 sends another alert. Reduce the load, or run the command less often.
No alert email or WhatsApp arrives The administrator email, mobile number, or WhatsApp settings are missing or wrong. Check the administrator email with email, and the WhatsApp settings in GoAdmio.
The command is slow, or hangs briefly It looks up the server's public IP address on every run, and waits if there is no internet connection. Fix the network connection. See Known limitations.
The percentage looks too low on a virtual machine The CPU thread count may be counted too high. See Known limitations. Compare with nproc.
/var/log/load.log is missing It is deleted every Sunday just after midnight. It is created again on the next run.

Details

How the percentage is calculated

The command reads the server's 1-minute load average and divides it by the number of CPU threads:

percentage = 1-minute load × 100 ÷ CPU threads

For example, a load of 2.0 on a server with 4 CPU threads gives 50. At 100, every thread is busy all the time.

The weekly average is the mean of every percentage saved in /var/log/load.log since the last reset, rounded down.

How it works

flowchart TD
    A["loadavg"] --> B{"Sunday, hour 00?"}
    B -- "Yes" --> C["Delete /var/log/load.log"]
    B -- "No" --> D["Keep the file"]
    C --> E["Read 1-minute load and CPU thread count"]
    D --> E
    E --> F["Compute percentage, append to /var/log/load.log"]
    F --> G["Average all samples in the file"]
    G --> H["Print the average"]
    H --> I{"Average above 70?"}
    I -- "Yes" --> J["Send email and WhatsApp alert"]
    I -- "No" --> K["Done"]
  1. Logs the call to /var/log/go/loadavg.log.
  2. Reads the server's hostname, public IP address, and the administrator's email, mobile number, and WhatsApp settings from GoAdmio's configuration. (None of these are used later in the script. The alert commands read their own settings.)
  3. Checks the day and hour. On Sunday between 00:00 and 00:59, deletes /var/log/load.log.
  4. Counts the CPU threads and reads the 1-minute load average.
  5. Computes the percentage, rounded down, and appends it to /var/log/load.log.
  6. Averages every value in the file, rounded down, and prints it.
  7. If the average is above 70, sends the alert by email and by WhatsApp.

Weekly reset

The file is deleted when the day is Sunday and the hour is 00 in the server's time zone (see timezone). The check doesn't care about the minute, so if the command runs more than once during that hour, the file is deleted again each time. Within that hour the "average" is just the latest sample, and an alert can fire on a single reading.

Files used

File Purpose
/var/log/load.log One whole-number sample per run, deleted every Sunday just after midnight.
/var/log/go/loadavg.log A log of each time the command ran, with its arguments.
/var/lib/sqlite/config.db Where the administrator's contact details are read from.

Known limitations


See also

Command Description
memoryavg Check the weekly server memory average
cpu Show the server's CPU load and its top CPU-consuming processes, and send an alert when one process uses most of the CPU
top Show the top CPU-consuming processes and their parent command
mem Check the top ten memory-consuming commands or services
heal Monitor key services, memory, load, and disk, and automatically fix problems
cron Rebuild GoAdmio's cron jobs, server-wide or for one domain
email Change the administrator email address GoAdmio uses for server notifications