Focus on cloud service provider activities
Notes on website operation and maintenance

Use the URL callback function of Monitoring Treasure to automatically monitor and maintain server cases

Some time ago, Lao Zuo conducted a sampling survey in the netizen circle, and found that more than 80% of webmaster users want the website and server to achieve automatic operation and maintenance. For example, a few days ago, some netizens wanted their servers to be restarted regularly. Whether we are personal webmasters or professional operation and maintenance personnel of companies, we need to implement automatic operation and maintenance when managing and maintaining websites, because this can not only reduce our workload and improve work efficiency, but also can quickly respond and automatically solve the problems of the project server. For example, Lao Zuo often meets netizens who mention that the server needs to perform a task regularly, and that it needs to restart automatically when the server may have problems. The efficiency of manual execution is certainly not as good as that of automation.

For example, Lao Zuo saw that the monitoring treasure provides a URL callback function application. We can use this function to provide more automated operation and maintenance server work. For example, we can use this function to detect the downtime server, and use third-party resolution tools such as DNSPOD to automatically switch to the standby server IP resolution, Or Lao Zuo often sees netizens mention that the server database or the WEB environment often have problems, which can be recovered only after manual restart. We can also use the URL callback function of Monitoring Treasure to automatically restart the Nginx and other WEB services after detecting the downtime alarm.

In this article, Lao Zuo will practice how to use the monitoring treasure URL callback function to detect the server downtime, restart the Nginx service and restore the normal operation of the website.

First, preparations

A - We need to have a monitoring treasure (jiangongbao. com) account. If there is no account, we need to register a new one.

B - The user places the URL to call back the site directory of the PHP page. We can find a site root directory in the active/available WEB environment, or we can build a special one ourselves. The current environment needs to support SSH2( SSH2 Installation Tutorial ), and above PHP 5.3.

C - The sites/servers to be monitored are added to the monitoring items of the monitoring treasure.

Second, set the URL callback page and parameter acquisition

 Set URL callback page and parameter acquisition

According to the above figure, we can add a URL callback page to our monitoring treasure account. This page needs to be accessible. Here, we can make development scripts for different projects according to the official document reference.

Third, deploy and edit the restart server callback script

Script address: https://soft.laozuo.org/tools/jiankongbao.zip

Here Lao Zuo also shares the script (thanks to the technical support from P). This is just an example of automatic restart or SSH command execution. For other in-depth uses, we need to write our own scripts.

 Deploy and edit the restart server callback script

In the jiankongbao.php file of the document, the parameter corresponds to the description that we need to find the ID of the project, the Token of the current callback URL, and the ROOT information of our monitoring server.

More importantly, the ssh_command means that we can restart the Nginx Web service after the server has a problem. Similarly, if we need to restart the database, we can use it this way.

Fourth, experience the URL callback function of Monitoring Treasure

After deploying the URL callback page parameters, Lao Zuo shut down Nginx for the monitoring server, and then waited for the mobile phone and email to notify the server of downtime after the monitoring was triggered, and then waited for a while to see the automatic task of recovering and restarting Nginx. It is recommended to purchase a paid version because it will be much better in terms of response speed, monitoring frequency and functions.

In conclusion, we can also apply it to more powerful automatic operation and maintenance services through the restart of WEB services through the URL callback function of Monitoring Treasure, which can realize unattended operation and maintenance practices.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( zero )
Do not reprint without permission: Lao Zuo's Notes » Use the URL callback function of Monitoring Treasure to automatically monitor and maintain server cases


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge