Automatic monitoring and operation of the server case using the Monitoring Treasure URL callback function

Source: Internet
Author: User
Tags php file web services
Whether our website or the server, in the operation of peacekeeping management time must not be required to use the monitoring function. Although in the domestic and foreign various third-party service providers can see similar Aliyun monitoring, Baidu Cloud observation, monitoring and so on Third-party monitoring service tools, but these tools are not single and focus on providing monitoring services. Of course, for most of the ordinary project site, we only need to monitor the HTTP can achieve basic needs, if the need for deep operational requirements, or need to use more in-depth functions.




For example, the old left to see the monitoring PO provides URL callback function application, we can use this to provide a more automated operation of the operational server, such as we can use to detect the downtime server, and the use of dnspod and other Third-party parsing tools to automatically switch to the standby server IP resolution, Or old left often see a netizen mentioned server database or Web environment often have problems, need to manually restart to restore, we can also use the Monitoring Treasure URL callback function, detect the downtime alarm, automatically restart Nginx and other Web services.




In this article, old left will practice how to use the Monitoring Treasure URL callback to detect downtime servers and restart the Nginx service and restore the site to normal operation.




First, preparatory work




A-we need to have a monitoring treasure (jiankongbao.com) account, if no account will need to register a new, free account can also support 6 monitoring sites, the general user enough.




B-User placed URL callback php page Site Directory, we can find a in/Available Web environment site root directory, can also be dedicated to build one, need the current environment support SSH2 (SSH2 installation tutorial), as well as PHP5.3 above.




C-Need to monitor the site/server, added to the monitoring of the Treasure Monitoring project.




Second, set URL callback page and parameter fetch







According to the above figure, we go to our own monitor treasure account, add URL callback page, this page needs to be able to access, here can according to the official document reference to produce different project development script.




Third, deploy and edit reboot server callback script




The code is as follows Copy Code

Script Address: Http://soft.laozuo.org/tools/jiankongbao.zip




Here the old left to share the script also (thanks to P always give technical support), here is only an automatic restart or the implementation of the SSH command example, for other in-depth use of the need to write our own script.







In the document's jiankongbao.php file, the parameter correspondence indicates 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 is a means of restarting the Nginx Web service after a problem with the server, as well as if we need to restart the database.




Four, monitor the Treasure URL callback function experience




Old left after the deployment URL callback page parameters, for the monitoring server shut down the Nginx, and then wait for the monitoring of the mobile phone, Mail told the server down, and then wait for a while to see the recovery and restart the Nginx automatic task. Because I am a free account here, the feedback is slightly delayed, and if it is a paid account it will be quicker to feedback and perform the preset automatic operation task.




Summary, through the monitoring of the Treasure URL callback to restart the Web services function, we can also be applied to a more powerful automated operation of the service, so that can be implemented unattended operation and maintenance practice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.