| Author | 
		  Message
		 | 
		
		  | sebastia | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 5:02 am    Post subject: need MB script help on linux | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
			  
				Hi, cloeagues.
 
I am trying to write a script to display some MB interesting info.
 
The platform is AIX but Linux shall be ok.
 
 
The code I have written is
 
 
   
	| Code: | 
   
  
	me@p9111-520:~/cmds> cat ./mostra_MB_all.sh
 
#!/bin/bash
 
# Get broker name and broker queue manager name
 
# sample : BIP1284I: Broker 'BKP9111' on queue manager 'P9111' is running.
 
 
echo ">>> Get broker name"
 
mqsilist | grep BIP1284I    | while read msgid a broker b c d brokerqm other2
 
 
do
 
  echo "Processing broker $broker with QM $brokerqm"
 
  # Get each execution group name
 
  # sample : BIP1286I: Execution group 'EG_cat_A' on broker 'BKP9111' is running.
 
 
  echo ">>> 0 Get execution group name for broker ($broker)"
 
  mqsilist $broker
 
 | 
   
 
 
 
And the problem comes with some strange chars I get :
 
 
   
	| Code: | 
   
  
	me@p9111-520:~/cmds> bash -x ./mostra_MB_all.sh
 
+ echo '>>> Get broker name'
 
>>> Get broker name
 
+ mqsilist
 
+ grep BIP1284I
 
+ read msgid a broker b c d brokerqm other2
 
+ echo 'Processing broker '\''BKP9111'\'' with QM '\''P9111'\'''
 
Processing broker 'BKP9111' with QM 'P9111'
 
 
+ echo '>>> 0 Get execution group name for broker ('\''BKP9111'\'')'
 
>>> 0 Get execution group name for broker ('BKP9111')
 
+ mqsilist ''\''BKP9111'\'''
 
BIP8013E: Component does not exist.
 
 | 
   
 
 
 
I think the problem comes from the "\" in front and after the name,
 
but I dont know how to remove them
 
 
Would somebody be kind enough to teach me a bit of script tricks ?
 
Thanks. Sebastian.
 
 
PD.- what I want to do at the very end is ... (pseudo code)
 
 
for all the brokers in the machine ... {mqsilist}
 
   get Execution Group name
 
   for every Execution Group ... {mqsireportproperties}
 
      get JVM Heap min and max size
 
 
Bye ! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | JosephGramig | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 5:19 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 09 Feb 2006 Posts: 1244 Location: Gold Coast of Florida, USA 
  | 
		  
		    
			  
				| Please consider using the Java CMP API to do the job. I think you will eventually find it easier and more flexible. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 5:38 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sebastia | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 5:57 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
			  
				
   
	| JosephGramig wrote: | 
   
  
	| Please consider using the Java CMP API to do the job. I think you will eventually find it easier and more flexible. | 
   
 
 
 
Well, I remember "CM" standed for Cfg Mgr, so I thought it was not used anymore ...
 
 
jejeje
 
 
again, I am wrong
 
 
Thanks for the pointer ! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 6:38 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				| It's now the broker APi or the Admin API depending on which level you're at. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sebastia | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 7:10 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
			  
				OK, the API is OK, but ... why not to use tools provided by shell ?
 
 
I am sure some "cut" or "sed" strings are missing ...
 
 
( ) | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Oct 01, 2013 7:26 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				The \ isn't what you're getting.
 
 
What you're getting is \', which is an escaped single-quote.
 
 
Yes, some kind of regular expression is the right choice to resolve this.
 
 
http://perldoc.perl.org/perlre.html | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mapa | 
		  
		    
			  
				 Posted: Wed Oct 02, 2013 8:43 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Master
 
 Joined: 09 Aug 2001 Posts: 257 Location: Malmö, Sweden 
  | 
		  
		    
			  
				Hi, had some old stuff laying around that we used for WMB6 that is related, here is some part of it that I just modified to make it work on a WMB7 AIX (verified).
 
 
   
	| Code: | 
   
  
	
 
BROKER=`mqsilist -d 0 | tr - : | tr -d ' ' | cut -d: -f3`
 
QMGR=`mqsilist -d 0 | tr - : | tr -d ' ' | cut -d: -f4`
 
echo $BROKER $QMGR      
 
 
#List EGs            
 
for eg in `mqsilist $BROKER -d 0 | tr - : | tr -d ' ' | cut -d: -f3`; do echo $eg; done;
 
 
#List Msgflows in all Executiongroups
 
for eg in `mqsilist $BROKER -d 0 | tr - : | tr -d ' ' | cut -d: -f3`; do echo "Executiongroup: $eg"; mqsilist $BROKER -e $eg -d 0| grep -v "Successful" | sed "s/.*:/Msgflow:/1"; done;
 
 | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sebastia | 
		  
		    
			  
				 Posted: Thu Oct 03, 2013 2:23 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sebastia | 
		  
		    
			  
				 Posted: Thu Oct 03, 2013 2:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
			  
				
   
	| mapa wrote: | 
   
  
	Hi, had some old stuff laying around that we used for WMB6 that is related, here is some part of it that I just modified to make it work on a WMB7 AIX (verified).
 
 
   
	| Code: | 
   
  
	
 
BROKER=`mqsilist -d 0 | tr - : | tr -d ' ' | cut -d: -f3`
 
QMGR=`mqsilist -d 0 | tr - : | tr -d ' ' | cut -d: -f4`
 
echo $BROKER $QMGR      
 
 
#List EGs            
 
for eg in `mqsilist $BROKER -d 0 | tr - : | tr -d ' ' | cut -d: -f3`; do echo $eg; done;
 
 
#List Msgflows in all Executiongroups
 
for eg in `mqsilist $BROKER -d 0 | tr - : | tr -d ' ' | cut -d: -f3`; do echo "Executiongroup: $eg"; mqsilist $BROKER -e $eg -d 0| grep -v "Successful" | sed "s/.*:/Msgflow:/1"; done;
 
 | 
   
 
 | 
   
 
 
 
mr MAPA : I like the simplicity of your code.
 
Works perfect on Linux SLES10.
 
Shall try to insert it in a loop (for all brokers in the machine).
 
 
Thanks a lot | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | sebastia | 
		  
		    
			  
				 Posted: Thu Oct 03, 2013 4:56 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 07 Oct 2004 Posts: 1003
  
  | 
		  
		    
			  
				Well, here is a working code (SLES 10)
 
 
   
	| Code: | 
   
  
	#!/bin/bash
 
echo ">>> Get broker names"
 
 
# BIP1284I: Broker 'BKP9111' on queue manager 'P9111' is running
 
mqsilist | grep BIP1284I | sed -e "s/'/ /g" | while read -r msgid a BROKER b c d brokerqm e
 
do
 
  echo "Processing broker ($BROKER) with QM ($brokerqm)"
 
 
# BIP1286I: Execution group  EG_A  on broker  BKP9111  is running.
 
  mqsilist $BROKER | grep BIP1286I | sed -e "s/'/ /g" | while read -r msgidi2 a b EGN c d BKNM e
 
  do
 
    echo "Processing eg ($EGN) in broker ($BKNM)"
 
 
# BIP1288I: Message flow 'mfP9111' on execution group 'EG_A' is running.
 
    mqsilist $BROKER  -e $EGN | grep BIP1288I | sed -e "s/'/ /g" | while read -r msgid3 a b MFNM c d e EGNM f
 
    do
 
      echo "Have msg flow ($MFNM) in eg ($EGNM)"
 
    done
 
  done
 
done | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |