Formatted TOP command output in file | Unix Linux Forums | HP-UX

  Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Formatted TOP command output in file

HP-UX


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-25-2013
lravip123 lravip123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 25 January 2013, 2:11 AM EST
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Formatted TOP command output in file

Hi All,

I want generate HP-UX overall system performance report.

I tried executing top command and write that out put to file. but am not able to view the report in proper format.

I can see report like below in file but i can see properly in terminal.

Please suggest how can i get proper format of out as it shown in the terminal.

[?25h[m[H[2J7[1;44r8System: ussbcap1[38CThu Jan 24 23:40:17 2013[BLoad averages: 4.50, 5.64, 6.52[B549 processes: 429 sleeping, 93 running, 27 zombies[BCpu states:[BCPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS[B 0 4.51 73.3% 0.0% 26.7% 0.0% 0.0% 0.0% 0.0% 0.0%[B 1 4.49 93.1% 0.0% 6.9% 0.0% 0.0% 0.0% 0.0% 0.0%[B--- ---- ----- ----- ----- ----- ----- ----- ----- -----[Bavg 4.50 83.2% 0.0% 16.8% 0.0% 0.0% 0.0% 0.0% 0.0%[2BMemory: 6586084K (6364224K) real, 8876320K (8507888K) virtual, 727260K free Page# 1/18[2BCPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND[B 1 ? 6922 mqm[6C234 24 15748K 2040K run 66562:13 40.53 40.46 autocons[B 1 ? 2372 root[5C152 20 15336K 1884K run 26462:41 25.87 25.83 dmisp[B 0 ? 5531 cyclone 152 20 206M 49916K run 76304:32 20.97 20.93 java[B 1 ? 26049 cyclone 152 20 1292M 1098M run 323:13 17.74 17.71 java[B 1 ? 20174 cyclone 152 20 1194M 1012M run[5C94:11 5.34 5.33 java[B 1 ? 3415 root[5C-16 20 45520K 8528K run 7149:30 2.12 2.12 midaemon[B 1 ? 8185 root[5C158 20 38164K 36416K sleep 0:00 4.36 1.29 sh[B 0 ? 8178 mqm[6C183 20 12900K 1388K run[6C0:00 3.70 1.22 auto_remote[B 0 ? 8192 mqm[6C183 20 12900K 1388K run[6C0:00 4.71 1.22 auto_remote[B 1 ? 37

Last edited by lravip123; 01-25-2013 at 02:59 AM..
Sponsored Links
    #2  
Old 01-25-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 25 November 2014, 12:59 PM EST
Location: Aachen, Germany
Posts: 4,702
Thanks: 80
Thanked 1,167 Times in 1,097 Posts
PLEASE use code tags as demanded!
Reading man pages is highly educational and sometimes really helps. cf. man top :
Quote:
-b : Batch-mode operation
Starts top in 'Batch' mode, which could be useful for sending output from top to other programs or to a file.
The messy stuff in your sample is terminal control chars, usually introduced by an <ESC> char, followed by the terminal command (position, colour, ...). More info: man console_codes You can try to remove them with a script for awk, sed, perl, ...

Last edited by RudiC; 01-25-2013 at 05:28 AM..
Sponsored Links
    #3  
Old 01-25-2013
Peasant's Avatar
Peasant Peasant is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 25 November 2014, 10:17 AM EST
Posts: 677
Thanks: 18
Thanked 153 Times in 149 Posts
Here is what i'm using on my HPUX boxes for basic CPU and DISK monitoring from cron in this manner :

Code:
00,5,10,15,20,25,30,35,40,45,50,55      *    *    *    *    /bin/awk -f /root/monitork /root/mon.data > /dev/null 2>&1

It's not perfect, but suits my needs


Code:
BEGIN {
cpu=95
stat="1 100"
sms="mailx -s \"`hostname`\" smsaddress@domain.com"
ml="mailx -s \"`hostname` Overload\" mail.address@domain.com"
system("bdf > mon.data")
system("sar -u "stat" >> mon.data")
close("bdf >> mon.data")
close("sar -u "stat" >> mon.data")
}
match($0,/Average/) {
        if ( $2 > cpu ) {
        loadmon="SAR: CPU is above "cpu"% on "$2"% for "substr(stat,3,5) " seconds"
        }
}
match($0,/9[4-9]% \//) {
        diskmon="Mountpoints ALARM "$NF " is on "$(NF -1)
}
match($0,/100% \//) {
        print $NF $(NF -1)
        full="Mountpoints ALARM "$NF " is full"
}
END {
        if ( loadmon != "" ) {
                print loadmon | ml
                }
        if ( diskmon != "" || full != "" ) {
                print diskmon "\n" full | sms
                }
}

Hope that helps.
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
Conflicts in the output of TOP command anand2308 UNIX for Advanced & Expert Users 2 01-04-2013 12:00 PM
String searching and output to a file in a formatted text cuji Shell Programming and Scripting 3 07-20-2010 04:03 AM
Need help with shell script - output of top command needyourhelp10 Shell Programming and Scripting 5 07-13-2010 02:27 PM
Extract header from top command output meharo Shell Programming and Scripting 3 01-14-2010 12:45 PM
mailing customized and formatted ls -lt command output mbak Shell Programming and Scripting 3 10-11-2008 01:07 PM



All times are GMT -4. The time now is 08:13 PM.