check cpu usage | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

check cpu usage

Shell Programming and Scripting


Tags
perl, perl shift, shift, shift perl

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-24-2008
gholdbhurg gholdbhurg is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 25 February 2009, 12:17 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old 03-25-2008
gholdbhurg gholdbhurg is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 25 February 2009, 12:17 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
If there are no threads related to this,
Does anyone know a way for this?

Thanks
Sponsored Links
    #3  
Old 03-25-2008
nua7 nua7 is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 27 March 2014, 10:42 AM EDT
Location: /bin/sh
Posts: 423
Thanks: 24
Thanked 4 Times in 4 Posts
Hammer & Screwdriver

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  
Old 03-25-2008
gholdbhurg gholdbhurg is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 25 February 2009, 12:17 PM EST
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
thanks nua7
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to check memory usage ? mrugesh78 Linux 8 03-11-2011 12:16 PM
Command to check RAM usage Swapna173 UNIX for Dummies Questions & Answers 1 02-04-2009 09:35 AM
how can I find cpu usage memory usage swap usage and logical volume usage alert0919 HP-UX 3 12-02-2008 01:38 PM
System usage check pushkar.verma AIX 3 01-25-2008 01:11 PM
Check the Disk usage Programmatically SriSri Programming 2 09-20-2005 03:15 AM



All times are GMT -4. The time now is 12:55 AM.