LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 06-04-2003, 11:47 AM   #1
Bilb
LQ Newbie
 
Registered: Jun 2003
Posts: 24

Rep: Reputation: 15
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?
 
Old 06-04-2003, 12:21 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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.
 
Old 06-06-2003, 03:04 PM   #3
Bilb
LQ Newbie
 
Registered: Jun 2003
Posts: 24

Original Poster
Rep: Reputation: 15
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.
 
Old 06-09-2003, 12:40 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Sorry - I've been away for a few days.

What is it you want to extract from the output?
 
Old 06-09-2003, 01:29 PM   #5
Bilb
LQ Newbie
 
Registered: Jun 2003
Posts: 24

Original Poster
Rep: Reputation: 15
In the end I would like it to email me with the box IP if the CPU/'s gets overloaded.
 
Old 06-09-2003, 01:58 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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;
 
Old 06-10-2003, 08:58 AM   #7
Bilb
LQ Newbie
 
Registered: Jun 2003
Posts: 24

Original Poster
Rep: Reputation: 15
Thx alot!
u've saved me a few more migraines

I'll give it a go when i get a mo
 
  


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
resource/sensor monitor evil_empire Linux - General 12 03-31-2005 12:47 PM
resource monitor? acidjuice SUSE / openSUSE 1 02-13-2005 07:54 PM
Nonexistent resource rudy152 Linux - Hardware 0 01-19-2005 03:23 PM
what are resource collisions? quantumechanix Linux - Newbie 2 01-18-2003 09:13 AM
Resource Hog tangle Linux - General 2 04-11-2002 07:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:36 PM.

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
Open Source Consulting | Domain Registration