Use Scheduled tasks in Linux +php Web-based programs to monitor Web server health "every 5 minutes and email alerts"
One, my monitoring server environment:
Rhel5.5+apache2.2+php5
Second, function Description:
Write a PHP page that implements the following functions:
Request the content of one page of the Web server to be monitored, if the data is not returned, or the data returned does not contain the code I expected "for the custom error page", then I think the Web service has a problem "outage or content overwrite attack", then send a message, This mail can be tied to the phone "139 mailbox can Do"
And what am I going to do when I'm planning a mission? Every 5 minutes, ask me for this monitoring page.
Finally, I realized the purpose of checking the health of the server every 5 minutes. Third, the description
Here the code to send the message, but also refer to the contributions of netizens, non-original.
Send Mail has two functions, one is used under the Wndows server, one is used under the Linux server, if you are lnux, please use the function with _unix suffix.
Iv. How to achieve this task?
Edit/etc/crontab, add the following line:
*/5 * * * * Root/usr/bin/curl http://localhost/monitor.php
"Explanation, the first field, which represents the execution of every 5 minutes"
Restart the Crond service using the service crond restart command after saving
Five, PHP code:
Paste the source code:
monitor.php:
Using Scheduled Tasks in Linux +php Web programs (GO)