vmstat uptime 系统状态脚本

时间:2023-01-09 17:05:58
 #!/bin/bash
 #
 # Command :vmstat,uptime
 #Capture_Stats - Gather System Performance Statistics
 ############################################################
 # Set Script Variables
 #
 REPORT_FILE=/home/ach/data-file/vmstat-uptime.csv
 DATE=`date +%m%d%Y`
 TIME=`date +%k:%M:%S`
 #
 ##############################################################
 # Gather Performance Statistics
 #
 USERS=`uptime | sed 's/users.*$//' | gawk '{print $NF}'`
 LOAD=`uptime |gawk '{print $NF}'`
 #
 FREE=`vmstat   | sed -n '/[0-9]/p' | sed -n '2p'|
 gawk '{print $4}'`
 #
 IDLE=`vmstat   | sed -n '/[0-9]/p' | sed -n '2p'|
 gawk '{print $15}'`
 #
 ############################################################
 #
 echo $DATE $TIME $USERS $LOAD $FREE $IDLE >> $REPORT_FILE
 #exec >&
 #exec > $REPORT_FILE
 #echo "Time is :" $DATE -- $TIME
 #echo "number of users:" $USERS
 #echo "average load at last 15 minutes:" $LOAD
 #echo "Free physical disk:" $FREE
 #echo "Cup is free (%)" $IDLE
 #exec >&
 #
 #END