From 272ca4d82d5b5ed0bf45efab12ef1c033d0ccf27 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 3 Nov 2023 14:44:38 -0400 Subject: [PATCH] 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 (cherry picked from commit 1a13e7407a043b151d02d6d65ad37d87788fa3a5) --- src/pybind/mgr/devicehealth/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 07768db7565..86ea1d28072 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: -- 2.39.5