Search This Blog

Monday, August 9, 2010

Actual script( Doctortux)

After a long discussion with various forums i have decided to name it as doctortux.

I m going to post modified content of Performance monitoring script.


#######################################################################
#!/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 " "
echo "Number of users logged in to machine"
echo "load average ,,"
echo "________________________________________________________________"
}
fn_terminalinfo()
{
echo "Terminal Information:"
echo -e "\033[32m w"
tput sgr0
w
echo "________________________________________________________________"
}
#################################################################
#####################CONNECTION INFO############################
fn_numberofconnection()
{
echo "Connection Information"
echo -e "\033[32m netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq"
tput sgr0
netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq
}
#################################################################
######################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_partitioninfo
echo "#######Connection Information#######"
fn_numberofconnection
}
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
echo "-a automatic -i interactive" ;;
esac
done
fi

No comments:

Post a Comment