GoAdmio

uptime

Check the websites (by URL) and servers (by IP or hostname) listed in /var/go/etc/uptime, and send email and WhatsApp alerts for any that are down

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


Overview

/go/uptime checks, once, every site and server in your list and tells you which ones do not answer. It:

[!NOTE] The command checks once and exits. It remembers nothing between runs, so a host that stays down triggers new alerts on every run, and there is no "back up" message. To monitor continuously, run it from cron.


Quick start

# 1. List what to monitor, one entry per line
printf '%s\n' "https://example.com" "203.0.113.10" | sudo tee /var/go/etc/uptime

# 2. Run the checks
/go/uptime

Syntax

/go/uptime

The command takes no options. Anything you type after it is only written to the log.


The host list

The list file is /var/go/etc/uptime. If it does not exist, the command prints File /var/go/etc/uptime not found. and stops with exit code 1.

https://example.com
https://shop.example.net
203.0.113.10
server2.example.org
Entry Treated as Check
Starts with http Website Fetches pages and looks for </html>.
Anything else Server Connects to port 22 (SSH).

List rules

Rule Detail
One entry per line Spaces before and after an entry are removed.
End the file with a newline The last line is skipped if the file does not end with a newline.
No blank lines or comments A blank line or a line starting with # is treated as a server name and ends in a false "down" alert.
Website entries Give the address only, such as https://example.com. No query string, and no trailing /.
Server entries A name or IP address, with no port. The port is always 22.

Output

Line Meaning
[<n>] Web Server is up: <url>... The website answered.
[<n>] Web Server is down: <url>... Five attempts failed. An alert was sent.
[<n>] Monitor is up: <host>... The server accepted a connection on port 22.
[<n>] Monitor is down: <host>... Five attempts failed. An alert was sent.
<entry>: Test Again <1-5> An attempt failed and another will follow after 12 seconds.

<n> is the entry's line number in the list.

[1] Web Server is up: https://example.com...
https://shop.example.net: Test Again 1
[2] Web Server is up: https://shop.example.net...
203.0.113.10: Test Again 1
203.0.113.10: Test Again 2
203.0.113.10: Test Again 3
203.0.113.10: Test Again 4
203.0.113.10: Test Again 5
[3] Monitor is down: 203.0.113.10...

The sample above is illustrative.


Examples

# Run all checks once
/go/uptime
# Add a site to the list
echo "https://example.com" | sudo tee -a /var/go/etc/uptime
# Example crontab entry: every 5 minutes, never two runs at once
*/5 * * * * flock -n /var/lock/go-uptime.lock /go/uptime >/dev/null 2>&1
# Test one website by hand, the way the command does (1 or more = up)
curl -sL "https://example.com/index.php" | grep -c "</html>"
# Test one server by hand
nc -z 203.0.113.10 22 && echo open

Troubleshooting

Symptom Likely cause Fix
File /var/go/etc/uptime not found. The list does not exist. Create it (see The host list).
The last entry is never checked The file does not end with a newline. Add a newline at the end of the file.
A "down" alert for an entry that does not exist A blank line or a comment line in the list. Remove it.
A server that is up shows as down SSH listens on another port, a firewall blocks port 22, or nc (netcat) is not installed. Use port to check the SSH port, open it in the firewall, and install nc.
A website shows as down but opens in a browser An invalid or expired SSL certificate, a page that is not HTML (JSON or plain text), </HTML> in capitals, or a firewall or proxy that blocks curl. Run the curl example and look at what comes back.
A broken website shows as up Only </html> is checked, not the HTTP status. A 404, 500, or 502 error page that contains </html> counts as up. Check the site by hand, or watch error logs.
The command seems stuck No time limit is set on the checks, so a server that accepts a connection and never answers can block the run. Press Ctrl+C and check that host.
The same alert arrives on every run Nothing is remembered between runs. Fix the host, or remove it from the list while it is down.
The run takes a long time Each down host adds about a minute (5 attempts, 12 seconds apart) plus request time. Reduce the list, or schedule with flock as in the examples.
"Down" is shown but no alert arrives The email or WhatsApp settings are missing or wrong in GoAdmio. Check them with config and email.

Details

What it does

flowchart TD
    A["/go/uptime"] --> B["Append the command to /var/log/go/uptime.log"]
    B --> C{"/var/go/etc/uptime exists?"}
    C -- "No" --> D["Print error and exit"]
    C -- "Yes" --> E["Read the next entry and trim it"]
    E --> F{"Starts with http?"}
    F -- "Yes" --> G["Fetch two pages, look for </html>"]
    F -- "No" --> H["Connect to port 22"]
    G --> I{"Answered?"}
    H --> I
    I -- "No, fewer than 5 tries" --> J["Wait 12 seconds and try again"]
    J --> I
    I -- "Yes" --> K["Print up"]
    I -- "No, 5 tries used" --> L["Print down, send email and WhatsApp"]
    K --> E
    L --> E

Steps in order

  1. Appends a timestamped line with the arguments to /var/log/go/uptime.log.
  2. Stops if /var/go/etc/uptime is missing.
  3. Reads the list one line at a time, trimming spaces.
  4. For each entry, tries up to 5 times, waiting 12 seconds after each failure.
  5. Prints the result. For a down entry, sends an email and a WhatsApp message with the helpers /go/sendmail and /go/sendwhatsapp.

Website check

Item Detail
Pages requested <url>/index.php?T=<timestamp> and <url>/apartment-<timestamp>
Cache The timestamp makes each address unique, so a cached copy is not used.
Browser identity Sent as a Chrome browser.
Redirects Followed.
Up when Either response contains </html>.

The second address normally does not exist, so a normal "page not found" page also counts as up. An invalid or expired SSL certificate gives an empty answer, so the site counts as down.

Server check

Item Detail
Test nc -z <host> 22
Up when Port 22 accepts the connection.
Checks The SSH service only, not websites or other services on that host.

Notes


See also

Command Description
cron Set up main cron jobs in GoAdmio
email Change the server's main GoAdmio contact email
config Show or edit the server's GoAdmio configuration
send Send queued WhatsApp messages through logged-in devices
port Change the default SSH port (22) to another port
checkssl Check if SSL certificates are installed for all domains
checkfirewall Verify that important required ports are open on your server
status Collect the status of every systemd service