Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-04-2003, 11:47 AM
|
#1
|
LQ Newbie
Registered: Jun 2003
Posts: 24
Rep:
|
Resource monitor
Hi,
Basically im after a little script or program that will email me if ever the system gets overloaded.
Anyone know of any?
|
|
|
06-04-2003, 12:21 PM
|
#2
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
I don't know of one but if you mean like CPU usage then you could just write something to monitor the output from sar.
|
|
|
06-06-2003, 03:04 PM
|
#3
|
LQ Newbie
Registered: Jun 2003
Posts: 24
Original Poster
Rep:
|
I've tried with sar but still not the best with scripting,
I've tried doin
sar 2 5 > tmp0.log
chk=`tail -c 6 tmp0.log`
but I cant seem to get the if command to work with it.
I've also tried awk '/Average/ { t=$6 }' tmp0.log but with no luck 
Last edited by Bilb; 06-06-2003 at 03:07 PM.
|
|
|
06-09-2003, 12:40 PM
|
#4
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
Sorry - I've been away for a few days.
What is it you want to extract from the output?
|
|
|
06-09-2003, 01:29 PM
|
#5
|
LQ Newbie
Registered: Jun 2003
Posts: 24
Original Poster
Rep:
|
In the end I would like it to email me with the box IP if the CPU/'s gets overloaded.
|
|
|
06-09-2003, 01:58 PM
|
#6
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
Here is a perl script
Code:
#!/usr/bin/perl
# Get the CPU usage
@sar = `sar 1 1`;
# Extract the average CPU usage
($ave) = $sar[@sar-1] =~ /.* (.*)\n/;
# If there is only 5% CPU available then...
if($ave < "5"){
# Get the ip info
@ipconf = `ifconfig`;
# Send the ip info
open(MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: someone\@somewhere.com\n";
print MAIL "From: someone\@somewhere.com\n";
print MAIL "Subject: CPU running at over 90% CPU\n\n";
print MAIL @ipconf;
close(MAIL);
}
exit;
|
|
|
06-10-2003, 08:58 AM
|
#7
|
LQ Newbie
Registered: Jun 2003
Posts: 24
Original Poster
Rep:
|
Thx alot!
u've saved me a few more migraines
I'll give it a go when i get a mo
|
|
|
All times are GMT -5. The time now is 11:36 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
|
|