Changeset 174


Ignore:
Timestamp:
Jun 10, 2010, 11:52:51 AM (15 years ago)
Author:
rock
Message:

新增功能 1.叢集狀態檢視 2.增加註解文字

Location:
nutchez-0.2/src/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nutchez-0.2/src/test/add_hosts

    r172 r174  
    22# Program:
    33#   Add nutch_nodes to /etc/hosts (for nutchez management interface).
    4 #   $1=/home/nutchuser/nutch_nodes
     4#   $1=/home/nutchuser/nutchez/system/nutch_nodes
    55#   $2=/etc/hosts
    66# Author:
     
    3838done
    3939
    40 # 附加 nutch_nodes 到 /etc/hosts
    41 cp -f /etc/hosts /etc/hosts.bak
    42 cat $1 | grep -v '#' >> $2
     40# Backup /etc/hosts
     41cp -f "$2" "$2.bak"
     42
     43# attache nutch_nodes to hosts
     44sed -i '/# NutchEz add/d' $2
     45echo "# NutchEz add" >>$2
     46cat $1 | grep -v '#' >>$2
     47
  • nutchez-0.2/src/test/duplicate_del

    r172 r174  
    1313
    1414# 刪掉空白行
    15 sed -i '/^$/d' $1
     15#sed -i '/^$/d' "$1"
    1616
    1717cp -f "$1" "${1}.old"
  • nutchez-0.2/src/test/nutchez

    r172 r174  
    6464$DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" \
    6565    --title "[Management Options]" \
    66         --menu "Plz choose: " 15 55 5 \
     66        --menu "Plz choose: " 15 55 6 \
     67        "cluster_status" "Check cluster status" \
    6768        "cluster_setup" "Setup your datanode & tasktracker" \
    6869        "tomcat_switch" "Start/Stop/Restart Tomcat" \
     
    7071        "lang_switch" "Change language" \
    7172        "exit" "Exit" 2>$main_choice
     73}
     74
     75## [Cluster Status (datanode & tasktracker)] ##
     76function cluster_status(){
     77IP_list=$(cat $NutchEZ_HOME/system/nutch_nodes | grep -v '^$' | grep -v '#'  | awk '{print $1}')
     78clusterStatus="/tmp/clusterStatus"
     79rm $clusterStatus 2> /dev/null
     80#printf '%16s\t %11s\t %10s\t %25s\n' "[IP] [Hostanme] [Network] [Dtatnode & Tasktracker]" >>$clusterStatus
     81echo -e "[IP] \t\t [Hostanme] \t [Network] \t [Dtatnode & Tasktracker]" >>$clusterStatus
     82echo -e "------------------------------------------------------------------------" >>$clusterStatus
     83echo -e "\nStart to check cluster..."
     84for ip in $IP_list
     85do
     86    # Check Network status
     87    ip_status="online"
     88    ping -c1 -w1 $ip 2>&1 > /dev/null || ip_status="offline"
     89    # Check Hadoop/Nutch service through ssh
     90    Task_Data_status="stop"
     91    if [ $ip_status == "online" ]; then
     92    Task_Data=$(ssh -o StrictHostKeyChecking=no $ip "jps |grep TaskTracker ; jps | grep  DataNode")
     93    fi
     94
     95#   if [ $? == "255" ]; then
     96#   echo -e "$ip Network is down"
     97#   elif [ $? == "1" ]; then
     98#   echo -e "Can't ssh to $ip"
     99#   fi
     100
     101    [ -z $Task_Data ] || Task_Data_status="running"
     102    host_name=$(cat $NutchEZ_HOME/system/nutch_nodes | grep $ip | awk '{print $2}')
     103    echo  -e "$ip  $host_name \t\t $ip_status \t $Task_Data_status" >>$clusterStatus
     104#    printf '%16s\t %11s\t %10s\t %25s\n' "$ip $host_name $ip_status $Task_Data_status" >>$clusterStatus
     105done
     106
     107read -p "Plz input anykey to continue..."
     108$DIALOG --clear --backtitle "= [NutchEz Management Interface] ~by NCHC =" \
     109     --title "[Cluster Status]" --textbox $clusterStatus 20 90
    72110}
    73111
     
    216254main_menu
    217255case $(cat $main_choice) in
     256    "cluster_status")
     257        cluster_status;;
    218258    "cluster_setup")
    219259        cluster_setup;;
Note: See TracChangeset for help on using the changeset viewer.