Saturday, October 11, 2008

Shell Script to show disk space, logged in users and memory usage.

#!/usr/bin/sh
#Author: Parag Kalra
#Date: 11th October, 2008

function menu {

clear
echo
echo -e "\t\t\tSys Admin Menu\n"
echo -e "\t1. Display disk space"
echo -e "\t2. Display logged on users"
echo -e "\t3. Display memory usage"
echo -e "\t0. Exit menu\n\n"
echo -en "\t\tEnter option: "
read -n 1 option

}

function diskspace {
clear
df -k
}

function users {
clear
who
}

function memusage {
clear
cat /proc/meminfo
}

while [ 1 ]
do
clear
menu

case $option in
0)
echo
break;;
1)
diskspace;;
2)
users;;
3)
memusage;;
*)
echo "Wrong Option"
esac

echo "Hit any key to continu!"
read -n 1 line
done


Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com

No comments: