The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 02:11 PM
CPU usage and memory usage mansoorulhaq High Level Programming 1 08-09-2007 04:55 PM
how to use ioctl to check out memory usage lanchen High Level Programming 2 01-31-2006 01:30 PM
Check the Disk usage Programmatically SriSri High Level Programming 2 09-20-2005 03:15 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 07:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2008
gholdbhurg gholdbhurg is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 26
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.
  #2 (permalink)  
Old 03-25-2008
gholdbhurg gholdbhurg is offline
Registered User
  
 

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

Thanks
  #3 (permalink)  
Old 03-25-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
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");
}
  #4 (permalink)  
Old 03-25-2008
gholdbhurg gholdbhurg is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 26
thanks nua7
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0