[pve-devel] r5685 - pve-cluster/trunk/data/src

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Mar 11 08:23:23 CET 2011


Author: dietmar
Date: 2011-03-11 08:23:23 +0100 (Fri, 11 Mar 2011)
New Revision: 5685

Modified:
   pve-cluster/trunk/data/src/status.c
Log:
expire old entries


Modified: pve-cluster/trunk/data/src/status.c
===================================================================
--- pve-cluster/trunk/data/src/status.c	2011-03-11 07:05:07 UTC (rev 5684)
+++ pve-cluster/trunk/data/src/status.c	2011-03-11 07:23:23 UTC (rev 5685)
@@ -1009,12 +1009,35 @@
 	goto ret;
 }
 
+static gboolean
+rrd_entry_is_old(
+	gpointer key,
+	gpointer value,
+	gpointer user_data)
+{
+	rrdentry_t *entry = (rrdentry_t *)value;
+	uint32_t ctime = GPOINTER_TO_UINT(user_data);
+
+	int diff = ctime - entry->time;
+ 
+	/* remove everything older than 5 minutes */
+	int expire = 60*5; 
+
+	return (diff > expire) ? TRUE : FALSE;
+}
+
 void
 cfs_rrd_dump(GString *str)
 {
-	// fixme: cache result 
-	// fixme: remove old data
+	// fixme: cache result ?
 
+	time_t ctime;
+	time(&ctime);
+
+	/* remove old data */
+	g_hash_table_foreach_remove(cfs_status.rrdhash, rrd_entry_is_old,  
+				    GUINT_TO_POINTER(ctime));
+
 	g_string_set_size(str, 0);
 
 	GHashTableIter iter;




More information about the pve-devel mailing list