#!/bin/sh ip=xxx port=8088 export HADOOP_HOME=xxx rmstate1=$($HADOOP_HOME/yarn rmadmin -getServiceState rm1) rmstate2=$($HADOOP_HOME/yarn rmadmin -getServiceState rm2) if [[ $rmstate1 == *active* ]] then ip=xxx fi cd /home/yarn/queuecheck curl http://$ip:$port/ws/v1/cluster/scheduler | jq . | sed 's/"//g' > cpu.json tail -n 32 cpu.json > ncpu.json cat ncpu.json | grep -i "vCores" | awk -F ": " '{print $2}' | awk -F "," '{print $1}' > vcores.txt usedvcores=$(sed -n "3 p" vcores.txt | awk '{print $1}') maxvcores=$(sed -n "2 p" vcores.txt | awk '{print $1}') vrate=$(printf "%.2f" `echo "scale=2;$usedvcores/$maxvcores"|bc`) echo "当前已使用vcores个数:"$usedvcores echo "当前共分配vcores个数:"$maxvcores echo "当前使用率:"$vrate
#curl http://xxx:50070/jmx?qry=Hadoop:service=NameNode,name=RpcActivityForPort8020
#curl http://xxx:8088/jmx?qry=Hadoop:service=ResourceManager,name=QueueMetrics,q0=root
#!/bin/sh ip=xxx port=8088 export HADOOP_HOME=/app/hadoop/bin rmstate1=$($HADOOP_HOME/yarn rmadmin -getServiceState rm1) rmstate2=$($HADOOP_HOME/yarn rmadmin -getServiceState rm2) if [[ $rmstate1 == *active* ]] then ip=xxx fi cd /home/yarn/queuecheck curl http://$ip:$port/ws/v1/cluster/scheduler | jq . | sed 's/"//g' > mem.json tail -n 32 mem.json > nmem.json cat nmem.json | grep -i "memory" | awk -F ": " '{print $2}' | awk -F "," '{print $1}' > mem.txt usedmem=$(sed -n "3 p" mem.txt | awk '{print $1/1024/1024}') maxmem=$(sed -n "2 p" mem.txt | awk '{print $1/1024/1024}') mrate=$(printf "%.2f" `echo "scale=2;$usedmem/$maxmem"|bc`) echo "当前已使用内存(TB):"$usedmem echo "当前共分配内存(TB):"$maxmem echo "当前使用率:"$mrate