[Ocfs2-tools-devel] [PATCH 6/7] o2cb.init: Improve o2cb status

Sunil Mushran sunil.mushran at oracle.com
Thu Mar 17 17:31:50 PDT 2011


o2cb status lists the global heartbeat regions and the nodes in the
o2cb cluster. This patch does not change the output if local heartbeat
is active.

The full output in global heartbeat mode is as follows:

$ service o2cb status
Driver for "configfs": Loaded
Filesystem "configfs": Mounted
Stack glue driver: Loaded
Stack plugin "o2cb": Loaded
Driver for "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster "mycluster": Online
  Heartbeat dead threshold: 31
  Network idle timeout: 30000
  Network keepalive delay: 2000
  Network reconnect delay: 2000
  Heartbeat mode: Global
Checking O2CB heartbeat: Active
  77D95EF51C0149D2823674FCC162CF8B /dev/sdh1
  BBA1DBD0F73F449384CE75197D9B7098 /dev/sdf1
  DCDA2845177F4D59A0F2DCD8DE507CC3 /dev/sdm1
Nodes in O2CB cluster: 92 96
Active userdlm domains:  domain1 domain2

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 vendor/common/o2cb.init.sh |   53 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 vendor/common/o2cb.init.sh

diff --git a/vendor/common/o2cb.init.sh b/vendor/common/o2cb.init.sh
old mode 100644
new mode 100755
index fb35de0..622c0a6
--- a/vendor/common/o2cb.init.sh
+++ b/vendor/common/o2cb.init.sh
@@ -34,6 +34,7 @@ CLUSTER_STACK_FILE="${OCFS2_SYS_DIR}/cluster_stack"
 DLMFS_CAPABILITIES_FILE='/sys/module/ocfs2_dlmfs/parameters/capabilities'
 DLMFS_DIR="/dlm"
 DLMFS_MAGIC="76a9f425"
+DEBUGFS_DIR="/sys/kernel/debug"
 
 if [ -f /etc/sysconfig/o2cb ]
 then
@@ -787,6 +788,48 @@ kill_daemon()
 }
 
 #
+# list_nodes_o2cb()
+#
+list_nodes_o2cb()
+{
+    check_filesystem "debugfs" "$DEBUGFS_DIR"
+    if [ "$?" -ne "0" ]
+    then
+        return
+    fi
+
+    nodestr=$(cat $DEBUGFS_DIR/o2hb/livenodes)
+    echo "Nodes in O2CB cluster: $nodestr"
+}
+
+#
+# list_heartbeat_o2cb()
+#
+list_heartbeat_o2cb()
+{
+    if [ "$#" -lt "1" -o -z "$1" ]
+    then
+        echo "list_heartbeat_o2cb(): Requires an argument" >&2
+        return 1
+    fi
+    CLUSTER="$1"
+
+    RC=0
+    if [ -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" ]
+    then
+        ls -1 "$(configfs_path)/cluster/${CLUSTER}/heartbeat/" | while read HBUUID
+        do
+            if [ -d "$(configfs_path)/cluster/${CLUSTER}/heartbeat/${HBUUID}" ]
+            then
+                dev=$(cat "$(configfs_path)/cluster/${CLUSTER}/heartbeat/${HBUUID}/dev")
+                echo "  ${regionstr}${HBUUID} /dev/${dev}"
+            fi
+        done
+    fi
+}
+
+
+#
 # check_heartbeat_o2cb()
 #
 # 0 is hb not active, 1 is error, 2 is hb active
@@ -1718,7 +1761,7 @@ online_status_o2cb()
     fi
     CLUSTER="$1"
 
-    echo -n "Checking O2CB cluster $CLUSTER: "
+    echo -n "Checking O2CB cluster \"$CLUSTER\": "
     check_online_o2cb $CLUSTER
     if [ $? = 2 ]
     then
@@ -1737,7 +1780,7 @@ online_status_o2cb()
         HBMODE="Global"
     fi
 
-    echo "  Heartbeat Mode: ${HBMODE}"
+    echo "  Heartbeat mode: ${HBMODE}"
 
     echo -n "Checking O2CB heartbeat: "
     check_heartbeat_o2cb $CLUSTER
@@ -1748,6 +1791,12 @@ online_status_o2cb()
         echo "Not active"
         return 0;
     fi
+
+    if [ $HBMODE = "Global" ]
+    then
+        list_heartbeat_o2cb $CLUSTER
+        list_nodes_o2cb
+    fi
 }
 
 online_status_user()
-- 
1.7.1




More information about the Ocfs2-tools-devel mailing list