I have written little script to check the CPU performance of the machine.
Request you to contribute your comments on the same.
Feel free to add your own scriptlet to make it better.
I call it as doctortux
I have decided to run the script in two mode
1)Interactive.(Not yet included in script)
2)Automatic.(currently giving CPU information.)
Automatic mode ( -a ) (default):This mode shoudnt ask any input from user and should run automatically.
Interactive mode (-i) : This mode should ask user for input .
Request you to contribute your comments on the same.
Feel free to add your own scriptlet to make it better.
I call it as doctortux
I have decided to run the script in two mode
1)Interactive.(Not yet included in script)
2)Automatic.(currently giving CPU information.)
Automatic mode ( -a ) (default):This mode shoudnt ask any input from user and should run automatically.
Interactive mode (-i) : This mode should ask user for input .
Code:
##############################Option Check###############################
#!/bin/bash
#########################UPTIME########################################
fn_uptimeinfo()
{
echo "Machine Uptime Information:"
echo -e "\033[32m uptime"
tput sgr0 #restores the terminal settings to normal.
uptime
echo "Command Description:"
echo "<current time> <Uptime since> <hour:min>"
echo "Number of users logged in to machine"
echo "load average <for last one minute>,<for last 5 minutes>,<for last 15 minutes>"
echo "________________________________________________________________"
}
fn_terminalinfo()
{
echo "Terminal Information:"
echo -e "\033[32m w"
tput sgr0
w
echo "________________________________________________________________"
}
#################################################################
######################CPU INFO########################################
fn_cpuinfo()
{
echo -e "\033[32m cat /proc/cpuinfo"
tput sgr0
cat /proc/cpuinfo
echo "________________________________________________________________"
}
fn_cpueaterprocess()
{
echo "Top 10 C.P.U Consumer Processes:"
echo -e "\033[32m ps -auxf | sort -nr -k 3 | head -10 "
tput sgr0
ps -auxf | sort -nr -k 3 | head -10
echo "________________________________________________________________"
}
######################################################################
#########################Memory Information###########################
fn_meminfo()
{
echo -e "\033[32m cat /proc/meminfo"
tput sgr0
cat /proc/meminfo
echo "________________________________________________________________"
echo -e "\033[32m free -m"
tput sgr0
free -m
echo "________________________________________________________________"
}
fn_memeaterprocess()
{
echo "Top 10 Memory Consumer Processes:"
echo -e "\033[32m ps -auxf | sort -nr -k 4 | head -10 "
tput sgr0
ps -auxf | sort -nr -k 4 | head -10
echo "________________________________________________________________"
}
######################################################################
#######################Disk Information###############################
fn_diskinfo()
{
echo "Disk Utilization"
echo -e "\033[32m df -h"
tput sgr0
df -h
echo "________________________________________________________________"
}
fn_partitioninfo()
{
echo "Disk Partition Information"
echo -e "\033[32m cat /proc/partitions"
tput sgr0
cat /proc/partitions
echo "________________________________________________________________"
}
######################################################################
fn_automatic()
{
echo "########CPU Information########"
fn_uptimeinfo
fn_terminalinfo
fn_cpuinfo
fn_cpueaterprocess
echo "########Memory Information########"
fn_meminfo
fn_memeaterprocess
echo "########Disk Information########"
fn_diskinfo
fn_partioninfo
}
if [ $# -eq 0 ]
then
echo "Automatic Mode Selected"
fn_automatic
else
while getopts ai option 2>/dev/null
do
case "$option" in
a) echo "Automatic Mode Selected"
fn_automatic
echo "Thanks";;
i) echo "Interacive Mode Selected";;
?) echo "Please select proper option"
echo list of available options
-a automatic -i interactive ;;
esac
done
fi