A PHP-based server monitoring solution that checks web ser# 2. Database Setup
# Create database and t# 6. Test the Monitor
```bash
# Run monitoring check
php www/index.php
# Or access via web browser
http://your-server/path-to/www/index.php
Open your web browser and navigate to:
http://your-server/path-to/www/dashboard.php
```u root -p < setup_database.sql
# Copy sample configuration
cp www/config.sample.php www/config.php
# Edit with your settings
nano www/config.php
Edit www/config.php:and stores results in a MariaDB/MySQL database with a beautiful dashboard interface.
Mini-Watch/
โโโ www/ # Web application files
โ โโโ index.php # Main monitoring script
โ โโโ dashboard.php # Web dashboard with charts
โ โโโ config.php # Configuration file (create from sample)
โ โโโ config.sample.php # Sample configuration template
โโโ setup_database.sql # Database setup script
โโโ docker-compose.yml # Docker Compose configuration
โโโ containers/ # Docker containers
โ โโโ apache/ # Apache + PHP container
โ โโโ mariadb/ # MariaDB container
โ โโโ README.md # Container documentation
โโโ k8s/ # Kubernetes manifests
โ โโโ mini-watch.yaml # Kubernetes deployment
โโโ build-images.sh # Build script (Linux/macOS)
โโโ build-images.bat # Build script (Windows)
โโโ .gitignore # Git ignore file
โโโ README.md # This file
# 1. Clone the project
git clone <repository-url>
cd Mini-Watch
# 2. Copy configuration
cp www/config.sample.php www/config.php
# 3. Edit configuration (update database credentials)
nano www/config.php
# 4. Build and start services
docker-compose up -d
# 5. Access dashboard
open http://localhost:8080/dashboard.php
# 1. Build images for ARM architecture
./build-images.sh
# 2. Deploy to Kubernetes
kubectl apply -f k8s/mini-watch.yaml
# 3. Access via NodePort
kubectl get service mini-watch-web-service -n mini-watch
# Access at http://raspberry-pi-ip:30080/dashboard.php
For production-ready Kubernetes deployments with advanced configuration options:
# 1. Build images for your architecture
./build-images.sh
# 2. Install with default values
helm install mini-watch ./helm/mini-watch
# 3. Install with custom values
helm install mini-watch ./helm/mini-watch \
--set web.service.type=LoadBalancer \
--set mariadb.auth.rootPassword=mysecretpassword \
--set config.webservers[0]=https://mywebsite.com
# 4. Using a values file
helm install mini-watch ./helm/mini-watch -f my-values.yaml
# 5. Access application (follow NOTES output)
kubectl get svc mini-watch-web-service
Helm Benefits:
helm upgrade for seamless updatesSee helm/mini-watch/README.md for complete Helm documentation.
git clone <repository-url>
cd Mini-Watch
# Create database and tables
mysql -u root -p < setup_database.sql
# Copy sample configuration
copy config.sample.php config.php
# Edit with your settings
notepad config.php
Edit config.php:
$dbConfig = [
'host' => 'localhost',
'username' => 'your_username',
'password' => 'your_password',
'database' => 'server_monitor',
'port' => 3306
];
Edit the server list in www/config.php:
$webservers = [
'https://your-website.com',
'https://api.yourservice.com',
'https://cdn.yoursite.com',
];
# Run monitoring check
php index.php
# Or access via web browser
http://your-server/path-to/index.php
Open your web browser and navigate to:
http://your-server/path-to/dashboard.php
$dbConfig = [
'host' => 'localhost', // Database host
'username' => 'monitor_user', // Database username
'password' => 'secure_password', // Database password
'database' => 'server_monitor', // Database name
'port' => 3306 // Database port
];
$appConfig = [
'timeout' => 10, // Request timeout (seconds)
'userAgent' => 'Mini-Watch/1.0', // User agent string
'autoRefreshInterval' => 300000, // Dashboard refresh (ms)
'defaultTimeRange' => 24, // Statistics time range (hours)
];
server_logs Table| Column | Type | Description |
|---|---|---|
id |
INT AUTO_INCREMENT | Primary key |
url |
VARCHAR(255) | Server URL being monitored |
status |
ENUM(โน UP โบ, โน DOWN โบ) | Server status |
http_code |
INT | HTTP response code |
response_time |
DECIMAL(10,2) | Response time in milliseconds |
error_message |
TEXT | Error details (if any) |
checked_at |
TIMESTAMP | Check timestamp |
latest_server_status - Most recent status per serverserver_status_summary - Historical data with row numbersconfig.php is excluded from version controlchmod 600 config.php-- Create dedicated user with limited privileges
CREATE USER 'monitor_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON server_monitor.* TO 'monitor_user'@'localhost';
FLUSH PRIVILEGES;
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Run monitoring manually
docker-compose exec apache php index.php
# Stop services
docker-compose down
# Deploy application
kubectl apply -f k8s/mini-watch.yaml
# Check status
kubectl get pods -n mini-watch
# Run monitoring manually
kubectl exec deployment/mini-watch-web -n mini-watch -- php index.php
# Scale web service
kubectl scale deployment mini-watch-web --replicas=3 -n mini-watch
# Install chart
helm install mini-watch ./helm/mini-watch
# Upgrade release
helm upgrade mini-watch ./helm/mini-watch
# Get status
helm status mini-watch
# Uninstall
helm uninstall mini-watch
# Override values
helm install mini-watch ./helm/mini-watch --set web.replicaCount=3
# Single check
php index.php
# Continuous monitoring with cron (every 5 minutes)
*/5 * * * * /usr/bin/php /path/to/index.php
http://your-server/www/index.php (Native) or http://localhost:8080/index.php (Docker)http://your-server/www/dashboard.php (Native) or http://localhost:8080/dashboard.php (Docker)http://node-ip:30080/dashboard.php-- Get uptime for last 7 days
SELECT url,
COUNT(*) as total_checks,
SUM(CASE WHEN status = 'UP' THEN 1 ELSE 0 END) as up_checks,
ROUND((SUM(CASE WHEN status = 'UP' THEN 1 ELSE 0 END) / COUNT(*)) * 100, 2) as uptime_percentage
FROM server_logs
WHERE checked_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
GROUP BY url;
# Edit crontab
crontab -e
# Add monitoring job (every 5 minutes)
*/5 * * * * /usr/bin/php /path/to/Mini-Watch/index.php
# Add daily cleanup (optional - remove logs older than 30 days)
0 2 * * * mysql -u username -p'password' server_monitor -e "DELETE FROM server_logs WHERE checked_at < DATE_SUB(NOW(), INTERVAL 30 DAY);"
# Create scheduled task for every 5 minutes
schtasks /create /tn "ServerMonitor" /tr "php.exe C:\path\to\Mini-Watch\index.php" /sc minute /mo 5
Container wonโt start:
docker-compose logs mariadbnetstat -an | grep 3306docker system dfDatabase connection failed:
docker-compose logs -f mariadbdocker-compose exec apache nc -z mariadb 3306config.phpPods not starting:
kubectl describe pod <pod-name> -n mini-watch
kubectl logs <pod-name> -n mini-watch
Service not accessible:
kubectl get service mini-watch-web-service -n mini-watch
kubectl get endpoints mini-watch-web-service -n mini-watch
ARM Architecture issues:
kubectl get nodes -o wide # Check node architecture
docker image inspect mini-watch/apache:latest # Verify image architecture
Chart installation failed:
helm lint ./helm/mini-watch # Validate chart syntax
helm template mini-watch ./helm/mini-watch # Test rendering
helm install mini-watch ./helm/mini-watch --dry-run --debug # Dry run
Values not applied:
helm get values mini-watch # Check applied values
helm upgrade mini-watch ./helm/mini-watch --set key=value # Update values
Release stuck:
helm list # Check release status
helm rollback mini-watch 1 # Rollback to previous version
Database Connection Failed
config.phpcURL Errors
php -m | grep curlDashboard Not Loading
No Data in Charts
php index.php to populate initial dataThis project is open source. Feel free to use, modify, and distribute as needed.
For issues or questions:
Made with โค๏ธ for reliable server monitoring