Author |
Message
|
senMQ |
Posted: Fri Feb 09, 2018 8:51 am Post subject: Alert emails during fail over |
|
|
Acolyte
Joined: 14 Aug 2006 Posts: 66 Location: Palo Alto, CA
|
We have an environment with MQHA set up on v9.0.0.1. The client wants to get an email when the queue manager fails over from one node to another. I have prepared a script for it. The script parses the server name from the file /mqha/qmgrs/$QMGR/active to identify the active node. The script works fine when I run it manually. I'm trying to trigger it as a service in the queue manager start up like this:
dis service(STATUS)
1 : dis service(STATUS)
AMQ8629: Display service information details.
SERVICE(STATUS) CONTROL(QMGR)
SERVTYPE(COMMAND) STARTCMD(/home/mqm/QM_StatusMail.sh)
STARTARG( ) STOPCMD( )
STOPARG( ) STDOUT( )
STDERR( ) DESCR( )
ALTDATE(2018-02-0 ALTTIME(16.18.10)
But, the script doesnt get trigger during the startup.
What am I missing here? Is it even possible to set up such alerting emails in a HA environment?
TIA
Deepa |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 09, 2018 8:59 am Post subject: Re: Alert emails during fail over |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
senMQ wrote: |
What am I missing here? |
From here:
Quote: |
IBM® MQ is installed on two servers, one of which is a spare. One queue manager, QM1, has been created. One instance of QM1 is active, and is running on one server. The other instance of QM1 is running in standby on the other server, doing no active processing, but ready to take over from the active instance of QM1, if the active instance fails |
Because the passive instance is running, the STARTCMD command isn't triggered; I'd expect you to get 2 emails when you start the set up, one from each queue manager. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
senMQ |
Posted: Fri Feb 09, 2018 9:12 am Post subject: |
|
|
Acolyte
Joined: 14 Aug 2006 Posts: 66 Location: Palo Alto, CA
|
Thats what I thought too. Thats why I wanted to know if there is a better way to do it.
But, right now the script isnt even getting triggered. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 09, 2018 10:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
senMQ wrote: |
Thats why I wanted to know if there is a better way to do it. |
Use a better HA mechanism than the free one that comes out of the box.
senMQ wrote: |
But, right now the script isnt even getting triggered. |
At all? Even when the queue managers are actually started?
I'd change the service to write stdout & stderr to files, and pass "START" and "STOP" as an argument to the script, changing the emails accordingly.
Then see what that yields. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
senMQ |
Posted: Fri Feb 09, 2018 10:11 am Post subject: |
|
|
Acolyte
Joined: 14 Aug 2006 Posts: 66 Location: Palo Alto, CA
|
The script I have right now doesnt even send mails as I wanted to start with the basics, I'm just creating a flat file with the status like this. This is my script:
export QMGR=`dspmq | grep 'QMNAME(' | awk -F'(' '{print $2}' | awk -F')' '{print $1}'`
export SERVER=`cut -c-10 /mqha/qmgrs/$QMGR/active`
echo $QMGR Queue manager is running on $SERVER > status.out
I'm not even seeing the status.out file. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 09, 2018 10:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
senMQ wrote: |
I'm not even seeing the status.out file. |
No, you won't and you implied the script was successfully sending emails in your original post.
When you run the script manually, that last line echos the text to stdout which redirects to a file via the ">" operator. When you run this as a service, the last line echos the text to stdout which (according to your service definition) is null. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
senMQ |
Posted: Fri Feb 09, 2018 10:34 am Post subject: |
|
|
Acolyte
Joined: 14 Aug 2006 Posts: 66 Location: Palo Alto, CA
|
The file is getting created when I give it in STDOUT Thanks for your help!
But, how do I send a mail? Can I just add the mailx line to the script like this or do I need to do anything else:
#echo $QMGR Queue manager is running on $SERVER | mailx -s "$QMGR" deepakar@us.ibm.com |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 09, 2018 10:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
senMQ wrote: |
But, how do I send a mail? Can I just add the mailx line to the script like this or do I need to do anything else:
#echo $QMGR Queue manager is running on $SERVER | mailx -s "$QMGR" deepakar@us.ibm.com |
Depends if mailx is installed on the server & the mqm user is authorized to use it.
Your question is better directed to whoever administers the server on your site than to us. It's highly possible there's another product installed as a mailer than the rather simplistic mailx that they'd prefer you to use. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
senMQ |
Posted: Fri Feb 09, 2018 11:16 am Post subject: |
|
|
Acolyte
Joined: 14 Aug 2006 Posts: 66 Location: Palo Alto, CA
|
I'm able to send emal using mailx from command line & while running the script manually from one of the servers. But, I'm not get an email from that server when I call the script from the queue manager. So, my question is, is it even possible to call a script that sends emails from the queue manager?
TIA
Deepa |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 09, 2018 11:34 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
senMQ wrote: |
I'm able to send emal using mailx from command line & while running the script manually from one of the servers. But, I'm not get an email from that server when I call the script from the queue manager. So, my question is, is it even possible to call a script that sends emails from the queue manager? |
When you run the script manually, are you logged on as yourself or the mqm user (my point about being authorized to use mailx applies)?
A script being run from a service is the same as a script being run from a command prompt. Which means it inherits the OS shell, user credentials, environment variables and other oddments when it runs as a service as it does when it runs from a command prompt. As a simple example, when you run the script the command shell has your .profile installed in it as well as whatever generic settings the admin has put in place for terminal users. The mqm user will have a different .profile (because it's a different user) that may or may not contain the same setup, and if it's been defined as a non-terminal user (a common security precaution) it will lack the generic settings your id has.
I repeat, you're talking about site specific items we can't help with. In theory, you can email from a script. In practice, there are any number of things that can go wrong.
And I remain surprised that the script goes off when the passive but already running queue manager takes over. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Feb 09, 2018 5:22 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Vitor wrote: |
And I remain surprised that the script goes off when the passive but already running queue manager takes over. |
You're assuming the HA method is Multi-Instance Queue Managers.
If its instead a "classic" Active/Passive cluster like HCAMP or VCS, then the QM really is starting up from a pure down state on the passive node.
The OP might look into enabling Start/Stop Events for the Queue Manager and acting on those event messages. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
Vitor |
Posted: Mon Feb 12, 2018 6:09 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
PeterPotkay wrote: |
Vitor wrote: |
And I remain surprised that the script goes off when the passive but already running queue manager takes over. |
You're assuming the HA method is Multi-Instance Queue Managers. |
True.
senMQ wrote: |
We have an environment with MQHA set up on v9.0.0.1 |
I took this to be multi-instance.
PeterPotkay wrote: |
If its instead a "classic" Active/Passive cluster like HCAMP or VCS, then the QM really is starting up from a pure down state on the passive node.
The OP might look into enabling Start/Stop Events for the Queue Manager and acting on those event messages |
If the OP has access to HACMP or VCS, using the alerting built into those products would be better / easier / simpler than event messages. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 12, 2018 7:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Qmgr start and stop also write a lot of messages into the qmgr's error log and specify in the log the host the qmgr is running on.
If they are already evaluating the qmgr's error logs they could kick off the email from the logs evaluation (splunk or similar?)  _________________ MQ & Broker admin |
|
Back to top |
|
 |
exerk |
Posted: Mon Feb 12, 2018 8:05 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
fjb_saper wrote: |
..If they are already evaluating the qmgr's error logs they could kick off the email from the logs evaluation (splunk or similar?)  |
Yay for V9.0.4 - 'splunky' format error logs to make it easy  _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
zpat |
Posted: Tue Feb 13, 2018 12:47 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
|
Back to top |
|
 |
|