此篇文章脚本功能主要是打印系统配置信息,有需要的朋友可以参考下。
[root@localhost ~]# vim auto_print_system_info.sh文章源自小柒网-https://www.yangxingzhen.cn/1603.html
脚本内容如下:文章源自小柒网-https://www.yangxingzhen.cn/1603.html
#!/bin/bash
#2018-5-20 13:14:00
#Author blog:
#https://www.yangxingzhen.cn
#Author site:
#https://www.yangxingzhen.cn/sitemap.html
#Author mirrors site:
#https://mirrors.yangxingzhen.com
#About the Author
#BY:、、、小柒
#QQ:675583110
#Auto Print System Info
SYS_VERSION=$(cat /etc/redhat-release)
HOSTNAME=$(hostname)
Public_IP=$(curl -s icanhazip.com 2>/dev/null)
IPADDR=$(hostname -I)
CPU_Model=$(awk -F: '/name/ {print $NF}' /proc/cpuinfo |uniq)
CPU_NUM=$(grep -c 'processor' /proc/cpuinfo)
DISK_INFO=$(df -h |grep "^/dev/"|awk '{print "|磁盘容量:",$1,$2}')
DISK_Avail=$(df -h |grep "^/dev/"|awk '{print "|磁盘可用容量:",$1,$4}')
MEM_INFO=$(free -m |awk '/Mem/ {print "内存容量:",$2"M"}')
MEM_Avail=$(free -m |awk '/Mem/ {print "|内存可用容量:",$7"M"}')
LOAD_INFO=$(uptime |awk '{print "CPU负载: "$(NF-2),$(NF-1),$NF}'|sed 's/\,//g')
Uptime_day=$(uptime |awk '{print $3,$4}')
Uptime=$(uptime -p |awk '{print $6,$7,$8,$9}')
echo -e "\033[32m+---------------------------------------------------+\033[0m"
echo -e "\033[32m|系统信息>> |\033[0m"
echo -e "\033[32m|系统运行时间:${Uptime_day}${Uptime} |\033[0m"
echo -e "\033[32m|操作系统: ${SYS_VERSION} |\033[0m"
echo -e "\033[32m|主机名: ${HOSTNAME} |\033[0m"
echo -e "\033[32m|公网IP: ${Public_IP} |\033[0m"
echo -e "\033[32m|内网IP: ${IPADDR} |\033[0m"
echo -e "\033[32m|CPU型号:${CPU_Model} |\033[0m"
echo -e "\033[32m|CPU核数: ${CPU_NUM} |\033[0m"
echo -e "\033[32m${DISK_INFO} |\033[0m"
echo -e "\033[32m${DISK_Avail} |\033[0m"
echo -e "\033[32m|${MEM_INFO} |\033[0m"
echo -e "\033[32m${MEM_Avail} |\033[0m"
echo -e "\033[32m|${LOAD_INFO} |\033[0m"
echo -e "\033[32m+---------------------------------------------------+\033[0m"
#保存退出,传到服务器即可使用。文章源自小柒网-https://www.yangxingzhen.cn/1603.html
效果展示文章源自小柒网-https://www.yangxingzhen.cn/1603.html
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
继续阅读
Wechat
微信扫一扫,加我!
![weinxin](https://www.yangxingzhen.com/images/weixin.jpg)
我的微信
微信公众号
微信扫一扫,关注我!
![weinxin](https://www.yangxingzhen.com/images/weixingongzhonghao.png)
我的公众号
亲测,写的不错,感谢博主![:razz:](https://www.yangxingzhen.cn/wp-content/themes/begin/img/smilies/icon_razz.gif)
我是一楼么 踩一脚 jf2116