The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
System usage check pushkar.verma AIX 3 01-25-2008 10:11 AM
CPU usage and memory usage mansoorulhaq High Level Programming 1 08-09-2007 01:55 PM
how to use ioctl to check out memory usage lanchen High Level Programming 2 01-31-2006 09:30 AM
Check the Disk usage Programmatically SriSri High Level Programming 2 09-20-2005 12:15 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 03:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2008
Registered User
 

Join Date: Oct 2007
Posts: 25
Stumble this Post!
check cpu usage

Hi,
Are there previous threads on perl scripts that check the cpu usage and send email whenever this exceeded a certain threshold?

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Oct 2007
Posts: 25
Stumble this Post!
If there are no threads related to this,
Does anyone know a way for this?

Thanks
Reply With Quote
  #3 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 338
Stumble this Post!
Wink

Hi!
This might be useful. It would give you procedure to send a mail thru perl.Extracting cpu usage shouldn't be a big deal.

Code:
sub _send_email($$$) {
	my $recipient = shift;
	my $full_name = shift;
	my $result_file = shift;
	my $res_file = basename($result_file);
	my $res_dir = dirname($result_file);
	chomp(my $hostname = qx/uname -n/);

	my $msg = MIME::Lite->new(
		From => '"Manager Usage" <MGR@"Server name">',
		To => "\"$full_name\" <$recipient>",
		Subject => "Results of usage for $input_dir on $hostname",
		Type => 'multipart/mixed',
		Data => "The results of your usage run are attached."
	);

	$msg->attach(
		Type => 'TEXT',
		Data => "Hello,\n$full_name\n\nPlease DO NOT reply to this email!\n\nIt was generated by a non-user account.  Attached is a file\ncontaining the results of your requested deck_check.upl run.\n\nThank You,\nThe HP Issuance Team"
	);

	$msg->attach(
		Type => 'TEXT',
		Path => "$result_file",
		Filename => "$res_file",
		Disposition => 'attachment'
	);

	$msg->send("sendmail");
}
Reply With Quote
  #4 (permalink)  
Old 03-25-2008
Registered User
 

Join Date: Oct 2007
Posts: 25
Stumble this Post!
thanks nua7
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0