Skip to content

Instantly share code, notes, and snippets.

@ajithbh
Last active November 14, 2017 07:29
Show Gist options
  • Save ajithbh/8e04d4be07b3c9ba41531182931c9691 to your computer and use it in GitHub Desktop.
Save ajithbh/8e04d4be07b3c9ba41531182931c9691 to your computer and use it in GitHub Desktop.
Dump /proc/meminfo in csv format
#!/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