Sponsored Content
Top Forums Shell Programming and Scripting Formatting the output of ps -eo command Post 302679117 by 02JayJay02 on Monday 30th of July 2012 09:35:20 AM
Old 07-30-2012
Formatting the output of ps -eo command

Hi ive been tasked to create a warning email which will be sent when a process exceeds a given percentage of CPU,
Ive created the script where it runs:
Code:
ps -eo pri,pid,user,nice,pcpu,comm  | awk '{if($5 >= 2)print $0}' >> /export/home/tjmoore/file2 2>/dev/null

I would then run a mail program to email it to me, This all works fine however I would like to format how it is displayed when it comes through on email,

This is currenlty what Im getting:
Code:
PRI   PID     USER    NICE    %CPU    COMMAND
 50 13109     root 20  3.0 _progres
  0  9838     root 20 10.8 _progres
 59  5790     root 20  4.1 _progres

Its looking a bit messy, can anyone help?

Last edited by Scott; 07-30-2012 at 10:43 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting the output

Hi all, Have the following code(1) producing the results(2 & 3). Would like to know if there is a way to format the two reports created in a similar fashion. IE - The first is formatted nicely as a result of the echo "$xmpbdate $xavgs" >> $xmpbrpt However when I attempt to do the same on... (7 Replies)
Discussion started by: Cameron
7 Replies

2. Shell Programming and Scripting

Formatting output

Hi, I am new to shell scripting, I ahve written a shell script which would extract me data, but my problem is I want to add a column name to my output. Using grep and sed I am getting my data from the input file. Sample data name : eric name : tom name : sean My output using grep and sed... (3 Replies)
Discussion started by: illur81
3 Replies

3. Shell Programming and Scripting

formatting the output

Is it possible to convert the attached file to the format mentioned. Here for a particular job the table name and the corresponding instance name from one test run "X" is compared with the table name and the instance name from the second test run "Y" for output rows,affected rows,applied... (1 Reply)
Discussion started by: ragavhere
1 Replies

4. Shell Programming and Scripting

Formatting ls output

I am using find and ls to search for "warez" files on my server. find /home/ -regex ".*\.\(avi\|mp3\|mpeg\|mpg\|iso\)" -print0 | xargs -0 ls -oh This command produces this: -rw-r--r-- 1 1000 3.2M Feb 18 2009 /home/user/public_html/lupus.mp3 I want to only get this 3.2M... (4 Replies)
Discussion started by: bonrad
4 Replies

5. Shell Programming and Scripting

formatting output

my script is as follows cnt=`ps -ef |grep pmon|grep -v grep|awk 'END {{print NR}}'` cnt2=`ps -ef |grep tns|grep -v grep|awk 'END {{print NR}}'` if then if then rman target/ catalog recdb/recdb@recdb cmdfile report_need_backup.sql > report_need_backup.txt ... (1 Reply)
Discussion started by: swkambli
1 Replies

6. Shell Programming and Scripting

Output formatting

I have input file in this way John 1234 BASIC 26000 John 1234 ALLOWC 01550 John 1234 INCER 01700 John 1234 REL 20000 Debi 2345 BASIC 29000 Debi 2345 ALLOWC 01600 Debi 2345 INCR 01900 Debi 2345 REL ... (8 Replies)
Discussion started by: vakharia Mahesh
8 Replies

7. Shell Programming and Scripting

Output formatting .

below is a CPU utilization Log for ABC server. However for every 15 minutes it generates 3 CPU values(with interval of 2 sec). Host CPU CPUtotal CPU% time ABC 101.1 2 50.55 14 : 15 ABC 100.5 2 50.25 14 : 15 ABC 100.2 2 50.1 14 : 15 ABC 100.9 2 50.45 14 : 30 ABC 100.5 2 50.25 14 : 30 ABC... (5 Replies)
Discussion started by: pinga123
5 Replies

8. Shell Programming and Scripting

sql select command output formatting in shell script

Hi, I need to connect to the database and retrieve two variables from the database and store them in a variable,out of these two variables I need to get lastdigit appended to the variable 1 retrieved and variable 2 with out any modification in short select var,data from usage; o/p=... (1 Reply)
Discussion started by: rkrish
1 Replies

9. Shell Programming and Scripting

Formatting the output

Hi, I have a file which contents entries in this form. Only in /data4/temp abc.000001 Only in /data4/temp abc.000003 Only in /data4/temp abc.000012 Only in /data4/temp abc.000120 Only in /data4/temp abc.000133 Only in /data4/temp abc.001444 i want to read line by line and format... (2 Replies)
Discussion started by: arijitsaha
2 Replies

10. Shell Programming and Scripting

Output formatting

Hi , can anyone help me in this Input file Name= XYZ Company= ALPHA City= Stockhomn Equipment=computer Country=Sweden Name=MNC Company=Beta City=Kaulampur Equipment=computer Country=Malaysia Name=JVC Company=gamma City=Kiruna (3 Replies)
Discussion started by: swets
3 Replies
CheckUser(3pm)						User Contributed Perl Documentation					    CheckUser(3pm)

NAME
Mail::CheckUser - check email addresses for validity SYNOPSIS
use Mail::CheckUser qw(check_email); my $ok = check_email($email_addr); use Mail::CheckUser qw(:constants check_email last_check) my $ok = check_email($email_addr); print "DNS timeout " if last_check()->{code} == CU_DNS_TIMEOUT; use Mail::CheckUser; my $res = Mail::CheckUser::check_email($email_addr); DESCRIPTION
This Perl module provides routines for checking validity of email address. It makes several checks: 1. It checks the syntax of an email address. 2. It checks if there any MX records or A records for the domain part of the email address. 3. It tries to connect to an email server directly via SMTP to check if mailbox is valid. Old versions of this module performed this check via the VRFY command. Now the module uses another check; it uses a combination of MAIL and RCPT commands which simulates sending an email. It can detect bad mailboxes in many cases. If is possible to turn off some or all networking checks (items 2 and 3). See "GLOBAL VARIABLES". This module was designed with CGIs (or any other dynamic Web content programmed with Perl) in mind. Usually it is required to quickly check e-mail addresses in forms. If the check can't be finished in reasonable time, the e-mail address should be treated as valid. This is the default policy. By default if a timeout happens the result of the check is treated as positive. This behavior can be overridden - see "GLOBAL VARIABLES". IMPORTANT WARNING
In many cases there is no way to detect the validity of email addresses with network checks. For example, non-monolithic mail servers (such as Postfix and qmail) often report that a user exists even if it is not so. This is because in cases where the work of the server is split among many components, the SMTP server may not know how to check for the existence of a particular user. Systems like these will reject mail to unknown users, but they do so after the SMTP conversation. In cases like these, the only absolutely sure way to determine whether or not a user exists is to actually send a mail and wait to see if a bounce messages comes back. Obviously, this is not a workable strategy for this module. Does it mean that the network checks in this module are useless? No. For one thing, just the DNS checks go a long way towards weeding out mistyped domain parts. Also, there are still many SMTP servers that will reject a bad address during the SMTP conversation. Because of this, it's still a useful part of checking for a valid email address. And this module was designed such that if there is exists possibility (however small) that the email address is valid, it will be treated as valid by this module. Another warning is about $Mail::CheckUser::Treat_Timeout_As_Fail global variable. Use it carefully - if it is set to true then some valid email addresses can be treated as bad simply because an SMTP or DNS server responds slowly. Another warning is about $Mail::CheckUser::Treat_Full_As_Fail global variable. Use it carefully - if it is set to true then some valid email addresses can be treated as bad simply because their mailbox happens to be temporarily full. EXAMPLE
This simple script checks if email address "blabla@foo.bar" is valid. use Mail::CheckUser qw(check_email last_check); my $email = 'blabla@foo.bar'; if(check_email($email)) { print "E-mail address <$email> is OK "; } else { print "E-mail address <$email> isn't valid: ", last_check()->{reason}, " "; } SUBROUTINES
$ok = check_email($email) Validates email address $email. Return true if email address is valid and false otherwise. $res = last_check() Returns detailed result of last check made with "check_email" as hash reference: { ok => OK, code => CODE, reason => REASON } OK True if last checked email address is valid. False otherwise. CODE A number which describes result of last check. See "CONSTANTS". REASON A string which describes result of last check. CONSTANTS
Constants used by "last_check" to describe result of last check can be exported with use Mail::CheckUser qw(:constants) List of all defined constants: CU_OK Check is successful. CU_BAD_SYNTAX Bad syntax of email address. CU_UNKNOWN_DOMAIN Mail domain mentioned in email address is unknown. CU_DNS_TIMEOUT Timeout has happen during DNS checks. CU_UNKNOWN_USER User is unknown on SMTP server. CU_SMTP_TIMEOUT Timeout has happen during SMTP checks. CU_SMTP_UNREACHABLE All SMTP servers for mail domain were found unreachable during SMTP checks. CU_MAILBOX_FULL Mailbox is temporarily full but probably a valid username. GLOBAL VARIABLES
It is possible to configure "check_email" using the global variables listed below. $Mail::CheckUser::Skip_Network_Checks If true then do only syntax checks. By default it is false. $Mail::CheckUser::Skip_SMTP_Checks If it is true then do not try to connect to mail server to check if a user exists. If this is true, and $Mail::CheckUser::Skip_Network_Checks is false, only syntax and DNS checks are performed. By default it is false. $Mail::CheckUser::Skip_SYN By default Net::Ping is used to determine remote reachability of SMTP servers before doing SMTP checks. Setting this to true skips this check. By default it is false. $Mail::CheckUser::Sender_Addr MAIL/RCPT check needs an email address to use as the 'From' address when performing its checks. The default value is "check@user.com". $Mail::CheckUser::Helo_Domain Sender domain used in HELO SMTP command. If undef Net::SMTP is allowed to use its default value. By default it is undef. Mail::CheckUser::Timeout Timeout in seconds for network checks. By default it is 60. $Mail::CheckUser::Treat_Timeout_As_Fail If it is true "Mail::CheckUser" treats checks that time out as failed. By default it is false. $Mail::CheckUser::Treat_Full_As_Fail If it is true "Mail::CheckUser" treats error "552 mailbox full" as an invalid email and sets CU_MAILBOX_FULL. By default it is false. $Mail::CheckUser::Net_DNS_Resolver Override with customized Net::DNS::Resolver object. This is used to lookup MX and A records for the email domain when network checks are enabled. If undef, Net::DNS::Resolver->new will be used. The default value is undef. $Mail::CheckUser::Debug If it is true then enable debug output on "STDERR". By default it is false. AUTHORS
Ilya Martynov ilya@martynov.org Rob Brown bbb@cpan.org Module maintained at Source Forge ( http://sourceforge.net/projects/mail-checkuser/ ). COPYRIGHT
Copyright (c) 1999-2003 by Ilya Martynov. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. $Id: CheckUser.pm,v 1.46 2003/09/18 23:51:36 hookbot Exp $ SEE ALSO
perl(1). perl v5.14.2 2012-03-10 CheckUser(3pm)
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy