您的位置:首页 > 运维架构 > Linux

linux shell状态检测

2020-08-17 13:40 831 查看

linux shell 检测

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

#看系统版本
versions=`cat /etc/redhat-release |awk '{print "version is:" $1"-"$4}' |awk -F '.' '{print $1"."$2}'`

#看磁盘使用情况
disks=`fdisk -l |grep "Disk" |grep -n "sectors$" |sed -e "s/:/-/g" -e "s/,//g" |awk '{print "disk is:" $2 $3 $4}'`

#看内存
mens=`free -h |sed -n "2p" |awk '{print "men free is:""\n" "total-"$2 "\n" "used-"$3"\n" "free-" $4}'`

#看cpu
cpus=`cat /proc/cpuinfo |grep "physical id" |sort |uniq -c|awk '{print "CPU:" "\n" $2,$NF,"\n" "Core:"$1}'`

#查看当前操作系统平
machines=`dmidecode  |grep "Product Name" |sed -ne "1p" |sed -e "s/[\t]//g"`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: