This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from 31bf2e4 agent.py: Set result to None, if SSH connection to broker agent fails. new a0a3eba whitespace fixup new eaa336c Calculate our own MemAvailable value in x2gobroker-agent.pl. Only kernels new than v3.14 offer the MemAvailable: field in /proc/meminfo. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 2 ++ lib/x2gobroker-agent.pl | 45 ++++++++++++++++++++++++++++++++++++++++++--- x2gobroker/agent.py | 3 +++ 3 files changed, 47 insertions(+), 3 deletions(-) -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit a0a3eba2af83a658ff0e42d6f7295ba8f845a040 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Fri Mar 27 11:18:34 2015 +0100 whitespace fixup --- lib/x2gobroker-agent.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl index c98c603..7996b2f 100755 --- a/lib/x2gobroker-agent.pl +++ b/lib/x2gobroker-agent.pl @@ -138,7 +138,7 @@ if ( $mode eq 'checkload' ) { print "OK\n"; # Read the values from /proc/loadavg and combine all three values in a linear - # way and make a percent value out of the result: + # way and make a percent value out of the result: open FILE, "< /proc/loadavg" or die return ("Cannot open /proc/loadavg: $!"); my ($avg1, $avg5, $avg15, undef, undef) = split / /, <FILE>; close FILE; -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit eaa336c4012348f564de492309efa96eecb1c8bf Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Fri Mar 27 12:11:08 2015 +0100 Calculate our own MemAvailable value in x2gobroker-agent.pl. Only kernels new than v3.14 offer the MemAvailable: field in /proc/meminfo. --- debian/changelog | 2 ++ lib/x2gobroker-agent.pl | 43 +++++++++++++++++++++++++++++++++++++++++-- x2gobroker/agent.py | 3 +++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index c7d336d..9d8ae6b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -250,6 +250,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low - agent.py: Make agent query mode LOCAL behave similar to agent query mode SSH if things go wrong. - agent.py: Set result to None, if SSH connection to broker agent fails. + - Calculate our own MemAvailable value in x2gobroker-agent.pl. Only + kernels new than v3.14 offer the MemAvailable: field in /proc/meminfo. * 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 7996b2f..27709f1 100755 --- a/lib/x2gobroker-agent.pl +++ b/lib/x2gobroker-agent.pl @@ -149,16 +149,53 @@ if ( $mode eq 'checkload' ) { } # calculate total memory vs. free memory - my $memAvail; + my $memTotal; + my $memFree; + my $memAvail; + my $pagesActiveFile; + my $pagesInactiveFile; + my $slabReclaimable; open FILE, "< /proc/meminfo" or die return ("Cannot open /proc/meminfo: $!"); foreach(<FILE>) { + if ( m/^MemTotal:\s+(\S+)/ ) { + $memTotal = $1; + } + if ( m/^MemFree:\s+(\S+)/ ) { + $memFree = $1; + } if ( m/^MemAvailable:\s+(\S+)/ ) { $memAvail = $1/1000; - last; + } + if ( m/^Active\(file\):\s+(\S+)/ ) { + $pagesActiveFile = $1; + } + if ( m/^Inactive\(file\):\s+(\S+)/ ) { + $pagesInactiveFile = $1; + } + if ( m/^SReclaimable:\s+(\S+)/ ) { + $slabReclaimable = $1; } } close(FILE); + my $myMemAvail = 0; + if ($myMemAvail == 0) { + # taken from Linux kernel code in fs/proc/meminfo.c (since kernel version 3.14)... + open FILE, "< /proc/sys/vm/min_free_kbytes" or die return ("Cannot open /proc/sys/vm/min_free_kbytes: $!"); + my $memLowWatermark = <FILE>; + $memLowWatermark =~ s/\n//g; + close(FILE); + $myMemAvail += $memFree - $memLowWatermark; + my $pagecache = $pagesActiveFile + $pagesInactiveFile; + $pagecache -= ($pagecache/2, $memLowWatermark) [$pagecache/2 > $memLowWatermark]; + $myMemAvail += $pagecache; + $myMemAvail += $slabReclaimable - ( ($slabReclaimable/2, $memLowWatermark) [$slabReclaimable/2 > $memLowWatermark]); + if ($myMemAvail < 0) { + $myMemAvail = 0; + } + $myMemAvail = $myMemAvail / 1000; + } + # check number and type of available CPU cores my $numCPU = 0; my $typeCPU; @@ -175,6 +212,8 @@ if ( $mode eq 'checkload' ) { print "\n"; print sprintf 'memAvail:%1$d', $memAvail; print "\n"; + print sprintf 'myMemAvail:%1$d', $myMemAvail; + print "\n"; print sprintf 'numCPU:%1$d', $numCPU; print "\n"; print sprintf 'typeCPU:%1$d', $typeCPU; diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py index 04591b2..eb6e888 100644 --- a/x2gobroker/agent.py +++ b/x2gobroker/agent.py @@ -431,6 +431,9 @@ def checkload(remote_agent=None, logger=None, **kwargs): p[key] = float(val) load_factor = None + if p['memAvail'] == 0: + p['memAvail'] = p['myMemAvail'] + try: load_factor = long( ( (p['memAvail']/1000) * p['numCPU'] * p['typeCPU'] * 100 ) / p['loadavgXX'] ) except KeyError: -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git