#!/bin/bash
echo "********************************************"
echo "* 查看监控列表信息 *" echo ""#打印CPU相关信息
cpu_model=`cat /proc/cpuinfo |grep 'model name' |gawk -F : '{print $2}'`echo "cpu model: $cpu_model "cpu_cores=`cat /proc/cpuinfo |grep 'cpu cores'|gawk -F : '{print $2}'`echo "cpu cores: $cpu_cores * core(s) "cpu_usage=`top -n 1 |grep '%Cpu'|gawk -F : '{print $2}'|gawk -F , '{print $1}'|sed 's/us//'`echo "cpu usage: $cpu_usage"%""#打印内存相关信息
memory_total=`free -h |grep -i mem |gawk -F : '{print $2}' |gawk '{print $1}'`echo "memory total: $memory_total"memory_total1=`free |grep -i mem |gawk -F : '{print $2}' |gawk '{print $1}'`memory_used=`free |grep -i mem |gawk -F : '{print $2}' |gawk '{print $2}'`memory_usage=`echo "scale=2; ($memory_used / $memory_total1)*100" | bc `echo "memory usage: $memory_usage"%""swap_total=`free -h |grep -i swap |gawk -F : '{print $2}' |gawk '{print $1}'`
echo "swap total: $swap_total"swap_total1=`free |grep -i swap |gawk -F : '{print $2}' |gawk '{print $1}'`swap_used=`free |grep -i swap |gawk -F : '{print $2}' |gawk '{print $2}'`swap_usage=`echo "scale=2; ($swap_used / $swap_total1)*100" | bc `echo "swap usage: $swap_usage"%""***********************************************************************
运行结果