Is there a way to verify if the AMQP Service is running correctly. Installation is on Linux - RHEL.
When the AMQP Service is started, command results suggests it is started, but when the channel is started in successive step, it shows error "AMQ8494: AMQP commands are not available", The error message description says service is not running. (error in STEP6 described below).
Display channel status commands show similar error as well (AMQ8494).
Current Configuration steps and verification steps followed
STEP1:Set primary instance (run as root)
/opt/mqm/bin/setmqinst -i -p /opt/mqm
Run as MQM for following
STEP2: Create queue manager
/opt/mqm/bin/crtmqm QMGR_CLAIM
STEP3:
Update command level
strmqm -e CMDLEVEL=801 QMGR_CLAIM
STEP4:
Start queue manager
/opt/mqm//bin/strmqm QMGR_CLAIM
--Verification steps : how to check if service is running
dspmq
(shows status running)
STEP5:
Start AMQP Service
echo "START SERVICE(SYSTEM.AMQP.SERVICE)" | runmqsc QMGR_CLAIM
--Verification steps : how to check if service is running
Is there a way to verify this actually started service
service SYSTEM.AMQP.SERVICE status
o/p:
Starting MQSC for queue manager QMGR_CLAIM.
1 : START SERVICE(SYSTEM.AMQP.SERVICE)
AMQ8733: Request to start Service accepted.
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
STEP6:
Start default channel
echo "START CHANNEL (SYSTEM.DEF.AMQP)" | runmqsc QMGR_CLAIM
O//P:
Starting MQSC for queue manager QMGR_CLAIM.
1 : START CHANNEL (SYSTEM.DEF.AMQP)
AMQ8494: AMQP commands are not available.
One MQSC command read.
No commands have a syntax error.
One valid MQSC command could not be processed.
--Verification STEPS
Display default channel
echo "display CHANNEL(SYSTEM.DEF.AMQP) CHLTYPE(AMQP)" | runmqsc QMGR_CLAIM
O/P:
Starting MQSC for queue manager QMGR_CLAIM.
1 : display CHANNEL(SYSTEM.DEF.AMQP) CHLTYPE(AMQP)
AMQ8414: Display Channel details.
CHANNEL(SYSTEM.DEF.AMQP) CHLTYPE(AMQP)
ALTDATE(2015-11-12) ALTTIME(18.38.30)
CERTLABL( ) DESCR( )
AMQPKA(AUTO) LOCLADDR( )
MAXINST(999999999) MAXMSGL(4194304)
MCAUSER( ) PORT(5672)
SSLCAUTH(REQUIRED) SSLCIPH( )
SSLPEER( ) USECLTID(NO)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
Display channel status
echo "dis chstatus(SYSTEM.DEF.AMQP) chltype(AMQP) all" | runmqsc QMGR_CLAIM
echo "display chstatus(*)" | runmqsc QMGR_CLAIM
O/P:
Starting MQSC for queue manager QMGR_CLAIM.
1 : display chstatus(*)
AMQ8420: Channel Status not found.
One MQSC command read.
No commands have a syntax error.
One valid MQSC command could not be processed.
STEP7:
Alter default channel , set port 5672
echo "ALTER CHANNEL(SYSTEM.DEF.AMQP) CHLTYPE(AMQP) PORT(5672)" | runmqsc QMGR_CLAIM
STEP8
Disable user authorizations Channel
echo "ALTER QMGR CHLAUTH(DISABLED)" | runmqsc QMGR_CLAIM
STEP9
Start Listener
echo "start LISTENER(SYSTEM.DEFAULT.LISTENER.TCP)" | runmqsc QMGR_CLAIM
--Verification
echo "DISPLAY LSSTATUS(*) STATUS" | runmqsc QMGR_CLAIM
echo "display lsstatus(SYSTEM.DEFAULT.LISTENER.TCP)" | runmqsc QMGR_CLAIM
ps -ef | grep runmqlsr | grep 1414
You can check the status of the AMQP service using the DISPLAY SVSTATUS command in runmqsc. You should get output similar to this:
DIS SVSTATUS(SYSTEM.AMQP.SERVICE)
3 : DIS SVSTATUS(SYSTEM.AMQP.SERVICE)
AMQ8632: Display service status details.
SERVICE(SYSTEM.AMQP.SERVICE) STATUS(RUNNING)
PID(19254) SERVTYPE(SERVER)
STARTDA(2015-11-11) STARTTI(16.04.51)
CONTROL(QMGR) STARTCMD(/opt/mqmAMQP//bin/amqp.sh)
STARTARG(start -m QM1 -d "/var/mqm/qmgrs/QM1//." -g "/var/mqm//.")
STOPCMD(/opt/mqmAMQP//bin/amqp.sh)
STOPARG(stop -m QM1 -d "/var/mqm/qmgrs/QM1//." -g "/var/mqm//.")
DESCR(Manages clients that use the AMQP protocol)
STDOUT(/var/mqm/qmgrs/QM1//amqp.stdout)
STDERR(/var/mqm/qmgrs/QM1//amqp.stderr)
You can see that the STATUS field is marked as RUNNING - so the service is up and running correctly and the JVM process ID is 19254.
Related
Say I'm executing a file named run.sh. I have this commands inside this file:
SERVER=${SERVER:-"localhost:5555"}
wait-for-it ${SERVER}
When I echo the ${SERVER}, I can see that it is correctly set to newserver:5555. When I run run.sh file, I get this error:
Command 'newserver:5555' not found
What am I doing wrong?
UPDATE: "wait-for-it is a script that will wait on the availability of one or more TCP services (i.e. host:port) before executing a user-defined command."
From the wait-for-it website that you linked:
Usage: wait-for-it [OPTIONS] [COMMANDS]...
Wait for service(s) to be available before executing a command.
Options:
-h, --help Show this message and exit.
-v, --version Show the version and exit.
-q, --quiet Do not output any status messages
-p, --parallel Test services in parallel rather than in serial
-t, --timeout seconds Timeout in seconds, 0 for no timeout [default: 15]
-s, --service host:port Services to test, in one of the formats: ':port',
'hostname:port', 'v4addr:port', '[v6addr]:port' or
'https://...'
So you probably want:
SERVER=${SERVER:-"localhost:5555"}
wait-for-it --service ${SERVER}
I am trying to write a script which calls the following command
[root#xxxxx imtadmin]# admin tower
-------------------------------------------------------------------
GMS: address=xxxxx-42450, cluster=CLRTY-SA, physical address=xxxxx:45155
-------------------------------------------------------------------
NSA Tower Shell
Usage:
history Show admin shell command history.
!<command prefix> Execute a command maching the given prefix from the command history.
refresh Wake up monitor thread, to update clients.
autodiscovery <on|off> Turn autodiscovery on or off.
add <host(s)> Add given host(s) by address.
remove <host(s)> Remove given host(s) by address.
list clients Print listing of clients.
list services Print listing of client services.
select <address|index> Select a specific client host by address.
connect <address> [port] Connect to a given Select a specific
client host by address.
trace Send trace message on multicast channel.
trace <on|off> Turn trace listening on or off.
password <password> Change password for this session only.
reset password Reset password to local machine value.
group <group> Change channel group for this session only.
(such as CLRTY for listening to PPM
broadcasts.)
reset group Reset group to local machine value.
list group List group members.
exit|quit Exit the tower.
? Print this message.
> list clients **TERMINAL INPUT***
Discovered Clients:
--------------------------
1) xxxxx.ec2.internal:9091 [xxxxx-20212]
--------------------------
> refresh **TERMINAL INPUT***
> list clients **TERMINAL INPUT***
Discovered Clients:
--------------------------
1) xxxxxx.ec2.internal:9091 [xxxxx-59053]
2) yyyyy.ec2.internal:9091 [yyyyy-20212]
3) zzzzzz.ec2.internal:9091 [zzzzz]
--------------------------
>
My Script:
#!/usr/bin/expect
spawn /opt/clarity/bin/admin tower
set timeout -1
expect -re "^>{1}"
send "list clients"
My script does call the command admin tower and stops at the prompt > but it doesn't accept input provided by script or input I provide from the terminal (my goal is to provide input from the script).
This should work :
send "list clients\n"
expect eof
Following worked. Thanks, #Philippe for hinting I need to add expect after providing input.
#!/usr/bin/expect
spawn /opt/clarity/bin/admin tower
expect -re "^>"
send "list clients\r"
expect -re "^>{1}"
send "refresh\r"
expect -re "^>{1}"
send "list clients\r"
expect -re "^>{1}"
send "exit\r"
I have a telnet expect script only used for check if the server is ok.
#!/usr/bin/expect
set IP 192.168.5.100
catch {spawn -noecho telnet $IP}
set timeout 3
expect {
timeout
{ send_user "Telnet timed out waiting for $IP\n" ; exit }
"onnection refused"
{ send_user "Connection was refused to $IP\n" ; exit }
"No route"
{ send_user "System $IP is unknown\n" ; exit}
"login:"
}
send_user "Success\n" ; exit
THis is working perfect and I call it from anothe bash script to store the message into a log file. The problem is that the output have too many information, e.g. in case the server is not reachable:
# ./checkconn.expect
Trying 192.168.5.101...
telnet: connect to address 192.168.5.101: No route to host
System 192.168.5.101 is unknown
In case the server is reachable:
Trying 192.168.5.100...
Connected to 192.168.5.100.
Escape character is '^]'.
--- Unauthorised access prohibited ---
This is a closed-access system. If you do not have permission
to access this system, then log off now. If you remain logged on
you consent to monitoring of your actions.
z1 login: Success
So I would like to store into log ONLY the message sent by expect script, like in the above example "System 192.168.5.101 is unknown"
How can I do this?
Thank you
Lucas
expect utility has proc named log_file to record the logs.
In man expect:
log_file [args] [[-a] file]
If a filename is provided, log_file will record a transcript of the session (beginning at that point) in the file. log_file will stop recording if no argument is given. Any previous log file is
closed.
Instead of a filename, a Tcl file identifier may be provided by using the -open or -leaveopen flags. This is similar to the spawn command. (See spawn for more info.)
The -a flag forces output to be logged that was suppressed by the log_user command.
By default, the log_file command appends to old files rather than truncating them, for the convenience of being able to turn logging off and on multiple times in one session. To truncate files,
use the -noappend flag.
The -info flag causes log_file to return a description of the most recent non-info arguments given.`
You can just use like this:
#!/usr/bin/expect
set IP 192.168.5.100
catch {spawn -noecho telnet $IP}
set timeout 3
log_file your_log_file.log
---
---
---
If your script is executed by entering
./yourscript
then you can use something like the following pipe:
./yourscript | sed -n '/^System.*is unknown$/p' > logfile
if [[ $(dspmq | grep '(Running)' | grep "$QMgr" | wc -l | tr -d " ") != 1 ]]
The above code is to check if queue manager is running or not.
Is there any command to check whether the given queue name is exists in the queue manager or not?
Adding another suggestion in addition to what Rob and T.Rob have said.
MQ v7.1 and higher come with the dmpmqcfg command and you can use this to check for a specific queue.
The examples below are in line with your sample that checks if a queue manager is running:
To use dmpmqcfg to check if a queue name of any type exists you could do this:
if dmpmqcfg -m ${QMgr} -t queue -x object -o 1line -n ${QName}|egrep '^DEFINE '; then
echo "Queue ${QName} exists on Queue Manager ${QMgr}
fi
Using the method Rob Parker provided* to check if a queue name of any type exists:
*Note I used DISPLAY Q( instead of DISPLAY QLOCAL(
if printf "DISPLAY Q(${QName})" | runmqsc ${QMgr} 2>&1 >/dev/null; then
echo "Queue ${QName} exists on Queue Manager ${QMgr}
fi
Your example check for a queue manager Running could be simplified to this:
if dspmq -m ${QMgr}| grep --quiet '(Running)'; then
echo "Queue Manager ${QMgr} is Running"
fi
There's not a specific command but you could use:
printf "DISPLAY QLOCAL(<QUEUE NAME>)" | runmqsc <QM Name>
You will get a Return Code of 10 if it does not exist and 0 if it does. One thing to note, the Queue Manager must be running and you must run the command as someone who has access to the Queue Manager in question otherwise you'll get different return codes! (20 for Queue Manager not running and not authorized)
Given you haven't specified a specific Queue type i've assumed you're looking for QLocal's but you could search on any Queue Type by modifying the above command.
In addition to what Rob said, the way to do this programmatically is to attempt to open the queue. If the queue exists you get either RC=0 or RC=2 with a Reason Code of 2035 MQRC_NOT_AUTHORIZED. If the queue does not exist you get back RC=2 with a Reason Code of 2085 MQRC_UNKNOWN_OBJECT_NAME.
In the event someone else has that queue open for exclusive input you can't open it for input without getting an error, but at least the error tells you the queue exists. To work around that open the queue for inquiry if all you need is to know it exists. That also lets you discover other attributes about it with the API's inquiry options.
Finally, if you have access to the Command Queue, you can drop a PCF command on it that is equivalent to DIS Q(<QUEUE NAME>) that Rob mentioned. In general, business applications do not need access to the Command Queue but then again business applications do not normally need to inquire as to whether their queue exists or not. That's an administrative function and the app either finds its queue or throws a fatal error. As an MQ Admin I would question any business application that asked for rights to use runmqsc or that inquired as to whether its queue was there, its channels were up, etc. Most shops I've worked at would not let a business app into Production with that design or privileges.
On the other hand, instrumentation applications routinely need to be able to inquire on things like queue inventory so would be expected to have access to and use the Command Queue for that function, or have access to runmqsc to inquire from scripts.
Ive got a script that checks if a process is running or not, using ps -ef and some grep. If the process is running, it does nothing. If the process isnt running, it restarts the process, and then sends an email to me stating that the process died.
This script currently runs ever 5 minutes from a admin account's crontab.
Peusdocode + problem code:
#!/bin/sh
# declare a ton of environment variables.
ATONOFVARS=/lots/of/qualified/paths
# declare relevant logging functions
loggingFunction()
# declare failure message to pass into mail (real code)
PAGEMESSAGE="MyServer: process not found in ps -ef. Attempting to Restart... Please check log file in /tmp"
PAGESUBJECT="ProcessHealthCheck.sh - MyServer: process not found in ps -ef"
EMAILLIST="my.email#mycorp.com"
# do the actual check (back to peusdo code)
if [ $(ps -ef | grep process | grep adminAccount | grep -v grep | wc -1) ]
restartProcess()
FAILURE=1
fi
# log the failure and send an email to me (real code)
if [ $FAILURE -eq 1 ]
then
logMsg ""
logMsg "The process is not detected in ps -ef!"
logMsg "Restarting..."
logMsg ""
#send emails out
echo $PAGEMESSAGE | mail -s $PAGESUBJECT $EMAILLIST
fi
To test this, I deliberately killed the PID of my process I want monitored, so this cronjob would have to restart it, I also wanted to test the email capability. The script restarts my process exactly like I want it, and I get the email.
However the email says in the message body: "MyServer: process not found in
the entire listing of ps -ef. Attempting to Restart... Please check log file in /tmp". Also, the addresses that the email was sent to, are lines from ps -ef as well. As in my email had 2000 recipients. Sample addresses: grep#myServer.mydomain.com, process#myServer.mydomain.com
Does anyone know whats going on? Why is mail executing a command that is in a string? Since finding this out, I have changed the string to remove any possibility of a unix command.