GoAdmio

mem

Show the top memory-using processes by physical and virtual size, and alert the administrator by email and WhatsApp when a single process uses more than 75% of memory

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


Overview

/go/mem shows which processes use the most memory, so you can find what is eating the server's RAM. It:

The alert looks at one process at a time. It does not measure total memory use across the server.


Quick start

/go/mem

Syntax

/go/mem
Form Behavior
/go/mem Prints both tables, then sends the alert if the memory condition is met.

Options

This command has no options. Arguments are only written to the log file.


Output

The command prints two tables, each under a line of dashes as wide as the terminal (40 characters if the width is unknown):

Section Sorted by Rows
MEMORY: %MEM, highest first The header row and the top 9 processes
VSIZE (VSZ): VSZ, highest first The header row and the top 9 processes

Each table has the standard ps aux columns: USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME, and COMMAND. An illustrative row:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
mysql     1021  2.1 18.4 2850312 1503244 ?     Ssl  Nov19  41:07 /usr/sbin/mariadbd

The alert

When the condition is met, the administrator gets an email and a WhatsApp message with this text:

High Memory Usage (82 %)
User: mysql
Command (MEM): /usr/sbin/mariadbd
Command (VSZ): /usr/sbin/mariadbd

The percentage is rounded down, and the command is only the program name (the first word of the command line, without its arguments).

Every run is also recorded in /var/log/go/mem.log.

[!NOTE] The command sends both messages every time it runs while the condition is true. Nothing limits how often alerts repeat.


Examples

# Show the biggest memory users, and alert if one is over 75%
/go/mem

Troubleshooting

Symptom Likely cause Fix
The server is nearly out of memory, but no alert arrives The alert fires only when one process uses more than 75%. Memory spread over many processes (for example many PHP-FPM workers) does not trigger it. Read the tables, or use memoryavg and heal.
Command (VSZ) is always the same as Command (MEM) Both values are taken from the memory ranking, so they are always identical. None. See How the alert is decided.
The VSIZE (VSZ) table has a different top process than the alert shows The alert never uses the VSZ ranking. Read the table for the biggest virtual sizes.
The alert shows only a program name Only the first word of the command line is reported. Find the full command line in the tables, or with ps.
Only 9 processes are listed in each table The header row is one of the 10 lines shown. None.
The command starts slowly or seems to hang It first looks up the server's public IP from the internet, with no time limit. This can wait a long time if the network is down. Check the server's internet access.
Repeated alerts An alert is sent on every run while the condition is true. Fix the memory problem, or lower how often the command runs.
No alert email or message arrives The administrator's email or WhatsApp details are missing, or mail or WhatsApp sending is not working. Check the address with email, and test mail with checkmail.

Details

How the alert is decided

The script looks at the first process in each ranking:

Value Where it comes from
User (MEM) The process with the highest %MEM
Memory (%) That process's %MEM, rounded down
Command (MEM) That process's program name
User (VSZ) The process with the largest VSZ. It is read but never shown or tested.
Memory and command (VSZ) Taken from the %MEM ranking again, so they are identical to the MEM values

The alert is sent when the rounded-down percentage is greater than 75, which means a process using 76% or more. Because the VSZ values are copied from the memory ranking, the second half of the check never changes the result.

%MEM is the share of physical memory the process uses right now. The VSZ column can be much larger than the installed RAM and is normal for many services.

Other values it reads

The script also reads the server hostname, the public IP address, and the administrator's email, mobile number, and WhatsApp settings from GoAdmio's settings database, but it does not use them itself. The public IP lookup is the only part that needs internet access.

Sending the alert

The email and the WhatsApp message are sent through GoAdmio's own sending helpers, to the administrator's contact details saved in GoAdmio. To change the email address, use email.


See also

Command Description
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
memoryavg Check the weekly server memory average
heal Monitor key services, memory, load, and disk, and automatically fix problems (Auto-Heal)
swap Create a swap file sized to RAM and set vm.swappiness
slice Apply server-wide CPU and memory limits to user-.slice
email Change the administrator email address GoAdmio uses for server notifications