No subject


Thu Oct 27 00:53:32 UTC 2011


n that is detecting OS information and putting them into CIB by crm_attribu=
te=0A=0A---=0A extra/resources/Makefile.am     |    1 +=0A extra/resources/=
NodeUtilization |  217 +++++++++++++++++++++++++++++++++++++++=0A 2 files =
changed, 218 insertions(+), 0 deletions(-)=0A create mode 100644 extra/reso=
urces/NodeUtilization=0A=0Adiff --git a/extra/resources/Makefile.am =
b/extra/resources/Makefile.am=0Aindex bc35401..210e9ed 100644=0A--- =
a/extra/resources/Makefile.am=0A+++ b/extra/resources/Makefile.am=0A@@ =
-27,6 +27,7 @@ ocf_SCRIPTS	     =3D  ClusterMon 	\=0A 			=
Dummy		\=0A 			HealthCPU	\=0A 			=
HealthSMART	\=0A+			NodeUtilization	\=0A 			=
o2cb		\=0A 			ping		\=0A 			=
pingd		\=0Adiff --git a/extra/resources/NodeUtilization b/extra/re=
sources/NodeUtilization=0Anew file mode 100644=0Aindex 0000000..94036ad=0A-=
-- /dev/null=0A+++ b/extra/resources/NodeUtilization=0A@@ -0,0 +1,217 =
@@=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_ROOT}/resource.d/heartbeat/.ocf-shellfuncs=
=0A+=0A+###################################################################=
####=0A+=0A+meta_data() {=0A+	cat <<END=0A+<?xml version=3D"1.0"?>=0A+<!D=
OCTYPE resource-agent SYSTEM "ra-api-1.dtd">=0A+<resource-agent name=3D"Nod=
eUtilization">=0A+<version>1.0</version>=0A+=0A+<longdesc lang=3D"en">=0A+T=
his is an NodeUtilization Resource Agent.=0A+This agent detects system's =
parameters such as total_memory=0A+and put them into CIB by crm_attribute. =
=0A+It runs on every node as clone resource.=0A+</longdesc>=0A+<shortdesc =
lang=3D"en">NodeUtilization resource agent</shortdesc>=0A+=0A+<parameters>=
=0A+=0A+<parameter name=3D"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"cpu_reservation" unique=3D"0" required=3D"0">=0A+<longdesc =
lang=3D"en">CPU reserved for non-HA related usage.</longdesc>=0A+<shortdesc=
 lang=3D"en">CPU reserved for non-HA related usage.</shortdesc>=0A+<content=
 type=3D"integer" default=3D"1" />=0A+</parameter>=0A+=0A+<parameter =
name=3D"host_memory" unique=3D"0" required=3D"0">=0A+<longdesc lang=3D"en">=
Enable setting memory utilization of host.</longdesc>=0A+<shortdesc =
lang=3D"en">Enable setting memory utilization of host.</shortdesc>=0A+<cont=
ent type=3D"boolean" default=3D"true" />=0A+</parameter>=0A+=0A+<parameter =
name=3D"host_memory_reservation" unique=3D"0" required=3D"0">=0A+<longdesc =
lang=3D"en">Memory reserved for other services inside host, in MB.</longdes=
c>=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"hv_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"hv_memory_reservation" unique=3D"0" required=3D"0">=0A+<longdesc =
lang=3D"en">Memory reserved for the hypervisor, in MB.</longdesc>=0A+<short=
desc lang=3D"en">Memory reserved for the hypervisor, in MB.</shortdesc>=0A+=
<content type=3D"integer" default=3D"512" />=0A+</parameter>=0A+=0A+</param=
eters>=0A+=0A+<actions>=0A+<action name=3D"start"   timeout=3D"90" =
/>=0A+<action name=3D"stop"    timeout=3D"100" />=0A+<action name=3D"monito=
r" timeout=3D"20s" interval=3D"60s"/>=0A+<action 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+NodeUtilization_us=
age() {=0A+	cat <<END=0A+usage: $0 {start|stop|monitor|validate-all|met=
a-data}=0A+=0A+Expects 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+=0A+    host_name=3D"$(uname -n)"=0A+=0A+    if ocf_is_true =
"$OCF_RESKEY_cpu"; then=0A+        sys_cpu=3D$(( $(grep -c processor =
/proc/cpuinfo) - $OCF_RESKEY_cpu_reservation ))=0A+        uti_cpu=3D$(crm_=
attribute -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 >/dev/null 2>&1; then=0A+   =
             ocf_log err "Failed to set cpu of utilization by crm_attribute=
."=0A+                exit $OCF_ERR_GENERIC=0A+            fi=0A+        =
fi=0A+    fi=0A+=0A+    if ocf_is_true "$OCF_RESKEY_host_memory"; then=0A+ =
       sys_mem=3D$(( $(awk '/MemTotal/{printf("%d\n",$2/1024)}' /proc/memin=
fo) - $OCF_RESKEY_host_memory_reservation ))=0A+        uti_mem=3D$(crm_att=
ribute -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 =
>/dev/null 2>&1; then=0A+                ocf_log err "Failed to set =
host_memory of utilization by crm_attribute."=0A+                exit =
$OCF_ERR_GENERIC=0A+            fi=0A+        fi=0A+    fi=0A+=0A+    if =
ocf_is_true "$OCF_RESKEY_hv_memory"; then=0A+        if command -v virsh =
>/dev/null 2>&1; then=0A+            hv_mem=3D$(virsh nodeinfo | awk =
'/Memory size/{printf("%d\n",$3/1024)}')=0A+        fi=0A+        if test =
-z "$hv_mem" && command -v xm >/dev/null 2>&1; then=0A+            =
hv_mem=3D$(xm info | awk '/total_memory/{print $3}')=0A+        fi=0A+	if =
test -z "$hv_mem"; then=0A+            ocf_log err "Could not get =
hv_memory."=0A+            exit $OCF_ERR_GENERIC=0A+        fi=0A+=0A+	=
hv_mem=3D$((hv_mem - OCF_RESKEY_hv_memory_reservation))=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 >/dev/null 2>&1; then=0A+                ocf_log err "Failed to =
set hv_memory of utilization by crm_attribute."=0A+                exit =
$OCF_ERR_GENERIC=0A+            fi=0A+        fi=0A+    fi=0A+=0A+    exit =
$OCF_SUCCESS=0A+}=0A+=0A+NodeUtilization_stop() {=0A+    rm -f $OCF_RESKEY_=
pidfile=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+NodeUtilization_monitor() =
{=0A+    if [ ! -f $OCF_RESKEY_pidfile ]; then=0A+        exit $OCF_NOT_RUN=
NING=0A+    fi=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+NodeUtilization_validat=
e() {=0A+    exit $OCF_SUCCESS=0A+}=0A+=0A+=0A+: ${OCF_RESKEY_pidfile:=3D"$=
HA_VARRUN/NodeUtilization-${OCF_RESOURCE_INSTANCE}"}=0A+: ${OCF_RESKEY_cpu:=
=3D"true"}=0A+: ${OCF_RESKEY_cpu_reservation=3D"1"}=0A+: ${OCF_RESKEY_hv_me=
mory:=3D"true"}=0A+: ${OCF_RESKEY_hv_memory_reservation=3D"512"}=0A+: =
${OCF_RESKEY_host_memory:=3D"true"}=0A+: ${OCF_RESKEY_host_memory_reservati=
on=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)		NodeUtiliza=
tion_stop=0A+		;;=0A+monitor)	NodeUtilization_monitor=0A+		=
;;=0A+validate-all)	NodeUtilization_validate=0A+		;;=0A+usage=
|help)	NodeUtilization_usage=0A+		exit $OCF_SUCCESS=0A+		=
;;=0A+*)		NodeUtilization_usage=0A+		exit =
$OCF_ERR_UNIMPLEMENTED=0A+		;;=0A+esac=0A+=0A+exit $?=0A-- =
=0A1.6.4.2=0A=0A
--=__Part5679DBB4.2__=--


More information about the ha-wg-technical mailing list