You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.8 KiB

#/bin/bash
#功能函数
mem(){
mem_total=`free -m |awk NR==2'{print $2}'`
mem_used=`free -m |awk NR==2'{print $3}'`
mem_free=`free -m |awk NR==2'{print $4}'`
mem_cache=`free -m |awk NR==2'{print $6}'`
mem_s=$((${mem_used}*100/${mem_total}))
mem_f=$((100-$mem_s))
echo "内存的使用率: $mem_s"
echo "内存的总量: $mem_total"
echo "内存的空闲率: $mem_f"
echo "内存的缓存量: $mem_cache"
echo "内存的空闲量: $mem_free"
}
disk(){
read -p "请输入分区名称:" name
case $name in
"/")
echo `df -Th | awk NR==2'{print "总量:"$3,"使用:"$4,"空闲:"$5}'`
;;
"/boot")
echo `df -Th | awk NR==7'{print "总量:"$3,"使用:"$4,"空闲:"$5}'`
;;
esac
}
system_info(){
cat /etc/redhat-release | awk '{print "系统版本号:"$4}'
echo "内核版本为:`uname -r`"
ip a | grep "2:" | awk -F: '{print "网卡名称:"$2}'
ip a | grep "cope global" | awk '{print $2}' |awk -F "/" '{print "IP地址是:"$1}'
}
cpu_info(){
w | awk -F: NR==1'{print "CPU的平均负载:"$NF}'
vmstat | awk NR==3'{print "CPU空闲率:"$(NF-2)}'
cpu_id=`vmstat | awk NR==3'{print $(NF-2)}'`
cpu_free=$((100-$cpu_id))
echo "CPU使用率: $cpu_free"
}
install_yum(){
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
yum clean all &>/dev/null
yum makecache fast &>/dev/nul
}
stop_firewalld(){
systemctl stop firewalld && systemctl disable firewalld &>/dev/null
setenforce 0 &>/dev/null
sed -i '/^SELINUX/c SELINUX=disabled' /etc/selinux/config
}
list(){
cat <<EOF
a: 内存使用情况
b: 磁盘使用情况
c: 服务器信息
d: CPU使用情况
e: YUM源更换
f: 关闭防火墙
q: 退出
EOF
}