Last active
August 29, 2015 14:20
-
-
Save kidmose/add104a37c213be72654 to your computer and use it in GitHub Desktop.
Simple linux ressource usage logging
This file contains 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
* |
This file contains 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 | |
# timestamp | |
echo -n `date "+%d/%m/%Y %H:%M:%S"` ";" | |
# cpu | |
echo -n `top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}'` ";" | |
free > /tmp/free | |
# Used RAM | |
echo -n `cat /tmp/free | grep Mem | sed -e "s/\s\{1,\}/ /g" | cut -f3 -d' '` ";" | |
# RAM used by kernel for caching | |
echo -n `cat /tmp/free | grep cache: | sed -e "s/\s\{1,\}/ /g" | cut -f4 -d' '` ";" | |
rm /tmp/free | |
# hdd | |
echo `df -lh | awk '{if ($6 == "/") { print $5 }}' | head -1 | cut -d'%' -f1` ";" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment