Magento health check is quite broad. However, we still have some outlines in the following article.
1. Check number or CPUs.
2. Check server’s OS.
3. Magento Health Check disk used/free space.
Low disk space also affects your server’s performance so please don’t forget this step if you’re checking your website’s status.
4. Check used/free memory.
When server runs into out-of-memory, the website usually shows “memory exhausted” error. We can do a quick check like this:
5. Check services’ CPU usage.
The Linux top command is used to show all the running processes within your linux environment. You can also find the CPU & memory usage for each process. This command is useful to find out which application is consuming system resources.
(Press Ctrl+c to quit)
6. Search for large files
If you’re cleaning up unnecessary large files to save disk space but not knowing where to start, this command might help. By default, Magento website itself contains small files only.
find ./ -size +20M -ls
This command will list all files larger than 20MiB. You might change 20 to any other number.
7. Magento Health Check services status
Sometimes we need to check the status of a service if it is running or not to cross-verify something on the server. Suppose you have edited your httpd.conf file and when restarting the service it just show start service is on. But when you try to get access to the web site the site is down.
service [services-name] status hoặc /etc/init.d/servicename status
i.e: service httpd status
To check all the services state at a time use below command
Here’s what we get:
8. Magento health Check real-time output from log file
tail -f /path/to/file.name
This command is useful for debugging or monitoring server status. A bad customized Magento website usually generates lots of error & exception log and this might cause low performace as well. Checking server’s log files in real time is actually simple. Access log for example:
tail -f /var/log/apache2/access.log
9. Find out which php script is running
If you have just typed “top” command and realized that php or apache service is consuming lots of server resources, there might be some scripts running in background. Try this command to know what’s running:
ps ax | grep *.php
10. Check slow mysql queries
We should also consider checking this step while speeding up Magento website. To determine running queries execute time, try this query from mysql command line:
show full processlist;
You can also enable mysql slow query log: set global slow_query_log = ‘ON’;
Set the path to the slow query log: set global slow_query_log_file =’/var/log/mysql/slow-query.log’;
Set the amount of time a query needs to run before being logged:
set global long_query_time = ’20’;
(default is 10 seconds)
11. Health Notification (Magento Commerce Cloud)
For Magento Commerce Cloud, it tracks the disk space usage of all applications and services in both your Starter and Pro Integration environment. The Magento health check happens every 5 minutes, and you can register to receive notification through email or other external services.
Warning – Available disk space drops below 20%
Critical – Available disk space is now below 10%
All Clear – Disk space returns above 20% after a low-disk event happened.
The email integration needs at least one ‘from’ and ‘recipient address. The following example registers a health email integration with two recipients:
$ magento-cloud integration:add –type health.email –from-address email@example.com –recipients firstname.lastname@example.org –recipients email@example.com
Slack channel notifications
Slack is an external service that uses bots to announce your Magento health check notification in a chat room. In order the receive health notification on Slack, you have to first create a custom bot user for your Slack group. After finish setting up bots for your channels, you should save the bot token provided by Slack to register your integration. The example below shows the registering for notification for Slack channel:
$ magento-cloud integration:add –type health.slack –token SLACK_BOT_TOKEN –channel ‘#slack-channel-name’
The PagerDuty is an external service that notifies the team members when the issues are happening. To receive health notification from PagerDuty, you should create PagerDuty integration that uses Events API version 2. Use the registering key, in other words, routing key to register your integration. Example:
$ magento-cloud integration:add –type health.pagerduty –routing-key PAGERDUTY_ROUTING_KEY
We have done with the tutorial on the Magento health check. We hope it is helpful.
CONTACT NOW to get pro Magento health check with >>> Magento 2 Code Audit Package.
About BSS Commerce:
We are one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bring high-quality products and services to optimize our business effectively. Let us know about your problems. We are willing to support you every time.