From: Patrick Donnelly Date: Fri, 3 Nov 2023 18:44:38 +0000 (-0400) Subject: pybind/mgr/devicehealth: replace SMART data if exists for same DATETIME X-Git-Tag: v19.1.0~674^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1a13e7407a043b151d02d6d65ad37d87788fa3a5;p=ceph.git pybind/mgr/devicehealth: replace SMART data if exists for same DATETIME Where DATETIME means "seconds since epoch". Fixes: https://tracker.ceph.com/issues/63433 Signed-off-by: Patrick Donnelly --- diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 07768db756565..86ea1d280720c 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -502,8 +502,8 @@ CREATE TABLE DeviceHealthMetrics ( def put_device_metrics(self, devid: str, data: Any) -> None: SQL = """ - INSERT INTO DeviceHealthMetrics (devid, raw_smart) - VALUES (?, ?); + INSERT OR REPLACE INTO DeviceHealthMetrics (devid, raw_smart, time) + VALUES (?, ?, strftime('%s', 'now')); """ with self._db_lock, self.db: