Prevent downtime by keeping an eye on the health of your servers
Contents
Server health monitoring allows you to prevent downtime by keeping an eye on your server at all times. Define what aspects of your server you want to monitor, and Semonto will notify you when an issue needs your attention.
This article will show you exactly how to get started.
Semonto’s reachability feature checks if a given URL is reachable, verifies the HTTP server result code and whether your website loads. With a server health monitor, we go deeper behind the scenes and can test the server load, disk space and server usage in more detail. You can also write custom tests to reflect when your server and web application are in good condition or have some issues. For example, you could check the status of queues, process application logs and more.
If you want to monitor the health of a server, you first need access to that server. This is why you create a server health point, also known as a health check URL or health endpoint. It acts as a portal for external monitoring. The server will perform tests and return the status of these tests through a secure URL that you have created, for example, https://myserver/health
. Optionally, and depending on your settings, it can also provide some extra data about the results when requested.
In theory, all types of servers are supported. Semonto calls the server health endpoint and processes the answer. Your server is responsible for performing and executing all the tests. When setting up the test, select the framework that corresponds with the software stack you already have on your server and are using for your websites or web applications. This will ensure that your current stack is performing as expected. Semonto supports multiple frameworks and plugins, going from PHP and Laravel to Python and platforms like WordPress and Drupal. As we use standard communication methods, server OSs like Windows and all Linux distributions such as Debian and Ubuntu are also supported.
Getting started with server health checking is a two-step process.
As explained, the health endpoint will perform the tests on the server and return its health status. There is no official standard for this, and it is usually done via the HTTP status code.
The status code should be 200 when the server is healthy and higher than 400 when something is wrong. HTTP 200 is the “All OK” code. See our docs about the most common website and serve errors.
Additionally, some health endpoints return extra metadata to give more insight into the server condition, such as the current RAM usage, disk usage, server load, state of queues and so on. Semonto has extended support for both.
You can create and implement your own health endpoint or use existing frameworks, plugins, or modules. Ideally, you use a system that is identical to the software stack that is already running on your server and is used for your web application on the server.
Health endpoints typically run on a /status or /health directory, but that is not enforced by Semonto, so you can use any URL and location you prefer, as long as Semonto can reach it.
Semonto framework: The Semonto framework is developed for PHP 7.4 and higher and should run on all PHP servers. The framework exposes a set of default health tests and gives you an interface to add custom tests easily. See here for more information.
Semonto WordPress plugin: Use our Semonto WordPress Health plugin available from the plugin store
Laravel-health: See Spatie how to install this package on your Laravel server. Make sure that the secret key matches the configured secret key on your Laravel server and the header name is set to oh-dear-health-check-secret
.
Drupal Health Check URL: If you use Health Check Url you can select in Semonto the “Drupal Health Check Url” endpoint type. Be sure to configure the plugin to return "passed" if everything is OK.
Drupal Health Check and other Drupals: If you use Health check or another plugin for the server health. Be sure to select in Semonto the “HTTP Status code only”, as those endpoints do not return extra metadata, but will return the status via the HTTP Code.
WordPress: Plugin Health Endpoint is compatible with Semonto if the "HTTP Status code only" option from the endpoint types is used.
Other frameworks: If you use another framework that is not listed here, there are two options:
As a fallback, or if you do not trust existing frameworks, you can create your own health endpoint. This could simply use the HTTP code to return the status of your server. HTTP 200 when everything is OK, or an HTTP 500 when something bad is going on. Be sure to select “HTTP Status Code Only” in Semonto in this case.
If you want to also return more detailed test information, your endpoint should return a JSON that matches some requirements. The easiest to implement will be the Semonto Health Framework.
If you want to be compatible with our Semonto health format, keep the following in mind.
{
"results": [
{
"name": "Current load",
"description": "Load: 0",
"value": 0,
"status": "ok"
}, {
"name": "Load average 5 min",
"description": "Load average: 0",
"value": 0,
"status": "ok"
}, {
"name": "Load average 15 min",
"description": "Load average: 0",
"value": 0,
"status": "ok"
}, {
"name": "MySQL Ping",
"description": "Total time: 2.0E-5",
"value": 2.0e-5,
"status": "ok"
}, {
"name": "MySQL Fetch Operation",
"description": "Total time: 0.00017",
"value": 0.00017,
"status": "ok"
}, {
"name": "Disk space",
"description": "/dev/sda1 33%",
"value": 33,
"status": "ok"
}
],
"status": "ok"
}
Now that you have created a health endpoint, you can connect it to Semonto. We will then periodically query the health endpoint and notify you of any issues. The Semonto dashboard will show the current status, and the status of the subtests, if present.
https://myserver/health
Extra configuration options:
If you want, you can add additional security to your health endpoint.
There are multiple ways to do that:
Mozilla/5.0 (compatible; Semonto/2.0; +https://semonto.com/monitoring; websiteMonitoring)
. If your framework supports limiting by a user agent, you can add and whitelist our user agent to shield the status results. This method is less secure but should offer an acceptable base protection.health-monitor-access-key
however you can change this to be compatible with the framework you use. Don’t change this header if you use our framework.If you are using WordPress, you can also install our Semonto WP plugin for your server monitoring. You create the server health endpoint in Semonto enter it in the plugin settings on WordPress. There, you can further define the tests you want to run. The results will appear directly in your WordPress dashboard. More about WordPress monitoring with Semonto