From dc10fe7c62ba805f0f4be18abc9ebcd9732fdf3b Mon Sep 17 00:00:00 2001 From: diandian Date: Fri, 21 Apr 2023 10:18:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'Shell-MD'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shell-MD/O.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ Shell-MD/P.sh | 30 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 Shell-MD/O.sh create mode 100644 Shell-MD/P.sh diff --git a/Shell-MD/O.sh b/Shell-MD/O.sh new file mode 100644 index 0000000..fcfa307 --- /dev/null +++ b/Shell-MD/O.sh @@ -0,0 +1,71 @@ +#/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 <