【Hadoop】大数据组件进行监控脚本

用linux shell对HDP(ambari)部署的大数据服务进程进行监控

检查进程脚本

#配置需要检查的进程,请以逗号隔开
process="NameNode,DFSZKFailoverController" 

#检查进程脚本
status=`jps`
arr=(${process//,/ }) 
index=0
while (( $index<${#arr[@]} ))
do
      if (echo $status | grep -q "${arr[index]}");
then
echo "${arr[index]} 进程存在"
      let "index++"
     elif(echo ${arr[index]} | grep -q "NameNode")
     then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hadoop/sbin/hadoop-daemon.sh start namenode
     let "index++"
     elif(echo ${arr[index]} | grep -q "DataNode")
     then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hadoop/sbin/hadoop-daemon.sh start datanode
   let "index++"
      elif(echo ${arr[index]} | grep -q "DFSZKFailoverController")
      then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hadoop/sbin/hadoop-daemon.sh start zkfc
   let "index++"
         elif(echo ${arr[index]} | grep -q "JournalNode")
      then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hadoop/sbin/hadoop-daemon.sh start journalnode
   let "index++"
            elif(echo ${arr[index]} | grep -q "HMaster")
      then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hbase/bin/hbase-daemon.sh start master
   let "index++"
               elif(echo ${arr[index]} | grep -q "HRegionServer")
      then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hbase/bin/hbase-daemon.sh start regionserver
   let "index++"
   
   elif(echo ${arr[index]} | grep -q "ThriftServer")
      then
     echo "${arr[index]} 进程不存在" 
     /usr/hdp/2.2.0.0-2041/hbase/bin/hbase-daemon.sh start thrift2
   let "index++"
    elif(echo ${arr[index]} | grep -q "QuorumPeerMain")
      then
     echo "${arr[index]} 进程不存在" 
    /usr/hdp/2.2.0.0-2041/zookeeper/bin/zkServer.sh start
   let "index++"
   
      else  
        echo "请检查下进程配置是否有问题"
        let "index++"
fi
done
        

你可能感兴趣的:(大数据,hadoop)