[X2Go-Commits] [x2gobroker] 02/03: x2gobroker-agent.pl: Fall-back CPU detection for virtualized systems (e.g. QEMU hosts).

git-admin at x2go.org git-admin at x2go.org
Sat Mar 28 00:43:58 CET 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gobroker.

commit be73fe8a539d97a5eb43d440befd53b153e4819c
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Sat Mar 28 00:42:55 2015 +0100

    x2gobroker-agent.pl: Fall-back CPU detection for virtualized systems (e.g. QEMU hosts).
---
 debian/changelog        |    2 ++
 lib/x2gobroker-agent.pl |   13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 501d914..7f3bbf8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -254,6 +254,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low
       kernels newer than v3.14 offer the MemAvailable: field in /proc/meminfo.
     - x2gobroker-agent.pl: Fix regexp for detecting number of CPUs and CPU
       frequency.
+    - x2gobroker-agent.pl: Fall-back CPU detection for virtualized systems (e.g.
+      QEMU hosts).
   * debian/control:
     + Provide separate bin:package for SSH brokerage: x2gobroker-ssh.
     + Replace LDAP support with session brokerage support in LONG_DESCRIPTION.
diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl
index 4926cce..2256f8c 100755
--- a/lib/x2gobroker-agent.pl
+++ b/lib/x2gobroker-agent.pl
@@ -23,6 +23,7 @@ use strict;
 
 use File::Basename;
 use File::Which;
+use POSIX;
 
 my @available_tasks = (
     "availabletasks",
@@ -208,6 +209,18 @@ if ( $mode eq 'checkload' ) {
 	}
 	close(FILE);
 
+	# in virtual hosts, we need to obtain the CPU frequency from the cpu MHz: field.
+	if ($typeCPU == 0) {
+		open FILE, "< /proc/cpuinfo" or die return ("Cannot open /proc/cpuinfo: $!");
+		foreach(<FILE>) {
+			if ( m/^cpu\ MHz\s+:\s+(\S+)/ ) {
+				$typeCPU = ceil($1);
+				$numCPU += 1;
+			}
+		}
+		close(FILE);
+	}
+
 	print sprintf 'loadavgXX:%1$d', $loadavgXX;
 	print "\n";
 	print sprintf 'memAvail:%1$d', $memAvail;

--
Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git


More information about the x2go-commits mailing list