From unknown Wed May 13 22:19:07 2026
X-Loop: owner@bugs.x2go.org
Subject: Bug#686: incorporate nxcheckload in x2gobroker-agent
Reply-To: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>, 686@bugs.x2go.org
Resent-From: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Resent-To: x2go-dev@lists.x2go.org
Resent-CC: X2Go Developers <x2go-dev@lists.x2go.org>
X-Loop: owner@bugs.x2go.org
Resent-Date: Tue, 02 Dec 2014 16:20:01 +0000
Resent-Message-ID: <handler.686.B.141753700211205@bugs.x2go.org>
Resent-Sender: owner@bugs.x2go.org
X-X2Go-PR-Message: report 686
X-X2Go-PR-Package: x2gobroker-agent
X-X2Go-PR-Keywords: 
Received: via spool by submit@bugs.x2go.org id=B.141753700211205
          (code B); Tue, 02 Dec 2014 16:20:01 +0000
Received: (at submit) by bugs.x2go.org; 2 Dec 2014 16:16:42 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED
	autolearn=ham version=3.3.2
Received: from freya.das-netzwerkteam.de (freya.das-netzwerkteam.de [88.198.48.199])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 35C585E0DB
	for <submit@bugs.x2go.org>; Tue,  2 Dec 2014 17:16:40 +0100 (CET)
Received: from grimnir.das-netzwerkteam.de (grimnir.das-netzwerkteam.de [78.46.204.98])
	by freya.das-netzwerkteam.de (Postfix) with ESMTPS id C9E081B99
	for <submit@bugs.x2go.org>; Tue,  2 Dec 2014 17:16:39 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTP id AAC033BA21
	for <submit@bugs.x2go.org>; Tue,  2 Dec 2014 17:16:39 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at grimnir.das-netzwerkteam.de
Received: from grimnir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (grimnir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id kX2zbpWmWJcB for <submit@bugs.x2go.org>;
	Tue,  2 Dec 2014 17:16:39 +0100 (CET)
Received: from grimnir.das-netzwerkteam.de (localhost [127.0.0.1])
	by grimnir.das-netzwerkteam.de (Postfix) with ESMTPS id 7F8BD3B9D5
	for <submit@bugs.x2go.org>; Tue,  2 Dec 2014 17:16:39 +0100 (CET)
Received: from p5B3B8969.dip0.t-ipconnect.de (p5B3B8969.dip0.t-ipconnect.de
 [91.59.137.105]) by mail.das-netzwerkteam.de (Horde Framework) with HTTP;
 Tue, 02 Dec 2014 16:16:39 +0000
Date: Tue, 02 Dec 2014 16:16:39 +0000
Message-ID: <20141202161639.Horde.WeNgtQZObw7n21V2dPwNug1@mail.das-netzwerkteam.de>
From: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
To: submit@bugs.x2go.org
User-Agent: Internet Messaging Program (IMP) H5 (6.2.2)
Accept-Language: en,de
Organization: DAS-NETZWERKTEAM
X-Originating-IP: 91.59.137.105
X-Remote-Browser: Mozilla/5.0 (X11; Linux x86_64; rv:32.0) Gecko/20100101
 Firefox/32.0 Iceweasel/32.0
Content-Type: multipart/signed; boundary="=_NVXtLGrNSUGi5IEOmfDp5g4";
 protocol="application/pgp-signature"; micalg=pgp-sha1
MIME-Version: 1.0

This message is in MIME format and has been PGP signed.

--=_NVXtLGrNSUGi5IEOmfDp5g4
Content-Type: multipart/mixed; boundary="=_8_eHXAcdQpFks0Kt_GlMPg8"

This message is in MIME format.

--=_8_eHXAcdQpFks0Kt_GlMPg8
Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes
Content-Disposition: inline

Package: x2gobroker-agent
Version: 0.0.3.0-preview
Severity: wishlist

In FreeNX there exists a script named nxcheckload.

The functionality of this script should be woven into x2gobroker-agent.pl.

THe nxcheckload script is attached to this bug report.

Mike

-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: mike.gabriel@das-netzwerkteam.de, http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

--=_8_eHXAcdQpFks0Kt_GlMPg8
Content-Type: text/x-shellscript; name=nxcheckload; charset=utf-8
Content-Disposition: attachment; size=3549; filename=nxcheckload
Content-Transfer-Encoding: quoted-printable

#!/bin/sh
#
# nxcheckload - sample script for calculation of the load for a node.
#
# Version 0.5
#
# Under GPL
#
# Jonathan "Arrouan" ROUZAUD-CORNABAS (rouzaud.jonathan@gmail.com)
#
# Fabian Franz <FreeNX@fabian-franz.de>
#
# 0.5
#  - Rewrote huge parts
#
# Change between 0.3 and 0.4
#   - Add of TMP_FILE
#   - Add of lock file to avoid two run at once.
#
# Change between 0.2 and 0.3
#   - SMP support.
#

if [ "$1" !=3D "" ]
then
	# Connect to a remote node
=09
=09# Note: This is a ssh sample, you'll need to tweak it for your setup
	#       and setup the secret keys for yourself.
=09
=09#exec $COMMAND_SSH nxcal@"$1" "$PATH_BIN/nxcheckload"
=09
=09# Note: This is a netcat example. You need to have nxcheckload running t=
hrough=20
=09# netpipes or netcat like follows:
	# 	node1:~$ faucet 9876 -io $PATH_BIN/nxcheckload
	#
	# Connect to another node running the load-service on some port.
	#
=09
=09#exec $COMMAND_NETCAT "$1" 9876

	# Same as loadbalance_rr_random
	# pick a node by random.
=09
=09ping -c 1 $1 1>/dev/null 2>/dev/null=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20       if [ $? -eq 0 ]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20       then=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20               exec ssh x2gobroker@"$1" "/usr/bin/nxcheckload"=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20       else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20           echo "1"=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
=20       fi=20

=09#echo $RANDOM
	exit 0
fi

# Be sure to use C numeric for calculations
export LC_NUMERIC=3DC

# The 3 variables of load from uptime
# =D0=A1=D1=80=D0=B5=D0=B4=D0=BD=D1=8F=D1=8F =D0=BD=D0=B0=D0=B3=D1=80=D1=83=
=D0=B7=D0=BA=D0=B0 =D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B LA
#LOADXX=3D$(awk '{ printf("(100-%s)+(100-%s)+(100-%s)\n", $1, $2, $3); }' /=
proc/loadavg | bc -q)
LOADXX=3D$(awk '{ printf("((%s+%s+%s)*100/3)\n", $1, $2, $3); }' /proc/load=
avg | bc -q)

if [ $LOADXX -eq 0 ]; then
    LOADXX=3D"1"
fi

# Add of total memory and free memory
#Mt=3D$(awk 'BEGIN { N=3D0 } /MemTotal|MemFree/ { N+=3D$2; } END { print N =
}' /proc/meminfo)

# NBCPU =3D number of CPU
# =D0=9A=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE =D1=86=D0=BF=
=D1=83
NBCPU=3D$(cat /proc/cpuinfo | grep ^processor | wc -l)

# CPU =3D Mhz of the CPU
# =D0=9C=D0=BE=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8 =D0=BF=D1=80=D0=BE=D1=86=
=D0=BE=D0=B2
#CPU=3D$(cat /proc/cpuinfo | grep "cpu MHz" | head -n1 | cut -d':' -f2 | cu=
t -d' ' -f2)
CPU=3D$(cat /proc/cpuinfo | grep "model name" | awk '{print $9*1000}' | cut=
 -d'G' -f1 | tail -n1 | bc -q)

# Number of Xorg already launch and running.
# =D0=9A=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE =D0=B7=D0=B0=
=D0=BF=D1=83=D1=89=D0=B5=D0=BD=D0=BD=D1=8B=D1=85 =D1=81=D0=B5=D1=81=D1=81=
=D0=B8=D0=B9
#NUMBX=3D$(ps aux | grep Xorg | grep -v grep | wc -l)
NUMBX=3D$(ps aux | grep x2goagent | grep -v grep | wc -l)

if [ $NUMBX -eq 0 ]; then
    NUMBX=3D"1"
fi

# Final calcul of the number of load.
# (=D0=9A=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE =D0=A6=D0=
=9F=D0=A3 * =D0=9C=D0=9E=D0=A9=D0=9D=D0=9E=D0=A1=D0=A2=D0=AC =D0=A6=D0=9F=
=D0=A3) / =D0=9D=D0=90 =D0=A1=D0=A0=D0=95=D0=94=D0=9D=D0=AE=D0=AE =D0=9D=D0=
=90=D0=93=D0=A0=D0=A3=D0=97=D0=9A=D0=A3 =D0=A1=D0=98=D0=A1=D0=A2=D0=95=D0=
=9C=D0=AB / =D0=9A=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE =
=D1=81=D0=B5=D1=81=D1=81=D0=B8=D0=B9
#echo "100 * $LOADXX + $Mt + ( $NBCPU * $CPU ) / 100 + $UNB * 100" | bc -q =
| cut -d. -f1
echo "( $NBCPU * $CPU * 100 ) / $LOADXX / $NUMBX" | bc -q

--=_8_eHXAcdQpFks0Kt_GlMPg8--

--=_NVXtLGrNSUGi5IEOmfDp5g4
Content-Type: application/pgp-signature
Content-Description: Digitale PGP-Signatur
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAABAgAGBQJUfeXnAAoJEJr0azAldxsxNxcP/iUEuqspLI0N4XNWw0+kHSM8
yume03+b1YTP7WKFBM7SR9AFdyjYiGkcnDszQEGi5oTbc9hp/6QUwhzHEJqmkI6O
gArwI+nfrXTFTPupK3InC9qfZW88P+zVMoq3ggiBUtNjZ5NrCZ3VVjdLTNxbvsDm
SOHDK65BpE788sHfohgcV4667exKL9kLgfwpgMhFGPzVS84gEK5H2lj6WCy/soU0
vFAOhKZPGj14AJLDDWHH+D/zndqNYKoe6BwqWUzWZWrofY4Eew1ZVW9yiFi13XWF
T+VTr8LMKrN+GyWUgM/ILzUb9TwLeviLvtUTBq0ar5kowFg6eIGKDCHTRVourLhl
DkxOebrG/dquSVbvLGzmpnNtPmf0UEodYOYWoumnAjAQuctQ9+SRcTS03iSc9hN/
dbdJgqi36tLR9txZdvyLtU+7bv/bT3K9Q9VNiAPkt2bQcjMyWFolQlIjchki0F7I
gU+qAb6THid/2bGPUfk+AvVaSc4ltXXRzLHtCN1z6dzAGyAUZtR3bR+Mkwx3mPSt
fahQsFlNRzj5yjZ8BYrjy1AkLa/3zoURQvRnoHb45SqunfdIJ12+O2CakIy80702
Hw/AjjDFuH2+6wlQPtnwDJMSsD9vqMyjpvGdnKTkLdXWK6fCBaqfvwb9pfH1CiLT
J6JxrbE3f5tX+zD7jyg8
=4o7x
-----END PGP SIGNATURE-----

--=_NVXtLGrNSUGi5IEOmfDp5g4--
