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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to monitor Machine Health (Project Doctortux) Input needed.
# 1  
Old 07-16-2010
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 .

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

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

Last edited by pinga123; 07-21-2010 at 01:28 AM..
# 2  
Old 07-16-2010
So which unix env for your script, solaris, linux or others?
# 3  
Old 07-16-2010
Looks remarkably like this, so maybe it is Linux?

Script to monitor CPU information.
# 4  
Old 07-16-2010
I m running it on linux environment .After completion i might think about other platform. Smilie

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

Quote:
Originally Posted by methyl
Looks remarkably like this, so maybe it is Linux?

Script to monitor CPU information.
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?
# 5  
Old 07-21-2010
Modified the script to include more options.
Will this script run on most of the linux distributions?
Code:
#######################################################################
#!/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?

Last edited by pinga123; 07-21-2010 at 01:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Input password to bash script, save, and enter when needed

I am looking for a way to start a script and have it prompt for a password that will be used later on in the script to SSH to another host and to SFTP. I don't want the password to be hard coded. Below is my script with the actual IP's and usernames removed. #!/usr/bin/expect -f... (2 Replies)
Discussion started by: jbrass
2 Replies

2. Solaris

Best way to monitor health of Solaris zones ?

What is the best way to monitor the health of solaris zones? Through the global zone or through the individual zones itself ? (5 Replies)
Discussion started by: CuriousDev
5 Replies

3. Solaris

Solaris machine without monitor!!!

Dear friends, I have solaris machine which doesn't have a monitor attached to it, I access it from another computer using putty. I was wondering if it is possible that by the time the computer starts, I could see all those boot messages live on my putty terminal. And is there any terminal... (8 Replies)
Discussion started by: gabam
8 Replies

4. Shell Programming and Scripting

System Health - Cpu, Load, IO Monitor

hello there, can someone please tell me the commands that makes sense, from a production point of view, to be used to make sure CPU, LOAD or IO usages on a Linux or Solaris server isn't too high? I'm aware of vmstat, iostat, sar. But i seriously need real world advice as to what fields in... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Programming

Help Needed Regarding Project

hai guys, I'am a newbie to this forum and to unix as well...as a part of our syllabus i got a project in Unix which i have to do in 4 days.Project is kinda File locking i will give the project specs...guys please help me.. Established client-server architecture using socket... (1 Reply)
Discussion started by: rosemolr
1 Replies

6. Shell Programming and Scripting

Script creation (Input needed)

Hi , I m trying to write a script in linux . The problem is the output of command get changed every now and then. Just like top command in linux. How would i manipulate the output of the command ? The command i m talking about gives the real time values of performance of hosted guest... (3 Replies)
Discussion started by: pinga123
3 Replies

7. Solaris

Monitor server's health

Dear all, There wasn't any monitoring on our server except on the filesystem. Therefore, I was wondering anything i should do on a daily basis to check on the server's status, health, hardware, or any other thing as a disaster prevention? Also, what command i should use to do that? ... (2 Replies)
Discussion started by: beginningDBA
2 Replies

8. BSD

how to monitor a freebsd machine using nagios

hi everyone. Any idea how to monitor a machine running freebsd 7.0 using Nagios? The Nagios server is currently on another machine. thanks :( (1 Reply)
Discussion started by: coolatt
1 Replies
Login or Register to Ask a Question