No subject


Thu Jun 30 09:13:00 PDT 2011


agent detects system parameters and put them into CIB by crm_attribute,=0A =
and it runs on every node as clone resource.=0A=0A---=0A heartbeat/Makefile=
.am     |    1 +=0A heartbeat/NodeUtilization |  229 ++++++++++++++++++++++=
+++++++++++++++++++++++=0A 2 files changed, 230 insertions(+), 0 deletions(=
-)=0A create mode 100755 heartbeat/NodeUtilization=0A=0Adiff --git =
a/heartbeat/Makefile.am b/heartbeat/Makefile.am=0Aindex dacf3bd..3a3d221 =
100644=0A--- a/heartbeat/Makefile.am=0A+++ b/heartbeat/Makefile.am=0A@@ =
-77,6 +77,7 @@ ocf_SCRIPTS	     =3D  ClusterMon		\=0A 		=
	mysql			\=0A 			mysql-proxy		=
\=0A 			nfsserver		\=0A+			=
NodeUtilization		\=0A 			oracle			=
\=0A 			oralsnr			\=0A 			=
pingd			\=0Adiff --git a/heartbeat/NodeUtilization =
b/heartbeat/NodeUtilization=0Anew file mode 100755=0Aindex 0000000..dca0d9a=
=0A--- /dev/null=0A+++ b/heartbeat/NodeUtilization=0A@@ -0,0 +1,229 =
@@=0A+#!/bin/sh=0A+#=0A+#=0A+#	NodeUtilization OCF Resource Agent=0A+#=0A+=
# Copyright (c) 2011 SUSE LINUX, John Shi=0A+#                    All =
Rights Reserved.=0A+#=0A+# This program is free software; you can =
redistribute it and/or modify=0A+# it under the terms of version 2 of the =
GNU General Public License as=0A+# published by the Free Software =
Foundation.=0A+#=0A+# This program is distributed in the hope that it =
would be useful, but=0A+# WITHOUT ANY WARRANTY; without even the implied =
warranty of=0A+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=0A+#=
=0A+# Further, this software is distributed without any warranty that it =
is=0A+# free of the rightful claim of any third person regarding infringeme=
nt=0A+# or the like.  Any license provided herein, whether implied or=0A+# =
otherwise, applies only to this software file.  Patent licenses, if=0A+# =
any, provided herein do not apply to combinations of this program =
with=0A+# other software, or any other product whatsoever.=0A+#=0A+# You =
should have received a copy of the GNU General Public License=0A+# along =
with this program; if not, write the Free Software Foundation,=0A+# Inc., =
59 Temple Place - Suite 330, Boston MA 02111-1307, USA.=0A+#=0A+###########=
############################################################=0A+# =
Initialization:=0A+=0A+: ${OCF_FUNCTIONS_DIR=3D${OCF_ROOT}/lib/heartbeat}=
=0A+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs=0A+=0A+##########################=
#############################################=0A+=0A+meta_data() {=0A+	=
cat <<END=0A+<?xml version=3D"1.0"?>=0A+<!DOCTYPE resource-agent SYSTEM =
"ra-api-1.dtd">=0A+<resource-agent name=3D"NodeUtilization">=0A+<version>1.=
0</version>=0A+=0A+<longdesc lang=3D"en">=0A+This is an NodeUtilization =
Resource Agent.=0A+This agent detects system parameters and put them into =
CIB by crm_attribute,=0A+and it runs on every node as clone resource.=0A+</=
longdesc>=0A+<shortdesc lang=3D"en">NodeUtilization resource agent</shortde=
sc>=0A+=0A+<parameters>=0A+<parameter name=3D"dynamic" unique=3D"0" =
required=3D"0">=0A+<longdesc lang=3D"en">=0A+If set, some of the HA =
parameters will be reset if there are=0A+difference between HA parameters =
and system parameters when HA monitor.=0A+Otherwise, the HA parameters =
will be set once when the resource instance starts.=0A+</longdesc>=0A+<shor=
tdesc lang=3D"en">Set HA parameters when start or monitor</shortdesc>=0A+<c=
ontent type=3D"boolean" default=3D"true" />=0A+</parameter>=0A+=0A+<paramet=
er name=3D"utilization_cpu" unique=3D"0" required=3D"0">=0A+<longdesc =
lang=3D"en">Enable setting cpu utilization.</longdesc>=0A+<shortdesc =
lang=3D"en">Enable setting cpu utilization.</shortdesc>=0A+<content =
type=3D"boolean" default=3D"true" />=0A+</parameter>=0A+=0A+<parameter =
name=3D"utilization_cpu_reservation" unique=3D"0" required=3D"0">=0A+<longd=
esc lang=3D"en">CPU reserved for non-HA related usage.</longdesc>=0A+<short=
desc lang=3D"en">CPU reserved for non-HA related usage.</shortdesc>=0A+<con=
tent type=3D"integer" default=3D"1" />=0A+</parameter>=0A+=0A+<parameter =
name=3D"utilization_host_memory" unique=3D"0" required=3D"0">=0A+<longdesc =
lang=3D"en">Enable setting memory utilization of host.</longdesc>=0A+<short=
desc lang=3D"en">Enable setting memory utilization of host.</shortdesc>=0A+=
<content type=3D"boolean" default=3D"true" />=0A+</parameter>=0A+=0A+<param=
eter name=3D"utilization_host_memory_reservation" unique=3D"0" required=3D"=
0">=0A+<longdesc lang=3D"en">Memory reserved for other services inside =
host, in MB.</longdesc>=0A+<shortdesc lang=3D"en">Memory reserved for =
other services inside host, in MB.</shortdesc>=0A+<content type=3D"integer"=
 default=3D"512" />=0A+</parameter>=0A+=0A+<parameter name=3D"utilization_h=
v_memory" unique=3D"0" required=3D"0">=0A+<longdesc lang=3D"en">Enable =
setting the memory utilization of hypervisor.</longdesc>=0A+<shortdesc =
lang=3D"en">Enable setting the memory utilization of hypervisor.</shortdesc=
>=0A+<content type=3D"boolean" default=3D"true" />=0A+</parameter>=0A+=0A+<=
parameter name=3D"utilization_hv_memory_reservation" unique=3D"0" =
required=3D"0">=0A+<longdesc lang=3D"en">Memory reserved for the hypervisor=
, in MB.</longdesc>=0A+<shortdesc lang=3D"en">Memory reserved for the =
hypervisor, in MB.</shortdesc>=0A+<content type=3D"integer" default=3D"512"=
 />=0A+</parameter>=0A+</parameters>=0A+=0A+<actions>=0A+<action name=3D"st=
art"   timeout=3D"90" />=0A+<action name=3D"stop"    timeout=3D"100" =
/>=0A+<action name=3D"monitor" timeout=3D"20s" interval=3D"60s"/>=0A+<actio=
n name=3D"meta-data"  timeout=3D"5" />=0A+<action name=3D"validate-all"  =
timeout=3D"30" />=0A+</actions>=0A+</resource-agent>=0A+END=0A+}=0A+=0A+set=
_utilization() {=0A+    host_name=3D"$(hostname)"=0A+=0A+    if [ =
"$OCF_RESKEY_utilization_cpu" =3D "true" -o "$OCF_RESKEY_utilization_cpu" =
=3D "1" ]; then=0A+        sys_cpu=3D$(( $(grep -c processor /proc/cpuinfo)=
 - $OCF_RESKEY_utilization_cpu_reservation ))=0A+        uti_cpu=3D$(crm_at=
tribute -Q -t nodes -U "$host_name" -z -n cpu 2>/dev/null)=0A+=0A+        =
if [ "$sys_cpu" !=3D "$uti_cpu" ]; then=0A+            if ! crm_attribute =
-t nodes -U "$host_name" -z -n cpu -v $sys_cpu; then=0A+                =
ocf_log err "Failed to set cpu of utilization by crm_attribute."=0A+       =
         return 1=0A+            fi=0A+        fi=0A+    fi=0A+=0A+    if =
[ "$OCF_RESKEY_utilization_host_memory" =3D "true" -o "$OCF_RESKEY_utilizat=
ion_host_memory" =3D "1" ]; then=0A+        sys_mem=3D$(( $(awk '/MemTotal/=
{printf("%d\n",$2/1024);exit(0)}' /proc/meminfo) - $OCF_RESKEY_utilization_=
host_memory_reservation ))=0A+        uti_mem=3D$(crm_attribute -Q -t =
nodes -U "$host_name" -z -n host_memory 2>/dev/null)=0A+=0A+        if [ =
"$sys_mem" !=3D "$uti_mem" ]; then=0A+            if ! crm_attribute -t =
nodes -U "$host_name" -z -n host_memory -v $sys_mem; then=0A+              =
  ocf_log err "Failed to set host_memory of utilization by crm_attribute."=
=0A+                return 1=0A+            fi=0A+        fi=0A+    =
fi=0A+=0A+    if [ -x /usr/sbin/xm ]; then=0A+        if [ "$OCF_RESKEY_uti=
lization_hv_memory" =3D "true" -o "$OCF_RESKEY_utilization_hv_memory" =3D =
"1" ]; then=0A+            hv_mem=3D$(( $(xm info | awk '/max_free_memory/{=
printf("%d\n",$3);exit(0)}') - $OCF_RESKEY_utilization_hv_memory_reservatio=
n ))=0A+            uti_mem=3D$(crm_attribute -Q -t nodes -U "$host_name" =
-z -n hv_memory 2>/dev/null)=0A+=0A+            if [ "$hv_mem" !=3D =
"$uti_mem" ]; then=0A+                if ! crm_attribute -t nodes -U =
"$host_name" -z -n hv_memory -v $hv_mem; then=0A+                    =
ocf_log err "Failed to set hv_memory of utilization by crm_attribute."=0A+ =
                   return 1=0A+                fi=0A+            fi=0A+    =
    fi=0A+    fi=0A+}=0A+=0A+NodeUtilization_usage() {=0A+	cat =
<<END=0A+usage: $0 {start|stop|monitor|validate-all|meta-data}=0A+=0A+Expec=
ts to have a fully populated OCF RA-compliant environment set.=0A+END=0A+}=
=0A+=0A+NodeUtilization_start() {=0A+    if ! touch "$OCF_RESKEY_pidfile"; =
then=0A+        ocf_log err "Failed to touch pidfile: ${OCF_RESKEY_pidfile}=
."=0A+        exit $OCF_ERR_GENERIC=0A+    fi=0A+    if [ "$OCF_RESKEY_dyna=
mic" =3D "false" -o "$OCF_RESKEY_dynamic" =3D "0" ]; then=0A+        if ! =
set_utilization; then=0A+            exit $OCF_ERR_GENERIC=0A+        =
fi=0A+    fi=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+NodeUtilization_stop() =
{=0A+    rm -f $OCF_RESKEY_pidfile=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+Nod=
eUtilization_monitor() {=0A+    if [ ! -f $OCF_RESKEY_pidfile ]; then=0A+  =
      exit $OCF_NOT_RUNNING=0A+    fi=0A+=0A+    if [ "$OCF_RESKEY_dynamic"=
 =3D "true" -o "$OCF_RESKEY_dynamic" =3D "1" ]; then=0A+        if ! =
set_utilization; then=0A+            exit $OCF_ERR_GENERIC=0A+        =
fi=0A+    fi=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+NodeUtilization_validate(=
) {=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+=0A+: ${OCF_RESKEY_pidfile:=3D"$HA=
_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}=0A+: ${OCF_RESKEY_dynami=
c:=3D"true"}=0A+: ${OCF_RESKEY_utilization_cpu:=3D"true"}=0A+: ${OCF_RESKEY=
_utilization_cpu_reservation=3D"1"}=0A+: ${OCF_RESKEY_utilization_hv_memory=
:=3D"true"}=0A+: ${OCF_RESKEY_utilization_hv_memory_reservation=3D"512"}=0A=
+: ${OCF_RESKEY_utilization_host_memory:=3D"true"}=0A+: ${OCF_RESKEY_utiliz=
ation_host_memory_reservation=3D"512"}=0A+=0A+if [ $# -ne 1 ]; then=0A+    =
NodeUtilization_usage=0A+    exit $OCF_ERR_ARGS=0A+fi=0A+=0A+case =
$__OCF_ACTION in=0A+meta-data)	meta_data=0A+		exit $OCF_SUCCESS=
=0A+		;;=0A+start)		NodeUtilization_start=0A+		=
;;=0A+stop)		NodeUtilization_stop=0A+		;;=0A+monit=
or)	NodeUtilization_monitor=0A+		;;=0A+validate-all)	=
NodeUtilization_validate=0A+		;;=0A+usage|help)	NodeUtiliza=
tion_usage=0A+		exit $OCF_SUCCESS=0A+		;;=0A+*)		=
NodeUtilization_usage=0A+		exit $OCF_ERR_UNIMPLEMENTED=0A+		=
;;=0A+esac=0A+=0A+exit $?=0A-- =0A1.7.2.5=0A=0A
--=__Part4D624B59.0__=
Content-Type: text/plain; name="0001-Low-VirtualDomain-Add-a-functionality-that-modifiesu.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="0001-Low-VirtualDomain-Add-a-functionality-that-modifiesu.patch"



More information about the ha-wg-technical mailing list