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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-27-2008, 05:31 AM
|
#1
|
|
LQ Newbie
Registered: Nov 2008
Posts: 2
Rep:
|
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 05:32 AM.
|
|
|
|
11-27-2008, 09:18 AM
|
#2
|
|
Member
Registered: Nov 2004
Location: Maryland, USA
Distribution: Mint 13
Posts: 272
Rep:
|
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.
|
|
|
|
11-27-2008, 10:21 AM
|
#3
|
|
Senior Member
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,043
Rep:
|
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.
|
|
|
|
11-27-2008, 10:24 AM
|
#4
|
|
Senior Member
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,043
Rep:
|
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.
|
|
|
|
11-27-2008, 10:58 AM
|
#5
|
|
LQ Newbie
Registered: Nov 2008
Posts: 2
Original Poster
Rep:
|
Quote:
Originally Posted by jstephens84
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
|
|
|
|
11-27-2008, 11:03 AM
|
#6
|
|
Senior Member
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,043
Rep:
|
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.
|
|
|
|
11-27-2008, 11:08 AM
|
#7
|
|
Senior Member
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,043
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|