Sponsored Content
Top Forums Shell Programming and Scripting Script to monitor Machine Health (Project Doctortux) Input needed. Post 302438814 by pinga123 on Wednesday 21st of July 2010 12:51:11 AM
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..
 

8 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

8. 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
All times are GMT -4. The time now is 08:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy