Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2009
    Posts
    272

    Unanswered: 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.

  2. #2
    Join Date
    Jan 2010
    Posts
    335
    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

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Why don't you use rah, the script that is supplied with DB2 exactly for this purpose?

  4. #4
    Join Date
    Jun 2009
    Posts
    272
    --> 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 22:07.

  5. #5
    Join Date
    Jun 2009
    Posts
    272
    --> 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 22:09.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •