1. #!/bin/bash
    2. resourceManager=cm1
    3. jobId=$1
    4. firstLineNumber=128
    5. afterLineNumber=6
    6. rename=true
    7. `curl http://${resourceManager}:19888/jobhistory/attempts/${jobId}/m/SUCCESSFUL > a.xml`
    8. urls=`cat a.xml | grep container | awk -F"'" '{print $10}'`
    9. if [ ! -d ./${jobId}_logs ];then
    10. mkdir ${jobId}_logs
    11. fi
    12. for url in ${urls[@]};do
    13. #echo $url
    14. mapName=`echo ${url} | awk -F'/' '{print $5}'`
    15. #echo $mapName
    16. echo "curl http://${resourceManager}:19888${url}/syslog/?start=0 > ${jobId}_logs/${mapName}.log"
    17. (curl http://${resourceManager}:19888${url}/syslog/?start=0 > ${jobId}_logs/${mapName}.log)
    18. (sed -i "1,${firstLineNumber}d" ${jobId}_logs/${mapName}.log)
    19. lines=`cat ${jobId}_logs/${mapName}.log | wc -l`
    20. tmp=`expr $lines - $afterLineNumber`
    21. afterDelNum=`expr $tmp - 1`
    22. (sed -i "${afterDelNum},${lines}d" ${jobId}_logs/${mapName}.log)
    23. done
    24. if [ "$rename" = true ];then
    25. newFileName=$2
    26. (mv ${jobId}_logs ${newFileName}_logs)
    27. (zip -r ${newFileName}_logs.zip ${newFileName}_logs)
    28. else
    29. (zip -r ${jobId}_logs.zip ${jobId}_logs)
    30. fi
    31. (rm -rf a.xml)
    1. #!/bin/bash
    2. ids=$(cat jobIDs.txt)
    3. id_list=(${ids})
    4. names=$(cat jobNames.txt)
    5. name_list=(${names})
    6. len=`expr ${#id_list[@]} - 1`
    7. for i in `seq 0 $len`;do
    8. echo "sh getJobHistoryLogs.sh ${id_list[$i]} ${name_list[$i]}"
    9. (sh getJobHistoryLogs.sh ${id_list[$i]} ${name_list[$i]})
    10. done

    job_1642669840858_58970 job_1642669840858_58984 job_1642669840858_58979 job_1642669840858_58985 job_1642669840858_58964 job_1642669840858_58793 job_1642669840858_58977 job_1642669840858_58965 job_1642669840858_58795 job_1642669840858_58976

    snapshotScanMR-NSSFCJSFW_BAK snapshotScanMR-XSDQ_BAK snapshotScanMR-QSFCJSFW_BAK snapshotScanMR-XSFCJSFW_BAK snapshotScanMR-MHSDQ_BAK snapshotScanMR-NSSFJ_BAK snapshotScanMR-PLSJ3_BAK snapshotScanMR-MHSFCJSFW_BAK snapshotScanMR-MHSFJ_BAK snapshotScanMR-PLSJ2_BAK

    开启yarn日志聚合功能的日志收集

    1. #!/bin/bash
    2. outPath=logs
    3. if [ ! -d logs ];then
    4. (mkdir logs)
    5. fi
    6. ids=$(cat jobIds.txt)
    7. id_list=(${ids})
    8. names=$(cat jobNames.txt)
    9. name_list=(${names})
    10. len=`expr ${#id_list[@]} - 1`
    11. for i in `seq 0 $len`;do
    12. jobId1=`echo ${id_list[$i]} | awk -F'_' '{print $2}'`
    13. jobId2=`echo ${id_list[$i]} | awk -F'_' '{print $3}'`
    14. echo "yarn logs -applicationId application_${jobId1}_${jobId2} > logs/${name_list[$i]}.log"
    15. (yarn logs -applicationId application_${jobId1}_${jobId2} > logs/${name_list[$i]}.log)
    16. done