[pve-devel] r5680 - pve-cluster/trunk/data/perl

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Mar 10 13:56:04 CET 2011


Author: dietmar
Date: 2011-03-10 13:56:04 +0100 (Thu, 10 Mar 2011)
New Revision: 5680

Modified:
   pve-cluster/trunk/data/perl/Cluster.pm
   pve-cluster/trunk/data/perl/test1.pl
Log:
parse RRD data


Modified: pve-cluster/trunk/data/perl/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/perl/Cluster.pm	2011-03-10 12:35:03 UTC (rev 5679)
+++ pve-cluster/trunk/data/perl/Cluster.pm	2011-03-10 12:56:04 UTC (rev 5680)
@@ -419,19 +419,29 @@
 	return $last_rrd_data;
     }
 
-    my $res;
+    my $raw;
     eval {
-	$res = &$ipcc_send_rec(10);
+	$raw = &$ipcc_send_rec(10);
     };
     my $err = $@;
 
     if ($err) {
 	warn $err;
-    } else {
-	$last_rrd_dump = $ctime;
-	$last_rrd_data = $res;
+	return {};
     }
 
+    my $res = {};
+
+    while ($raw =~ s/^(.*)\n//) {
+	my ($key, @ela) = split(/:/, $1);
+	next if !$key;
+	next if !(scalar(@ela) > 1);
+	$res->{$key} = \@ela;
+    }
+
+    $last_rrd_dump = $ctime;
+    $last_rrd_data = $res;
+
     return $res;
 }
 

Modified: pve-cluster/trunk/data/perl/test1.pl
===================================================================
--- pve-cluster/trunk/data/perl/test1.pl	2011-03-10 12:35:03 UTC (rev 5679)
+++ pve-cluster/trunk/data/perl/test1.pl	2011-03-10 12:56:04 UTC (rev 5680)
@@ -30,7 +30,7 @@
     print "update end\n";
 
     my $res = PVE::Cluster::rrd_dump();
-    print "RRDDATA:$res\n";
+    print "RRDDATA:" . Dumper($res);
 
     #my $res = PVE::Cluster::cfs_file_version('user.cfg');
     #print "VER $res\n";



More information about the pve-devel mailing list