If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DPF shell script question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-17-11, 02:41
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
DPF shell script question

DB2 DPF
Linux
V 9.1


Hi,
I am trying to do a "df -h" on all the nodes in the cluster. I am running this script from the admin node.

cat ~/sqllib/db2nodes.cfg | awk '{print $2}'| uniq | while read nodename
do ssh $nodename "df -h" | grep -i % | cut -c 22- | awk '{print $5}' | grep -iE 'db2backups|db2containers|db2logs'
done


db2nodes.cfg has 3 nodes: adm, node1 and node2.

My above command is only displaying the df -h output of adm node and its not displaying the df -h outputs of node1 and node2.

If anyone could help in throwing a suggestion in this regard would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old 02-17-11, 03:42
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Hi,

the script seem to be ok.

Did you check
cat ~/sqllib/db2nodes.cfg | awk '{print $2}'| uniq | while read nodename
do ssh $nodename "df -h"
done

Is the ssh generating the output for the other nodes? Are there keys for login and are host in the known_hosts?

Cheers
nvk
Reply With Quote
  #3 (permalink)  
Old 02-17-11, 08:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Why don't you use rah, the script that is supplied with DB2 exactly for this purpose?
Reply With Quote
  #4 (permalink)  
Old 02-17-11, 20:51
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
--> nvk@vhv : There is no issue with ssh. When I try to execute the script mentioned by you, It generates df -h out put of only one node

But when I do,

cat ~/sqllib/db2nodes.cfg | awk '{print $2}'| uniq | while read nodename
do echo $nodename
done

The above one generates all the three nodenames. I am not sure why ssh on all the three nodes is not working for while loop

I modified while loop to for loop and then ssh started working on three nodes

What I did was

cat ~/sqllib/db2nodes.cfg | awk '{print $2}'| uniq > nodefile.out
for nodename in `cat nodefile.out`
do ssh $nodename "df -h" | grep -i % | cut -c 22- | awk '{print $5}' | grep -iE 'db2backups|db2containers|db2logs'
done

The above script works perfectly

Last edited by blazer789; 02-17-11 at 21:07.
Reply With Quote
  #5 (permalink)  
Old 02-17-11, 20:58
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
--> n_i

Can we use rah to a specific node ? The reason why I am using ssh instead of rah is because, after doing ssh on each node, it generates an output specific to that node

This is what I am trying to do. If the particular file is not readable on that node, the output should say that the file is not readable on that specific node.

If you could suggest me a way how this could be accomplished through rsh, it would be really great.


cat ~/sqllib/db2nodes.cfg | awk '{print $2}'| uniq > nodefile.out
for nodename in `cat nodefile.out`
do ssh $nodename "df -h" | grep -i % | cut -c 22- | awk '{print $5}' | grep -iE 'db2backups|db2containers|db2logs' > filename_output
for filename in `cat filename_output`
do ssh "ls -ld $filename" | awk '{print $1}' | cut -c2 | while read var
if [[ $var -eq r ]]
then echo "$filename on $nodename is readable"
else
echo "$filename on $nodename is not readable"
fi
done
done

Last edited by blazer789; 02-17-11 at 21:09.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On