1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/bin/sh GetHostList() { curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE/components/$1 2>/dev/null |grep host_name|awk -F: '{print $2}'|sed 's/"//g' >> temp_host_list } GetServiceComponent() { curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE 2>/dev/null | grep "component_name" > ./temp_component_list sed -i 's/"//g' ./temp_component_list sed -i 's/,//g' ./temp_component_list } if [ $# != 4 ]; then echo "Usage: $0 Ambari_Server Cluster_Name Service_Name Package_Name" exit 1 fi AMBARI_HOST=$1 CLUSTER=$2 SERVICE=$3 PACKAGE=$4 GetServiceComponent cat ./temp_component_list|while read line do COMPONENT=`echo $line|awk -F: '{print $2}'` GetHostList $COMPONENT done curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE rm -f ./temp_component_list >/dev/null 2>&1 #delete duplicated lines (duplicated host name) hosts=`cat temp_host_list|sort |uniq` for host in $hosts do ssh $host "yum erase $PACKAGE" done rm -f temp_host_list >/dev/null 2>&1 |
1 | NAME_SERVICE_CHCECK |
1 2 3 4 | curl -u admin:admin -H "X-Requested-By: ambari" -X POST -d ' {"RequestInfo":{"context":"My YARN Service Check", "command": "YARN_SERVICE_CHECK"},"Requests/resource_filters":[{"service_name":"YARN"}]}' http://zwshen86:8080/api/v1/clusters/bigdata/requests |
1 2 3 4 5 | curl -u admin:admin -H "X-Requested-By: ambari" -X POST -d ' {"RequestInfo":{"context":"Get RM host Mem Usage","command":"GetMem"},"Requests/resource_filters":[{"service_name": "YARN","component_name":"RESOURCEMANAGER","hosts":"zwshen86.eng.platformlab.ibm.com"}]}' http://zwshen86:8080/api/v1/clusters/bigdata/requests |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |