[pve-devel] r5638 - in pve-common/trunk/data: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Mar 3 07:57:36 CET 2011


Author: dietmar
Date: 2011-03-03 07:57:36 +0100 (Thu, 03 Mar 2011)
New Revision: 5638

Modified:
   pve-common/trunk/data/ChangeLog
   pve-common/trunk/data/PVE/ProcFSTools.pm
Log:
	* PVE/ProcFSTools.pm (read_memory_usage): memory usage of current
	process



Modified: pve-common/trunk/data/ChangeLog
===================================================================
--- pve-common/trunk/data/ChangeLog	2011-03-03 06:12:51 UTC (rev 5637)
+++ pve-common/trunk/data/ChangeLog	2011-03-03 06:57:36 UTC (rev 5638)
@@ -1,3 +1,8 @@
+2011-03-03  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/ProcFSTools.pm (read_memory_usage): memory usage of current
+	process
+
 2011-02-22  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/JSONSchema.pm (pve_verify_email): verify email address

Modified: pve-common/trunk/data/PVE/ProcFSTools.pm
===================================================================
--- pve-common/trunk/data/PVE/ProcFSTools.pm	2011-03-03 06:12:51 UTC (rev 5637)
+++ pve-common/trunk/data/PVE/ProcFSTools.pm	2011-03-03 06:57:36 UTC (rev 5638)
@@ -178,4 +178,22 @@
     return $res;
 }
 
+# memory usage of current process
+sub read_memory_usage {
+
+    my $res = { size => 0, resident => 0, shared => 0 };
+
+    my $ps = 4096;
+
+    my $line = PVE::Tools::file_read_firstline("/proc/$$/statm");
+
+    if ($line =~ m/^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
+	$res->{size} = $1*$ps;
+	$res->{resident} = $2*$ps;
+	$res->{shared} = $3*$ps;
+    }
+
+    return $res;
+}
+
 1;




More information about the pve-devel mailing list