Watching a variable#
The alert types of the server each watch for one fixed thing. The type Variable Watcher watches whatever you name: any value the server knows about itself, against a line you draw. "More than 500 users connected", "memory over 90 percent", "the job engine is not OK".
It is set up like any alert, in Preferences, Alerts. This page is about what can be watched and how to write the condition.
How it works#
Once a minute the server works out two values, compares them, and acts while the condition holds.
| Field | Is |
|---|---|
| Compare | usually a variable of the server: {concurrent_users} |
| Condition | Equals, Doesn't Equal, Contains, Doesn't Contain, Greater Than, Greater Than Or Equal, Less Than, Less Than Or Equal, Matches Pattern, Doesn't Match Pattern |
| With | what to compare with: a number, a text, a pattern, or another variable |
| Test | shows what a field stands for right now |
- The four greater and less conditions compare numbers. If either side is not a number, the alert does not fire.
- With both fields empty the condition is always true.
- In the alert's mail,
{var1}and{var2}are the two values as they were, and{condition}the condition.
What can be watched#
Every value of the server's status. These were read from a test server:
| Variable | Is | On the test server |
|---|---|---|
{concurrent_users} |
sessions open now | 1 |
{logged_in_users} |
of them, logged in | 1 |
{connected_unique_ips} |
different addresses connected | 1 |
{max_users} |
the licence's limit of sessions | 5 |
{incoming_transfers_count}, {outgoing_transfers_count} |
uploads and downloads under way | 0, 0 |
{current_upload_speed}, {current_download_speed} |
the server's speed now | 0, 0 |
{ram_used_percent} |
share of its memory the server uses | 2 |
{ram_free}, {ram_used}, {ram_max} |
the same in bytes | |
{thread_pool_busy}, {thread_pool_available}, {max_threads} |
the server's worker threads | 7, 12, 2000 |
{open_files}, {max_open_files} |
files the server has open, and the system's limit; -1 where the system does not say | |
{failed_logins}, {successful_logins}, {total_logins} |
counted since the start | 25, 95, 131 |
{last_login_user}, {last_login_ip}, {last_login_date_time} |
the newest login | |
{health_overall} |
OK, or the worst state of the checks below |
OK |
{health_job_engine}, {health_replication}, {health_serverbeat} |
OK, DISABLED, or what is wrong |
OK, DISABLED, DISABLED |
{replicated_servers_count} |
other servers this one replicates with | 0 |
{running_event_threads} |
events of users being handled now | 0 |
{update_available} |
true when a newer version can be installed |
false |
{allow_logins} |
false while logins are stopped from the admin pages |
true |
{hostname}, {version_info_str} |
the machine's name, the server's version |
The same names work with server_ in front, and written with percent signs: %server_concurrent_users%.
The address POST /tests/job-variable of the API works a line of variables out, as Test does in the form. On the test server, {ram_used_percent} % of memory, {thread_pool_busy} threads busy, health {health_overall} gave:
6 % of memory, 7 threads busy, health OK
Watchers worth having#
| Watch for | Compare | Condition | With |
|---|---|---|---|
| the licence nearly used up | {concurrent_users} |
Greater Than Or Equal | a number a little under {max_users} |
| memory | {ram_used_percent} |
Greater Than | 90 |
| the server running out of threads | {thread_pool_busy} |
Greater Than | 1500, with max_threads at 2000 |
| running out of file handles | {open_files} |
Greater Than | three quarters of {max_open_files} |
| anything unhealthy | {health_overall} |
Doesn't Equal | OK |
| the job engine | {health_job_engine} |
Doesn't Equal | OK |
| logins left stopped after maintenance | {allow_logins} |
Equals | false |
| an unusually quiet server in working hours | {concurrent_users} |
Less Than | 1 |
It fires every minute#
A watcher is not an event; it is a state that is looked at every minute. While the condition holds, the alert acts every minute, up to its Max of … alerts per hour.
So set the limit of a watcher to 1 or 2. A watcher on memory at the usual 60 an hour is sixty mails an hour for as long as memory stays high.
It does not say when the state is over. For that, have a second watcher with the opposite condition, or rely on the first one falling silent.
Beyond the server's own values#
| To watch | Use |
|---|---|
| something in the activity record: counts of uploads, failed logins by address, a partner's silence | Report alerts and expected files |
| a disk | the type Disk Space Below Threshold, which is made for it |
| many values over time, with charts and history | Prometheus metrics: a watcher tells you now, a monitoring system shows you the last month |
| whether the server answers at all | Health checks, from outside |
Things to know#
- A minute is the finest grain. A spike of ten seconds between two looks is not seen.
- Text comparisons are exact about capitals:
okdoes not equalOK. - A number on text never fires.
{health_overall}Greater Than0is silent for ever. Use Test to see what a variable really holds. - In a cluster each server watches its own values.