LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-27-2008, 06:31 AM   #1
moyousif
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
Server Check Scripts with grep Option


Hi every one,

I have some problems doing daily routines on my Linux servers I need to do the following

Check the disk size
Check memory and cpu utilization.
Check /var/adm/messages for specifics alarms .

I am wounding if anyone can suggest me a script to monitor host performance according the previous points and send me email if specific value In df –k , vmstat

Any suggestions
Am asking the experts 
Regards,
M. Yosuif Alx

Last edited by moyousif; 11-27-2008 at 06:32 AM.
 
Old 11-27-2008, 10:18 AM   #2
Fritz_Monroe
Member
 
Registered: Nov 2004
Location: Maryland, USA
Distribution: Mint 13
Posts: 272

Rep: Reputation: 30
I'm no scripting expert, so can't just pop out a script for you, but I'll try to give some ideas.

I found a Linux Command Cheatsheet that has a bunch of useful scripts. One is for checking CPU suage. You could put this into a loop and use the cut command to pull out the un-needed bits. Maybe just keep the CPU % and the process name. Direct the output to a file using > to overwrite the contents of that file or >> to append to the file.

Then use the mail command to e-mail it to yourself. That would be something along the lines of

mail -s "subject" address < filename.input

Good luck with creating your script.

One piece of advice is to install an enhanced text editor if you don't already have one. This will color the text in different ways and it makes it easier to see what you are doing.
 
Old 11-27-2008, 11:21 AM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Here is a start.
Code:
df -h >> MorningLog.log // gives you diskspace info
free -m >> MorningLog.log // gives you memory info
vmstat >> MorningLog.log  // gives you swaping information
ps aux | awk '{print $1, " ", $2 " ", $3, " " , $4, " ", $11}' >> MorningLog.log  // gives you all processs running, who owns them, cpu %, mem% and what the command is.
 
Old 11-27-2008, 11:24 AM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
then you can also put in
Code:
lpr -P <destination to printer> -# <number> -h [file name]
this will send the MorningLog.log to a printer in your office.
 
Old 11-27-2008, 11:58 AM   #5
moyousif
LQ Newbie
 
Registered: Nov 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jstephens84 View Post
Here is a start.
Code:
df -h >> MorningLog.log // gives you diskspace info
free -m >> MorningLog.log // gives you memory info
vmstat >> MorningLog.log  // gives you swaping information
ps aux | awk '{print $1, " ", $2 " ", $3, " " , $4, " ", $11}' >> MorningLog.log  // gives you all processs running, who owns them, cpu %, mem% and what the command is.


hijstephens84 ,

Thanks for you feed . .
this is so close, but i need to do more , i mean to append to MorningLog.log only if df -h for /var valuse exceeded 80 %.

its was helpfull
Thanks
 
Old 11-27-2008, 12:03 PM   #6
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Sounds like you are going to want to use regexp also with df -h to parse out the percentage. maybe. I will tinker around and see what I can come up with.
 
Old 11-27-2008, 12:08 PM   #7
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
well I was able to get the percentages from df -h but just having problems with my if statement. Some things you will want to research will be how to remove headings from df -h and how to turn the string into an integer.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
understand -w option with grep geeyathink Programming 5 02-21-2008 05:17 AM
How to check grep status when find elements return 0 ahjiefreak Programming 18 12-18-2007 06:06 PM
Paragraph-option to grep TheSpork Linux - General 2 03-17-2006 02:45 AM
grep option needed ziox Linux - General 7 01-05-2005 12:02 AM
Problem: Running cgi scripts with userdir option beatlelane Fedora 4 04-16-2004 04:06 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration