#!/bin/bash # func:sys info check [ $(id -u) -ne 0 ] && echo "请用root用户执行此脚本!" && exit 1 sysversion=$(rpm -q centos-release | cut -d- -f3) line="-------------------------------------------------" # 获取系统cpu信息 function get_cpu_info() { Physical_CPUs=$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l) Virt_CPUs=$(grep "processor" /proc/cpuinfo | wc -l) CPU_Kernels=$(grep "cores" /proc/cpuinfo | uniq | awk -F ': ' '{print $2}') CPU_Type=$(grep "model name" /proc/cpuinfo | awk -F ': ' '{print $2}' | sort | uniq) CPU_Arch=$(uname -m) cpu_usage=$(cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1) #echo -e '\033[32m CPU信息:\033[0m' echo -e ' CPU信息:' cat <&1) pub_ipadd=$(curl -s http://ddns.oray.com/checkip | awk -F ":" '{print $2}' | awk -F "<" '{print $1}' | awk '{print $1}') gateway=$(ip route | grep default | awk '{print $3}') mac_info=$(ip link | egrep -v "lo" | grep link | awk '{print $2}') dns_config=$(egrep 'nameserver' /etc/resolv.conf) route_info=$(route -n) echo -e ' IP信息:' cat </dev/null) if [ ${sysversion} -gt 6 ]; then service_config=$(systemctl list-unit-files --type=service --state=enabled | grep "enabled") run_service=$(systemctl list-units --type=service --state=running | grep ".service") else service_config=$(/sbin/chkconfig | grep -E ":on|:启用" | column -t) run_service=$(/sbin/service --status-all | grep -E "running") fi echo -e ' 服务启动配置:' cat </dev/null | cut -d/ -f5 egrep -v "^$|^#" ${cronuser} 2>/dev/null echo "" done) echo -e ' 系统登录用户:' cat <