I previously introduced a Scheduled SMS Reminder Feature Based on Sina SAE, which was quite practical but not particularly valuable for Internet professionals. Today I’m introducing another application also built on the Sina SAE platform — a website monitoring and alert system. Website monitoring should be familiar to most of you; the most commonly used services in China are probably JianKongBao and DNSPod’s uptime checker. The principle behind this application is simple: it periodically fetches content from the monitored website and analyzes it. If the fetch fails, the site is considered down.
If the error count exceeds a threshold, the application calls the SMS and email APIs to send alert messages to a designated phone number and email address. Once the site recovers, the system will also send a notification saying “your website is back to normal.” This application is an upgraded version of the SMS reminder feature I introduced earlier, and it’s particularly well-suited for small website owners and independent bloggers.
Here’s how to use it:
- Open the
config.phpfile and fill in the URL to monitor, maximum retry count, and SMS/email configuration details. The code is as follows:
//URL to monitor
define('MONITOR_URL',' https://imzl.com/ ');
define('TRY_TIMES',1); //Number of failure retries
define('MAX_TRY_TIMES',1); //Maximum number of alert messages to send
//EMAIL alert service
define('EMAIL_ENABLED',FALSE); //Enable or not
define('EMAIL_DEST','email address'); //Alert email recipient
define('SMTP_SERVER','SMTP server address');
define('SMTP_USERNAME','Sender email username');
define('SMTP_PASSWORD','password');
//SMS alert service
define('SMS_ENABLED',TRUE); //Enable or not
define('SMS_APID','China Telecom App Factory APID'); //APID number
define('SMS_PRODUCTID',' product number '); //Product number
define('SMS_APKEY',' product key '); //Product key
define('SMS_DEST',' SMS alert recipient '); //SMS alert recipient
- Open
config.yamland configure your application name and version. Leave everything else unchanged:
name: change to your application name
version: your application version number
cron:
- description: Website monitoring
url: monitor/index.php
schedule: every 15 mins
timezone: Beijing
Note that you need to set this version as the application’s default code version for the Cron job to execute automatically.
-
This system uses SAE’s Counter service as a fetch counter, so please enable the Counter Service in the SAE backend and create four counters named
SuccessNum, FailNum, ErrorNum, SendNum, all initialized to 0. -
I’ve uploaded the complete source code to 115 Cloud. You can download it and upload it to Sina SAE. Download here
This website monitoring and alert system built on Sina SAE is highly practical, supporting both SMS and email dual notifications. Since SAE has extremely high uptime with top-tier domestic data centers and network connections, the monitoring accuracy is guaranteed — unlike cases where the monitoring system itself has poor uptime, leading to inaccurate data. You can also extend this system with features like sensitive word detection and inappropriate content filtering.
SMS sending generally works without issues, but it requires a China Telecom APID. If you don’t have one, you can refer to my earlier article on Scheduled SMS Reminders on Sina SAE and modify the code accordingly. The email functionality may encounter minor issues due to SAE’s email API.
Also, Sina SAE is free to use. Even if you run out of cloud beans, you can register a new account through my referral link below and get bonus cloud beans!
Sina SAE referral registration link: https:/imzl.com/go/sae/