import Foundation import SQLite3 class StatusMonitor { private var timer: Timer? private let databaseConfig = DatabaseConfig() private var nodeCount: Int = 0 private var lastUpdateTime: Date = Date() func startMonitoring() { print("Starting status monitoring...") updateStats() timer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: true) { _ in self.updateStats() } } func stopMonitoring() { timer?.invalidate() timer = nil print("Status monitoring stopped") } func updateStats() { nodeCount = databaseConfig.getNodeCount() lastUpdateTime = Date() print("Stats updated: \(nodeCount) nodes") } func getNodeCount() -> Int { return nodeCount } func getLastUpdateTime() -> Date { return lastUpdateTime } func getDatabasePath() -> String { return databaseConfig.getCurrentDatabasePath() } }