Skip to content

Instantly share code, notes, and snippets.

@shanefreeman
shanefreeman / freemem.sh
Last active August 19, 2016 20:46
A literal printout of the 'free' utility.
#!/bin/bash
### This script is provided with the hopes that it will be useful, but without any warranty of any kind. This script to be used AT YOUR OWN RISK. ###
date > /var/tmp/_free.tmp.txt
free >> /var/tmp/_free.tmp.txt
ramTotal="$(awk '/Mem/ {print $2}' /var/tmp/_free.tmp.txt)"
ramUsed="$(awk '/+/ {print $3}' /var/tmp/_free.tmp.txt)"
ramFree="$(awk '/+/ {print $4}' /var/tmp/_free.tmp.txt)"
swapTotal="$(awk '/Swap/ {print $2}' /var/tmp/_free.tmp.txt)"
swapUsed="$(awk '/Swap/ {print $3}' /var/tmp/_free.tmp.txt)"
swapFree="$(awk '/Swap/ {print $4}' /var/tmp/_free.tmp.txt)"
@shanefreeman
shanefreeman / top.sh
Last active August 20, 2016 00:25
This will run top the specified number of iterations, at the specified interval. This is useful for troubleshooting processes that are hogging CPU/Memory, which a qkview won't tell you.
#!/bin/bash
# USE AT YOUR OWN RISK!!!
#
# play nice and clean up on exit
function exitcleanup {
if [ $success ]
then
echo -e "\\n--------------- $end iterations every $sleep seconds completed successfully ---------------"
echo -e "\\n--------------- $end iterations every $sleep seconds completed successfully ---------------" >> $output
else