码迷,mamicode.com
首页 > 编程语言 > 详细

linux服务器巡检性能与Java 进程脚本

时间:2020-07-22 21:05:02      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:storm   solr   stat   wan   服务   linux服务器   jps   swap   swap空间   

#!/bin/bash
#作者:洪永坚
echo -e "\033[31m211服务器时间: \033[0m"
date +%F" "%H:%M #获取脚本执行的时间
echo -e "\033[31m服务器ip地址: \033[0m"
ifconfig eno1 | awk ‘/inet/‘ | awk ‘{print $2}‘#获取IP
#检查CPU状态
hong=$(vmstat | awk ‘NR==3{print $15}‘)
yong=$(vmstat | awk ‘NR==3{print $14}‘)
jian=$(vmstat | awk ‘NR==3{print $13}‘)
echo -e "\033[31mCPU情况 :CPU空闲:${hong} 内核空间:${yong} 用户空间:${jian}\033[0m"
for i in $honc
do
if [ $i -lt 10 ]; then
echo -e "\033[35m CPU空间不足 10% 请检查 \033[0m"
fi
done
#检查free空间状态
h=$(free -h |awk ‘/Mem:/‘|awk ‘NR==1{print $4}‘)
y=$(free -h |awk ‘/Mem:/‘|awk ‘NR==1{print $6}‘)
j=$(free -h |awk ‘/Mem:/‘|awk ‘NR==1{print $7}‘)
hong=$(free -h |awk ‘/Mem:/‘|awk ‘NR==1{print $4}‘|cut -d G -f 1)
echo -e "\033[33mfree -h Mem: free内存:${h} 缓存内存:${y} available内存:${j}\033[0m"
for i in $honr
do
if [ $i -lt 10 ]; then
echo -e "\033[35m free空间不足 10G 请检查 \033[0m"
fi
done
#检查swap交换空间状态
hon=$(free -h |awk ‘/Swap:/‘|awk ‘NR==1{print $2}‘)
yon=$(free -h |awk ‘/Swap:/‘|awk ‘NR==1{print $3}‘)
jia=$(free -h |awk ‘/Swap:/‘|awk ‘NR==1{print $4}‘)
wang=$(free -h |awk ‘/Swap:/‘|awk ‘NR==1{print $4}‘|cut -d G -f 1)
echo -e "\033[33mfree -h swap:总内存:${hon} 已用内存:${yon} free内存:${jia}\033[0m"
for i in $wanr
do
if [ $i -lt 2 ]; then
echo " swap空间不足 2G 请检查 "
fi
done

echo -e "\033[34m服务器重要进程:\033[0m"
echo -e "\033[36mhbase进程:\033[0m"
jps -l |grep hbase
mei=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $mei
do
if [ $i -gt 0 ]; then
echo -e "\033[35m>>>>no hbase,进程挂了,请注意!... \033[0m"
fi
done

echo -e "\033[31mMpp进程(2个):\033[0m"
jps -l |grep MppService_232
wan=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wan
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no MppService_232,进程挂了,请注意!...\033[0m"
fi
done

jps -l |grep MppService-0
wah=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wah
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no MppService,进程挂了,请注意!...\033[0m"
fi
done

echo -e "\033[31mkafka的进程: \033[0m"
jps -l |grep kafka
waho=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $waho
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no kafka,进程挂了,请注意!...\033[0m"

fi
done
echo -e "\033[31mstorm进程:\033[0m"
jps -l |grep org.apache.storm.daemon.supervisor.Supervisor
wahon=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wahww
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no storm,进程挂了,请注意!...\033[0m"
fi
done
echo -e "\033[31mzookeeper进程:\033[0m"
jps -l |grep zookeeper
wahong=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wahop
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no zookeeper,进程挂了,请注意!...\033[0m"
fi
done
echo -e "\033[31mredis微服务进程:\033[0m"
jps -l |grep redis
wanhong=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wanhon
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no redis,进程挂了,请注意!...\033[0m"
fi
done
echo -e "\033[31mhadoop进程(3个):\033[0m"
jps -l |grep org.apache.hadoop.hdfs.server.datanode.DataNode
wangLhong=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wLhow
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no hdfs DataNode,进程挂了,请注意!...\033[0m"
fi
done
jps -l |grep org.apache.hadoop.yarn.server.nodemanager.NodeManager
wlh=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wlgwh
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no yarn NodeManagtr,进程挂了,请注意!...\033[0m"
fi
done
jps -l |grep org.apache.hadoop.hbase.regionserver.HRegionServer
wloh=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wloh
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no hbase HRegionServer,进程挂了,请注意!...\033[0m"
fi
done

echo -e "\033[31m硬盘空间使用情况:\033[0m"
df -Th
echo -e "\033[31m查看solr进程:\033[0m"
ps -ef |grep solr |grep /opt/java/jdk1.8.0_112/bin/java
jps -l|grep start.jar
wanghong=$(echo $?|awk ‘NR==1{print $1}‘)
for i in $wanghp
do
if [ $i -gt 0 ]; then
echo -e "\033[35m >>>>no solr,进程挂了,请注意!...\033[0m"
fi
done

linux服务器巡检性能与Java 进程脚本

标签:storm   solr   stat   wan   服务   linux服务器   jps   swap   swap空间   

原文地址:https://blog.51cto.com/14861926/2512629

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!