Resolves issue where multiple monitors updating statistics simultaneously
can cause "Duplicate entry" database errors for the same monitor_id and
timestamp combination in stat_hourly and stat_daily tables.
Changes:
- Add database-specific upsert logic for SQLite and MariaDB
- Replace R.store() calls with atomic upsert operations
- Add fallback to original R.store() if upsert fails
- Initialize default values for new stat beans to prevent null conflicts
- Use ON CONFLICT/ON DUPLICATE KEY UPDATE for atomic stat updates
This fix is particularly important for high-volume monitoring scenarios
with 400+ monitors where concurrent heartbeats can trigger race conditions
in the stat insertion process.
Fixes#5357