shell/shell脚本编程进阶/创建捕捉脚本.sh

25 lines
660 B
Bash
Raw Normal View History

2016-05-23 08:32:00 +08:00
#!/bin/bash
#
# Capture_Stats - Gather System Performance Statistics
#
#########################################################
#
# Set Script Variables
#
REPORT_FILE=/home/tiandi/Documents/capstats.csv
DATE=`date +%m/%d/%y`
TIME=`date +%k:%M:%S`
#
############################################################
#
USERS=`uptime | sed 's/user.*$//' | gawk '{print $NF}'`
LOAD=`uptime | gawk '{print $NF}'`
#
FREE=`vmstat 1 2 | sed -n '/[0-9]/p' | sed -n '2p' | gawk '{print $4}'`
IDLE=`vmstat 1 2 | sed -n '/[0-9]/p' | sed -n '2p' | gawk '{print $15}'`
#
##########################################
#
echo "$DATE,$TIME,$USERS,$LOAD,$FREE,$IDLE" >> $REPORT_FILE
#