Operating System - HP-UX
1824983 Members
3882 Online
109678 Solutions
New Discussion

how to write a script to find the status of Cluster system

 
Khairul_1
Frequent Advisor

how to write a script to find the status of Cluster system

Hi,
We have two node HP-UX 11i v2 11.23 rx5670 Cluster production system. We can check the Cluster health statuts by using cmviewcl and cmviewcl -v command.

Could any one help to write a script for check the cluster health status and send the output into another file?

Thanks
Khairul
1 REPLY 1
Srinikalyan
Regular Advisor

Re: how to write a script to find the status of Cluster system

Hi khairul,
Please find the script. This may help you to check the health of the cluster.
#!/bin/sh
#check for the output file. If yes, delete it.
if [ -f /tmp/output.txt ]
then
rm -f /tmp/output.txt
fi

clust_status=$(cmviewcl -f line -l cluster| grep -e status|cut -d = -f 2,2)
if [ "$clust_status" = "up" ]
then


# Exclude Multi-node packages in the cmviewcl output.

for pkg_name in $(cmviewcl -f line -l package|grep -e type|grep -v multi_node|cu
t -d : -f 2,2 | cut -d "|" -f 1,1)
do
running_node=$(cmviewcl -v -p $pkg_name | grep current | awk '{print $1}')
node_name=$(cmviewcl -v -p $pkg_name | grep current | awk '{print $4}')

if [ "$running_node" = "Primary" ]
then
...skipping...
#!/bin/sh
#check for the output file. If yes, delete it.
if [ -f /tmp/output.txt ]
then
rm -f /tmp/output.txt
fi

clust_status=$(cmviewcl -f line -l cluster| grep -e status|cut -d = -f 2,2)
if [ "$clust_status" = "up" ]
then


# Exclude Multi-node packages in the cmviewcl output.


for pkg_name in $(cmviewcl -f line -l package|grep -e type|grep -v multi_node|cut -d : -f 2,2 | cut -d "|" -f 1,1)
do
running_node=$(cmviewcl -v -p $pkg_name | grep current | awk '{print $1}')
node_name=$(cmviewcl -v -p $pkg_name | grep current | awk '{print $4}')

if [ "$running_node" = "Primary" ]
then
echo $pkg_name running in Primary node $node_name. >> /tmp/output.txt
elif [ "$(cmviewcl -f line -l package -p $pkg_name|grep -e status|cut -d = -f 2,2)" != "up" ]
then
echo $pkg_name package totally down. Not running in Primary $node_name as well as secondary $node_name. >> /tmp/output.txt
else
echo $pkg_name running in Secondary node $node_name. >> /tmp/output.txt
fi
done
#mailx -s "Cluster status" aaa@bbb.com < /tmp/output.txt


else

echo "Cluster not up" >> /tmp/output.txt
fi