Operating System - HP-UX
1825719 Members
3071 Online
109686 Solutions
New Discussion

Script for Failover Notification

 
ricky2
Frequent Advisor

Script for Failover Notification

Hi,

I'm looking for a script which could send a email notification when ever a package failover happen.

Regards,
Ricky
7 REPLIES 7
Matti_Kurkela
Honored Contributor

Re: Script for Failover Notification

A package failover is a combination of two operations: halting the package on one node and starting it on another. If you want to perform an action at failover, you should add the action to either one of these operations.

Only the package start operation is guaranteed to happen: if the failover happens because the original node has crashed, lost power or even burnt to ashes, the failing node is obviously not going to perform any package shutdown actions.

The simplest method would be to add a command for sending the email to package startup actions:

mailx -s "Package startup on node $(hostname)" someone@company.example
This would send a message *every* time a package starts up. It would be the job of the receiver of the message to determine whether this was a failover or a pre-planned maintenance action.

(The example command above leaves the message content empty, as everything that needs to be said fits in the message subject.)

MK
MK
Basheer_2
Trusted Contributor

Re: Script for Failover Notification

We set up in 2 ways

1) write a small script for cmviewl and cron it every 15 minutes

2) We had a maintenance script, that emailed whenever there was a failover

ricky2
Frequent Advisor

Re: Script for Failover Notification

Thanks Bashir,

Could you please share those scripts?

Regards,
Ricky
Steven E. Protter
Exalted Contributor

Re: Script for Failover Notification

Shalom,

Build a a call to build an attachment into your cluster scripts.


http://www.hpux.ws/?p=7

That script will enable you to send out an email with an attachment.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mel Burslan
Honored Contributor

Re: Script for Failover Notification

A very simple script I have written for an ex-colleague of mine who took over a couple of HPUX servers and not well versed in MCSG or posix shell programming. Hope it helps you. You can put it in crontab to run at whatever frequency you wish to do it.

#!/usr/bin/sh

# script name : cluster_mon
# script location : /etc/cmcluster
# prerequisites :
# ... run the following command prior to first run of this script
# ... cmviewcl > /etc/cmcluster/cluster_status.out
#

notify_list=me@mydomain.com

cmviewcl > /var/tmp/cluster_status.out

diff /etc/cmcluster/cluster_status.out /var/tmp/cluster_status.out > /dev/null
r=${?}

case $r in
0) echo "cluster is stable at $(date)" >> /var/adm/cluster_mon.log
exit 0
;;
1) echo "cluster status has changed since last check. $(date)" >> /var/adm/cluster_mon.log
echo "PREVIOUS CLUSTER STATUS\n" > /var/tmp/mailfile
cat /etc/cmcluster/cluster_status.out >> /var/tmp/mailfile
echo "\n\n\nCURRENT CLUSTER STATUS\n" >> /var/tmp/mailfile
cat /var/tmp/cluster_status.out >> /var/tmp/mailfile
echo "\n\n\n\nChanges found in the cluster status since the last check at $(date) >> /var/tmp/mailfile
cat /var/tmp/mailfile | mailx -s "Cluster Status Change ALERT !!" $notify_list
mv /var/tmp/cluster_status.out /etc/cmcluster/cluster_status.out
;;
*) MSG="Diff returned an unknown error while comparing cluster status files. Please investigate. $(date)"
echo $MSG >> /var/adm/cluster_mon.log
echo $MSG | mailx -s "ERROR while cheking cluster status" $notify_list
;;
esac
________________________________
UNIX because I majored in cryptology...
ricky2
Frequent Advisor

Re: Script for Failover Notification

Shalom Steven,

Could you be more clear about attachment into my cluster scripts?
How does it help me?


Regards,
Ricky
Rick Garland
Honored Contributor

Re: Script for Failover Notification

View the output from the cmviewcl command. If running SG version 11.17 or later you have the -f switch available.

Can use sudo to execute as a non-root user.

sudo /usr/sbin/cmviewcl -f line | grep owner | awk -F= '{print $2}'

This command will tell you who the owner is of a particular package.