How to output the prstat into table and send through email?


 
Thread Tools Search this Thread
Operating Systems Solaris How to output the prstat into table and send through email?
# 8  
Old 03-02-2015
Please show us the output you got from RudiC's script when you ran it on your system (using CODE tags).
# 9  
Old 03-02-2015
Here is a slightly modified version of RudiC's script:

Code:
prstat 5 1|nawk 'NR==1  {COLS=NF; for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }
$9 >= 0.1 { for (i=1; i<COLS; i++) printf("|%8s",$i);printf("|%20s|\n",$i)}
END {for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }'

and its output:

Code:
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+
|     PID|USERNAME|    SIZE|     RSS|   STATE|     PRI|    NICE|    TIME|     CPU|        PROCESS/NLWP|
|       5|    root|      0K|      0K|   sleep|      99|     -20| 2:10:13|    0.3%|     zpool-rpool1/37|
|   10204|jlliagre|   9184K|   3128K|    cpu0|      49|       0| 0:00:00|    0.2%|            prstat/1|
|    9978|jlliagre|     10M|   3088K|   sleep|      49|       0| 0:00:00|    0.1%|             ksh93/1|
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+

Note that I set the threshold to 0.1 percent to test it.

Note also that this command is unlikely to help identifying what processes are using 75% of the swap space. You should monitor different columns and commands as stated in https://www.unix.com/302934556-post9.html

Last edited by jlliagre; 03-02-2015 at 10:11 AM..
# 10  
Old 03-07-2015
Quote:
Originally Posted by jlliagre
Here is a slightly modified version of RudiC's script:

Code:
prstat 5 1|nawk 'NR==1  {COLS=NF; for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }
$9 >= 0.1 { for (i=1; i<COLS; i++) printf("|%8s",$i);printf("|%20s|\n",$i)}
END {for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }'

and its output:

Code:
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+
|     PID|USERNAME|    SIZE|     RSS|   STATE|     PRI|    NICE|    TIME|     CPU|        PROCESS/NLWP|
|       5|    root|      0K|      0K|   sleep|      99|     -20| 2:10:13|    0.3%|     zpool-rpool1/37|
|   10204|jlliagre|   9184K|   3128K|    cpu0|      49|       0| 0:00:00|    0.2%|            prstat/1|
|    9978|jlliagre|     10M|   3088K|   sleep|      49|       0| 0:00:00|    0.1%|             ksh93/1|
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+

Note that I set the threshold to 0.1 percent to test it.

Note also that this command is unlikely to help identifying what processes are using 75% of the swap space. You should monitor different columns and commands as stated in https://www.unix.com/302934556-post9.html
Hi Jiliagre,
Thanks for the reply.
When i send the output to the email, the border is not consistent as below.
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+
| PID|USERNAME| SIZE| RSS| STATE| PRI| NICE| TIME| CPU| PROCESS/NLWP|
| 13434| oracle| 12G| 10G| sleep| 9| 0| 0:00:06| 2.6%| oracle/1|
| 13452| oracle| 12G| 10G| sleep| 1| 0| 0:00:05| 2.4%| oracle/1|
| 466| oracle| 3279M| 94M| sleep| 24| 0|1072:17:4| 2.2%| tnslsnr/1|
| 5529| oracle| 2104K| 1472K| sleep| 59| 2| 0:03:59| 1.8%| tar/1|
| 5789| oracle| 12G| 10G| sleep| 54| 0| 1:22:10| 0.9%| oracle/17|
| 13422| oracle| 12G| 10G| sleep| 60| 0| 0:00:02| 0.9%| oracle/1|
| 13412|sprdcron| 12G| 10G| sleep| 60| 19| 0:00:01| 0.5%| oracle/1|
| 13216| oracle| 12G| 10G| sleep| 52| 0| 0:00:06| 0.4%| oracle/1|
| 4699| oracle| 12G| 2745M| sleep| 1| 0|373:25:52| 0.4%| oracle/18|
| 1114| root| 98M| 91M| sleep| 59| 0|592:35:53| 0.3%| esd/4|
| 13467| oracle| 12G| 10G| sleep| 60| 0| 0:00:00| 0.3%| oracle/1|
| 13471| oracle| 12G| 10G| sleep| 52| 0| 0:00:00| 0.3%| oracle/1|
| 4697| oracle| 12G| 2738M| sleep| 58| 0|291:53:50| 0.3%| oracle/258|
| 14908| oracle| 12G| 10G| sleep| 52| 0| 0:12:57| 0.3%| oracle/1|
| 1121| oracle| 12G| 10G| sleep| 54| 0|15:31:42| 0.2%| oracle/11|
| Total:| 449|processes,| 1774| lwps,| load|averages:| 2.29,| 2.17,| 2.13|
+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------+


Is that possible to get nicer output Jiliagre?

Last edited by tharmendran; 03-07-2015 at 11:29 AM..
# 11  
Old 03-07-2015
Is that an HTML mail? Then use HMTL table format.
Is that a text mail? Then use a monospace font to print it.
# 12  
Old 03-07-2015
Quote:
Originally Posted by RudiC
Is that an HTML mail? Then use HMTL table format.
Is that a text mail? Then use a monospace font to print it.
Hi RudiC,
Thanks for your reply. I thinkthat is HTML email. So kindly explain how send output to email using HTML table format?
# 13  
Old 03-09-2015
Quote:
Originally Posted by THARMENDRAN
When i send the output to the email, the border is not consistent as below.
How do you send the output to the email?
# 14  
Old 03-10-2015
Quote:
Originally Posted by jlliagre
How do you send the output to the email?
Hi Jlliagre,
Thanks for the reply. I send the output to email like below

Code:
prstat 5 1|nawk 'NR==1  {COLS=NF; for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }
$9 >= 0.1 { for (i=1; i<COLS; i++) printf("|%8s",$i);printf("|%20s|\n",$i)}
END {for (i=1; i<=COLS; i++) printf "+--------"; printf "------------+\n" }'| mailx -s "Testing" xxxxxx@yyyy.com.my

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to read hive table and send email

HI Team, I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body. below script: #!/bin/bash hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Discussion started by: Mi4304
4 Replies

2. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

3. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

4. Shell Programming and Scripting

Parse qshape output and send email alert

Hi I need help to do this. This is the output of qshape: user$ qshape deferred|head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 0 0 0 0 0 0 0 0 0 0 0 T stands for minutes elapsed and TOTAL... (1 Reply)
Discussion started by: zorrox
1 Replies

5. Shell Programming and Scripting

Send email if Output is available

hello can anyone debug these lines cd /usr/local/scripts ./build update ./build versions | grep available if then mail -s "update for server `hostname`" $EMAIL else echo -e "$YELLOW No update $RESET" fi echo "Please press a key - Back to main menu . . ." ; read but... (3 Replies)
Discussion started by: nimafire
3 Replies

6. Shell Programming and Scripting

How to send mails based on email ids residing in table?

Hello Gurus, I have one table which consists of two field:- PROG_NAME EMAIL xxxx email1,email2,email3 yyyy email4,email1,email2 I want to to send mails by using mailx command. But how do I get each and every mail ids from table against... (4 Replies)
Discussion started by: pokhraj_d
4 Replies

7. Shell Programming and Scripting

Send output of a command as an email

Hello Unix Experts! We are on AIX 6.1 TL6 I am trying to develop a script that does the following: It should send the output of "df -g /directory/folder" command as an email to a user(someone@company.com) This is too simple and i can research on how to do it, but it would be great if... (2 Replies)
Discussion started by: atechcorp
2 Replies

8. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

9. Shell Programming and Scripting

send an email of script output

Hi All, I'm trying to send some file which generated by script to my email. when I run the script I'm getting an email. Thats fine. But it seems to be all messed up like below Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA:... (4 Replies)
Discussion started by: s_linux
4 Replies

10. Shell Programming and Scripting

Send one email with output result from 2 commands

Hi, i want to create a script which should do the following: 1) ping the remote servers and email the hosts which are down 2) netstat on port x on 2 server and email the result too. I want both results to be sent in the same email. I have few ideas but i can't finish it. Here... (4 Replies)
Discussion started by: varu0612
4 Replies
Login or Register to Ask a Question