1. Introduction
Server Resource Monitoring is a process of monitoring a server's system resources/services (eg: CPU Usage, Load average, Memory Usage, I/O, Network, Disk Usage, Process, etc). Server monitoring allows you to keep your systems in a healthy state. Implementing a monitoring process helps you to make decisions proactively before anything fails due to unexpected resource usage/failures. This section describes the recommended monitoring guidelines by OrangeHRM.
2. Monitoring tools
There are a lot of good monitoring tools available in the market. You can select any tool according to your preferences. Following are some of the suggested tools by OrangeHRM.
3. Monitoring resource matrix
Following table contains the recommended (by OrangeHRM) resources/services to monitor and the recommended threshold levels for trigger alerts.
Service / Resource |
Monitoring Criteria |
Threshold Levels |
Descriptions |
CPU |
Usage percentage |
> 80% [ for at least 2 mins ] |
|
Load average |
> No of CPU cores [ for at least 2 mins ] |
||
Memory |
Usage percentage |
> 80%Server audit VA scan [ for at least 2 mins ] |
|
Disk |
Usage percentage |
> 80% [ for at least 2 mins ] |
|
Inode usage (/tmp partition) |
> 80% [ for at least 2 mins ] |
||
Disk read |
Read utilization percentage |
> 90% [ for at least 2 mins ] |
the % of the elapsed time when your particular disk drive was busy in servicing read requests |
Disk write |
Write utilization percentage |
> 90% [ for at least 2 mins ] |
the % of the elapsed time when your particular disk drive was busy in servicing write requests |
Apache |
Service status |
Stop |
|
MariaDB |
Service status |
Stop |
|
RabbitMQ |
Service status |
Stop |
|
Apache |
Service status |
Stop |
|
Nginx |
Service status |
Stop |
|
Cron |
Service status |
Stop |
|
Monitoring software |
Service status |
Stop |
|
MySQL connections |
maxUsedConnections |
> 121 [ for at least 2 mins ] |
|
Custom synthetic monitoring |
HTTP Response Code |
should equals to 200 |
This will monitor the MySQL connectivity from Apache. Refer to the section “Steps on setting up the custom synthetic” |
Steps on setting up the custom synthetic
1. Create a directory /var/www/html/monitoring
2. Create an index.php (/var/www/html/monitoring/index.php)
3. Add the following content to the index.php,
<?php define('DB_USER', 'username'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'host'); $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { header('HTTP/1.1 500 Internal Server Error'); die('Could not connect: OrangeHRM server is failing'); } else { echo "This is for server monitoring purpose. Please do not delete"; } ?> |
4. Set up a domain name to access the above index.php from the public (sample vhost configuration is given below).
<VirtualHost *:443> ServerAdmin webmaster@example.com DocumentRoot /var/www/html/monitoring ServerName example-monitoring.example.com SSLEngine on SSLCertificateFile <PUBLIC_KEY_LCOATION> SSLCertificateKeyFile <PRIVATE_KEY_LCOATION> SSLCertificateChainFile <CA_LCOATION> </VirtualHost> |
5. Set up a synthetic monitoring rule to monitor the HTTP response code using your monitoring software. Alerts should be triggered if the HTTP response code is not equal to 200.