Skip to content

Instantly share code, notes, and snippets.

@heyseus1
Created July 14, 2016 16:49
Show Gist options
  • Save heyseus1/b2a8045058e0d18554881b66a206c852 to your computer and use it in GitHub Desktop.
Save heyseus1/b2a8045058e0d18554881b66a206c852 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Config ------------------------------------------------
outfile="${HOSTNAME}_Net_io_config.txt"
#--------------------------------------------------------
checkroot() {
if [ $UID -ne 0 ] ; then
echo "User has insufficient privilege."
exit 4
fi
}
header() {
echo '' | tee -a $outfile
echo -e "----------------------" | tee -a $outfile
echo -e " [*] $title " | tee -a $outfile
echo -e "----------------------" | tee -a $outfile
}
hostnames() {
title="Hostname"
header $title
hostname | tee -a $outfile
cat /etc/*-release | tee -a $outfile
uname -r | tee -a $outfile
}
netio_config () {
title="Netio_config"
header $title
rmem=`/sbin/sysctl -a|grep -P net.core\..mem | grep rmem_default`
wmem=`/sbin/sysctl -a|grep -P net.core\..mem | grep wmem_default`
amem=`/sbin/sysctl -a|grep -P net.core\..mem | grep rmem_default | awk -F'= ' '{print$2}'`
minimum=8388608
if [ "$amem" -lt "$minimum" ]
then
echo "this system is below requirements." | tee -a $outfile
echo $rmem | tee -a $outfile
echo $wmem | tee -a $outfile
else
echo system passes minimum requirements | tee -a $outfile
/sbin/sysctl -a|grep -P net.core\..mem | tee -a $outfile
fi
}
email() {
mail -s "RIAK" ${SUDO_USER}@gmail.com < ${HOSTNAME}_Net_io_config.txt
echo "Email delivered to ${SUDO_USER}@gmail.com"
exit 0
}
checkroot
hostnames
netio_config
email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment