#!/bin/bash #monitor available disk space SPACE='df | sed -n '/ \ / $ / p' | gawk '{print$5}' | sed 's/%//' if [ $SPACE -ge 90 ] then jbxue123@163.com fi
监控 CPU 和内存的使用情况
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/bash #script to capture system statistics OUTFILE=/home/xu/capstats.csv DATE='date +%m/%d/%Y' TIME='date +%k:%m:%s' TIMEOUT='uptime' VMOUT='vmstat 1 2' USERS='echo $TIMEOUT | gawk '{print$4}' ' LOAD='echo $TIMEOUT | gawk '{print$9}' | sed "s/,//'' FREE='echo$VMOUT | sed -n '/[0-9]/p' | sed -n '2p' | gawk '{print $4} '' IDLE='echo$VMOUT | sed -n '/[0-9]/p' | sed -n '2p' |gawk '{print $15}'' echo "$DATE,$TIME,$USERS,$LOAD,$FREE,$IDLE" >> $OUTFILE