Script to monitor Machine Health (Project Doctortux) Input needed.

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 have decided to 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 .

##############################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 "________________________________________________________________"
}
#################################################################

#######################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 "########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

Modified with CPU and Memory Information.

So which unix env for your script, solaris, linux or others?

Looks remarkably like this, so maybe it is Linux?

Script to monitor CPU information.

I m running it on linux environment .After completion i might think about other platform. :slight_smile:

---------- Post updated at 05:03 AM ---------- Previous update was at 05:02 AM ----------

that thread was posted by myself .But this forum is much more faster so i shifted my focus here.Thanks to pludy He is a real unix guru.

---------- Post updated at 05:51 AM ---------- Previous update was at 05:03 AM ----------

What else can be included?. Also want to know how would i include network information in the script?

Modified the script to include more options.
Will this script run on most of the linux distributions?

#######################################################################
#!/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_partitioninfo
}
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

---------- Post updated at 11:51 PM ---------- Previous update was at 11:26 PM ----------

I m planning to include some content from error file .What is the most common location for checking the error log in system?