Last active
November 14, 2017 07:29
-
-
Save ajithbh/8e04d4be07b3c9ba41531182931c9691 to your computer and use it in GitHub Desktop.
Dump /proc/meminfo in csv format
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 | |
__VER="1.0" | |
INTERVAL=1 | |
usage () { | |
echo "Usage : $0 [options] [--] | |
Options: | |
-h|help Display this message | |
-v|version Display version | |
-n|interval <sec> Seconds to wait between output" | |
} | |
while getopts ":hvn:" opt | |
do | |
case $opt in | |
h|help ) usage; exit 0 ;; | |
v|version ) echo "$0 -- Version $__VER"; exit 0 ;; | |
n|interval ) INTERVAL=$OPTARG ;; | |
* ) echo -e "\n No such option : $OPTARG\n"; usage; exit 1 ;; | |
esac | |
done | |
echo -n "Time," | |
cat /proc/meminfo | awk -F: -vORS=, ' { print $1 } ' | sed 's/,$/\n/' | |
while true; do | |
NOW=$(date +"%D %T") | |
echo -n "$NOW," | |
cat /proc/meminfo | awk -vORS=, ' { print $2 } ' | sed 's/,$/\n/' | |
sleep $INTERVAL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment