Sponsored Content
Full Discussion: check cpu usage
Top Forums Shell Programming and Scripting check cpu usage Post 302178275 by nua7 on Tuesday 25th of March 2008 06:51:08 AM
Old 03-25-2008
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");
}

 

10 More Discussions You Might Find Interesting

1. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

2. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

3. UNIX for Dummies Questions & Answers

How check the overall CPU usage of the unix server

Hi All, Can anyone help me.. I want to know the command to check the overall CPU usage of the server. Note: I don't want the CPU usge of each and every process. I just want to know thw aggregate CPU utilization of the server. (2 Replies)
Discussion started by: Selva_Kumar
2 Replies

4. Programming

Cpu usage

Hi all, When I have a below while loop in my code (This observation is same for C and Perl) i= 0; while(1) { i++; } for above the CPU uses goes beyond 49% on hp-ux machine, why cpu usage increase at this level for just a simple while loop? and if I have a single print statement... (2 Replies)
Discussion started by: zing_foru
2 Replies

5. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

6. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

7. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

8. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

9. Shell Programming and Scripting

Command to check the CPU usage for particular user

Hi All, Can anybody knows, how to check the CPU usage in percentage for a particular process along with its user and PID? Thanks in advance!! (3 Replies)
Discussion started by: AB10
3 Replies

10. AIX

Overall CPU Usage

Hi Guys, I am a newbie on the forum. This is my first post, so first of all I would like to introduce myself. I am a SAS Analyst programmer working for an Health Insurance client. SAS is installed on a 16 CPU AIX Server with partitions running with shared processor. I have couple of... (2 Replies)
Discussion started by: saurabhiim2003
2 Replies
SOAP::Packager(3)					User Contributed Perl Documentation					 SOAP::Packager(3)

NAME
SOAP::Packager - this class is an abstract class which allows for multiple types of packaging agents such as MIME and DIME. DESCRIPTION
The SOAP::Packager class is responsible for managing a set of "parts." Parts are additional pieces of information, additional documents, or virtually anything that needs to be associated with the SOAP Envelope/payload. The packager then will take these parts and encode/decode or "package"/"unpackage" them as they come and go over the wire. METHODS
new Instantiates a new instance of a SOAP::Packager. parts Contains an array of parts. The contents of this array and their types are completely dependant upon the Packager being used. For example, when using MIME, the content of this array is MIME::Entity's. push_part Adds a part to set of parts managed by the current instance of SOAP::Packager. parser Returns the parser used to parse attachments out of a data stream. headers_http This is a hook into the HTTP layer. It provides a way for a packager to add and/or modify HTTP headers in a request/response. For example, most packaging layers will need to override the Content-Type (e.g. multipart/related, or application/dime). ABSTRACT METHODS
If you wish to implement your own SOAP::Packager, then the methods below must be implemented by you according to the prescribed input and output requirements. package() The "package" subroutine takes as input the SOAP envelope in string/SCALAR form. This will serve as the content of the root part. The packager then encapsulates the envelope with the parts contained within "parts" and returns the properly encapsulated envelope in string/SCALAR form. unpackage() The "unpackage" subroutines takes as input raw data that needs to be parsed into a set of parts. It is responsible for extracting the envelope from the input, and populating "parts" with an ARRAY of parts extracted from the input. It then returns the SOAP Envelope in string/SCALAR form so that SOAP::Lite can parse it. SUPPORTED PACKAGING FORMATS
SOAP::Packager::MIME "SOAP::Packager::MIME" utilizes MIME::Tools to provides the ability to send and receive Multipart/Related and Multipart/Form-Data formatted requests and responses. MIME METHODS The following methods are used when composing a MIME formatted message. transfer_encoding The value of the root part's Content-Transfer-Encoding MIME Header. Default is: 8bit. env_id The value of the root part's Content-Id MIME Header. Default is: <main_envelope>. env_location The value of the root part's Content-Location MIME Header. Default is: /main_envelope. env_type The value of the root part's Content-Type MIME Header. Default is: text/xml. OPTIMIZING THE MIME PARSER The use of attachments can often result in a heavy drain on system resources depending upon how your MIME parser is configured. For example, you can instruct the parser to store attachments in memory, or to use temp files. Using one of the other can affect performance, disk utilization, and/or reliability. Therefore you should consult the following URL for optimization techniques and trade-offs: http://search.cpan.org/dist/MIME-tools/lib/MIME/Parser.pm#OPTIMIZING_YOUR_PARSER To modify the parser's configuration options consult the following code sample, which incidentally shows how to minimize memory utilization: my $packager = SOAP::Packager::MIME->new; # $packager->parser->decode_headers(1); # no difference # $packager->parser->extract_nested_messages(1); # no difference $packager->parser->output_to_core(0); # much less memory $packager->parser->tmp_to_core(0); # much less memory $packager->parser->tmp_recycling(0); # promotes faster garbage collection $packager->parser->use_inner_files(1); # no difference my $client = SOAP::Lite->uri($NS)->proxy($URL)->packager($packager); $client->someMethod(); CLIENT SIDE EXAMPLE The following code sample shows how to use attachments within the context of a SOAP::Lite client. #!/usr/bin/perl use SOAP::Lite; use MIME::Entity; my $ent = build MIME::Entity Type => "text/plain", Path => "attachment.txt", Filename => "attachment.txt", Disposition => "attachment"; $NS = "urn:Majordojo:TemperatureService"; $HOST = "http://localhost/cgi-bin/soaplite.cgi"; my $client = SOAP::Lite ->packager(SOAP::Packager::MIME->new) ->parts([ $ent ]) ->uri($NS) ->proxy($HOST); $response = $client->c2f(SOAP::Data->name("temperature" => '100')); print $response->valueof('//c2fResponse/foo'); SERVER SIDE EXAMPLE The following code shows how to use attachments within the context of a CGI script. It shows how to read incoming attachments, and to return attachments to the client. #!/usr/bin/perl -w use SOAP::Transport::HTTP; use MIME::Entity; SOAP::Transport::HTTP::CGI ->packager(SOAP::Packager::MIME->new) ->dispatch_with({'urn:Majordojo:TemperatureService' => 'TemperatureService'}) ->handle; BEGIN { package TemperatureService; use vars qw(@ISA); @ISA = qw(Exporter SOAP::Server::Parameters); use SOAP::Lite; sub c2f { my $self = shift; my $envelope = pop; my $temp = $envelope->dataof("//c2f/temperature"); use MIME::Entity; my $ent = build MIME::Entity Type => "text/plain", Path => "printenv", Filename => "printenv", Disposition => "attachment"; # read attachments foreach my $part (@{$envelope->parts}) { print STDERR "soaplite.cgi: attachment found! (".ref($part).") "; print STDERR "soaplite.cgi: contents => ".$part->stringify." "; } # send attachments return SOAP::Data->name('convertedTemp' => (((9/5)*($temp->value)) + 32)), $ent; } } SOAP::Packager::DIME TODO SEE ALSO
MIME::Tools, DIME::Tools COPYRIGHT
Copyright (C) 2000-2004 Paul Kulchenko. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHORS
Byrne Reese (byrne@majordojo.com) perl v5.12.1 2009-09-30 SOAP::Packager(3)
All times are GMT -4. The time now is 07:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy