linux-shell系列5-统计

#!/bin/bash
show=$(service --status-all 2>/dev/null | grep -E "is running|正在运行"|awk '{print $1}'|grep -E "tingyun-agent-system|httpd|nginx|redis|*ftp*|php-fpm|mongod")
for i in $show
do
if [ $i == "nginx" ];then echo "$i 服务器web应用";fi
if [ $i = "redis-server" ];then echo "$i 服务器缓存应用";fi
if [ $i = "vsftpd" ];then echo "$i 服务器ftp应用";fi
if [ $i = "php-fpm" ];then echo "$i 服务器php应用";fi
if [ $i = "httpd" ];then echo "$i 服务器web应用";fi
if [ $i = "mongod" ];then echo "$i 服务器数据库应用";fi
if [ $i = "tingyun-agent-system" ];then echo "$i 听云探针应用";fi
done
ps=$(ps aux|grep mysqld|awk '{print $1}')
for i in $ps
do
if [ $i == "mysql" ];then echo "$i 服务器web应用";fi
done
sl=$(ps aux |grep -v grep|grep tomcat|grep solr|awk '{print $NF}')
[ ! -n $sl ] && echo "java 服务器java-solr应用"
fpm=$(ps aux |grep -v grep|grep php-fpm|awk '{print $1}'|sed -n '1p')
[ ! -n $fpm ] && echo "php-fpm 服务器web应用"
df -hP|sed -n '2p'|awk '{print "系统盘容量总计:"$2 " " "已使用容量:"$3}'
diskdata=$(df -TP | sed '1d' | awk '$2!="tmpfs"{print}')
disktotal=$(echo "$diskdata" | awk '{total+=$3}END{print total}')
diskused=$(echo "$diskdata" | awk '{total+=$4}END{print total}')
sysdata=$(df -TP | sed -n '2p' | awk '{print $3}')
sysused=$(df -TP | sed -n '2p' | awk '{print $4}')
datatotal=$((disktotal-sysdata))
dataused=$((diskused-$sysused))
echo "数据盘容量总计:$((datatotal/1024/1024))G 已使用容量:$((dataused/1024/1024))G"

上一篇:[UE4]瞬移前后屏幕亮度变化,Get Player Camera Manager.Start Camera Fade


下一篇:推荐:Java性能优化系列集锦