Linux打印系统配置信息脚本

2018-11-1309:29:04 2 2,025

此篇文章脚本功能主要是打印系统配置信息,有需要的朋友可以参考下。

[root@localhost ~]# vim auto_print_system_info.sh

脚本内容如下:

#!/bin/bash
#2018-5-20 13:14:00
#Author blog:
#https://www.yangxingzhen.com
#Author site:
#https://www.yangxingzhen.com/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`
IPADDR=`ifconfig |awk '/cast/ {print $2}'|sed 's/addr://'`
CPU_Model=`awk -F: '/name/ {print $NF}' /proc/cpuinfo |uniq`
CPU_NUM=`grep -c 'processor' /proc/cpuinfo`
#DISK_INFO=`fdisk -l |grep Disk |awk '/dev/ {print "Disk: " $2,$3,$4}'|sed 's/,//'`
DISK_INFO=`df -h |grep "^/dev/"|awk '{print "Total:",$1,$2}'`
DISK_Avail=`df -h |grep "^/dev/"|awk '{print "Avail:",$1,$4}'`
MEM_INFO=`free -m |grep "Mem"|awk '{print "Total",$1,$2"M"}'`
LOAD_INFO=`uptime |awk '{print "System Load: "$(NF-2),$(NF-1),$NF}'|sed 's/\,//g'`
MEM_Available=`free -m |grep "Mem"|awk '{print "Available",$1,$7"M"}'`
echo -e "\033[32mSystem Info: \033[0m"
echo -e "\033[32m------------------------- \033[0m"
echo -e "\033[32mVersion: ${SYS_VERSION} \033[0m"
echo -e "\033[32mHostname: ${HOSTNAME} \033[0m"
echo -e "\033[32mIPADDR: ${IPADDR} \033[0m"
echo -e "\033[32mCPU Model: ${CPU_Model} \033[0m"
echo -e "\033[32mCPU number: ${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_Available} \033[0m"
echo -e "\033[32m${LOAD_INFO} \033[0m"
echo -e "\033[32m------------------------- \033[0m"

保存退出,传到服务器即可使用。

效果展示

Linux打印系统配置信息脚本

  • 微信号
  • 微信扫一扫加我~~
  • weinxin
  • 微信公众号
  • 微信扫一扫关注我吧~~
  • weinxin
广告也精彩

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  2   博主  0

    • avatar 运维老司机

      亲测,写的不错,感谢博主 :razz:

      • avatar 赖鑫平

        我是一楼么 踩一脚 jf2116