A Python monitoring script that checks database records for missing check-ins and sends SMS alerts when issues are detected.
- Monitors database check-in records for staleness (> 300 seconds)
- Sends SMS notifications via OneWaySMS gateway when problems are detected
- Prevents duplicate notifications with status tracking
- Configurable database and SMS settings via separate config files
-
Install dependencies:
pip install -r requirements.txt
-
Configure database connection:
- Copy
.dbconfig_ahsoo.templateto.dbconfig_ahsoo - Update with your database credentials:
hostname,username,password,database_name
- Copy
-
Configure SMS settings:
- Copy
.smsconfig_ahsoo.templateto.smsconfig_ahsoo - Update with your SMS gateway credentials:
api_username,api_password,mobile_number1,sender_id,mobile_number2
- Copy
Run the script manually:
python pyalerter.pyOr set up as a cron job to run every 6 minutes:
*/6 * * * * /path/to/python /path/to/pyalerter.py- Connects to MySQL database using credentials from
.dbconfig_ahsoo - Updates records older than 300 seconds to 'NOK' status
- Resets notification flags for 'OK' records
- Checks for 'NOK' records that haven't been notified
- Sends SMS alert if issues found
- Updates notification status to prevent duplicates
- Database and SMS credentials are stored in separate config files
- Config files are excluded from version control via
.gitignore - Template files provided for easy setup without exposing sensitive data
- Python 3.x
- MySQL database
- OneWaySMS account (or compatible SMS gateway)