Created
November 21, 2014 14:12
-
-
Save Remiii/3750b63f8a8d76f9ba41 to your computer and use it in GitHub Desktop.
HW state log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # HW state log by Remiii | |
| # Package `bc` : (sudo apt-get install bc) | |
| LOG_FILE='hw-state-log.log' | |
| echo `date` >> ${LOG_FILE} | |
| echo CPU: `top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}'`% >> ${LOG_FILE} | |
| FREE_DATA=`free -m | grep Mem` >> ${LOG_FILE} | |
| CURRENT=`echo ${FREE_DATA} | cut -f3 -d' '` >> ${LOG_FILE} | |
| TOTAL=`echo ${FREE_DATA} | cut -f2 -d' '` >> ${LOG_FILE} | |
| echo RAM: $(echo "scale = 2; ${CURRENT}/${TOTAL}*100" | bc)% >> ${LOG_FILE} | |
| echo HDD: `df -lh | awk '{if ($6 == "/") { print $5 }}' | head -1 | cut -d'%' -f1`% >> ${LOG_FILE} | |
| echo '' >> ${LOG_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment