A Python-based monitoring agent that tracks pfSense CPU usage and load average, sending Gmail alerts when configured thresholds are exceeded.
- Real-time Monitoring: Continuously monitors pfSense system metrics
- Configurable Thresholds: Set custom CPU and load average alert thresholds
- Gmail Alerts: Sends email notifications when thresholds are exceeded
- Alert Cooldown: Prevents spam by limiting alert frequency
- Comprehensive Logging: Detailed logging to file and console
- Easy Setup: Interactive configuration script
-
Install Dependencies
pip3 install -r requirements.txt
-
Run Setup
python3 setup.py
This will guide you through configuring:
- pfSense connection details
- Alert thresholds
- Gmail credentials
- Monitoring intervals
-
Start Monitoring
python3 pfsense_monitor.py
The config.json file contains all settings:
{
"pfsense": {
"host": "192.168.1.1",
"username": "admin",
"password": "your_password",
"verify_ssl": false
},
"thresholds": {
"cpu_percent": 80,
"load_avg": 2.0
},
"gmail": {
"from_email": "your_email@gmail.com",
"to_email": "alerts@example.com",
"app_password": "your_app_password"
},
"check_interval_seconds": 300,
"alert_cooldown_minutes": 30,
"log_level": "INFO"
}- Enable 2-Factor Authentication on your Google account
- Go to Google Account > Security > 2-Step Verification > App passwords
- Generate an app password for "Mail"
- Use this app password in the configuration (not your regular password)
- CPU Usage: Percentage of CPU utilization
- Load Average: System load average (1-minute)
- Alerts are sent when metrics exceed configured thresholds
- Cooldown period prevents alert spam
- Email includes timestamp, host info, and specific threshold violations
Logs are written to:
pfsense_monitor.log(file)- Console output
Log levels: DEBUG, INFO, WARNING, ERROR
- Verify pfSense credentials and network connectivity
- Check if pfSense web interface is accessible
- Ensure SSL settings match your pfSense configuration
- Confirm 2FA is enabled and app password is correct
- Check Gmail security settings
- Verify email addresses are correct
# Test pfSense connection only
python3 setup.py testThe monitor can be extended to track additional metrics by modifying:
parse_system_stats()method for new metricscheck_thresholds()method for new alert conditions- Configuration file for new settings
- Python 3.6+
- Network access to pfSense web interface
- Gmail account with app password
- pfSense with web interface enabled
MIT License - feel free to modify and distribute.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter issues:
- Check the logs in
pfsense_monitor.log - Verify your configuration in
config.json - Test connection with
python3 setup.py test - Open an issue on GitHub with logs and configuration (remove sensitive data)
- Initial release
- CPU and load average monitoring
- Gmail alert system
- Configurable thresholds and intervals
- Systemd service support