Sponsored Content
Top Forums Shell Programming and Scripting Help with Display Shell Script Post 302639741 by kunwar on Sunday 13th of May 2012 02:46:25 AM
Old 05-13-2012
thanks you guys...It helped..Below is o/p:

Code:
> perl -nle 'if($.>2) { if (/(^\d{2}:\d{2}:\d{2})/) { $time=$1;print $_;}else{s/^\s+/$time   /;print $_;}}' tt3

01:22:42   device   %busy   avque   r+w/s  blks/s  avwait  avserv
01:27:59   disk30    8.79   13.72      26     427   36.47   10.09
01:27:59   disk50   10.48   12.87      29     449   36.78   10.74
01:27:59   disk745    0.00    0.50       0       0    0.01    0.41
01:27:59   disk746    0.05    0.50       0       0    0.00    8.33
01:27:59   disk747    0.03    0.50       0       0    0.01    6.00
01:27:59   disk748    0.07    0.50       0       0    0.00   11.09


> awk '$1 ~ /[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ { a=$1"\t" }  { print ( $1 != a ) ? a $0 : $0 }'  tt3

HP-UX dhpcdbe1 B.11.31 U ia64    05/09/12

01:22:42        01:22:42   device   %busy   avque   r+w/s  blks/s  avwait  avserv
01:27:59        01:27:59   disk30    8.79   13.72      26     427   36.47   10.09
01:27:59                   disk50   10.48   12.87      29     449   36.78   10.74
01:27:59                  disk745    0.00    0.50       0       0    0.01    0.41
01:27:59                  disk746    0.05    0.50       0       0    0.00    8.33
01:27:59                  disk747    0.03    0.50       0       0    0.01    6.00
01:27:59                  disk748    0.07    0.50       0       0    0.00   11.09

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell Script Display?

I remember learning that there is a way to make a shell script display the script itself to standard output while the script is being executed but I can't find how to do that. Any pointers? (2 Replies)
Discussion started by: wmosley2
2 Replies

2. Shell Programming and Scripting

shell script that would display installing.... when installign something

Hi, I am developing a shell script that would install a software when it is run. I want to displaying Installing <so and so>........ when it is actually installing it. I want it to be dynamic, in the sense, I want the dots after installing grow and drop. Is there a way we can do it.... (1 Reply)
Discussion started by: eamani_sun
1 Replies

3. Shell Programming and Scripting

shell script that adds two integers and display answer on screen

please help shell script that adds two intergers and display answer on screen (1 Reply)
Discussion started by: wanyac2
1 Replies

4. Shell Programming and Scripting

Shell script to display top 5 process (per cpu consumption)

Hello, I have to create shell script being myself real novice in scripting... I was looking on the Internet for some script examples, but I don't have the basic understanding of the shell. I was trying to do something with “ps” command without success. For exemple total number of... (2 Replies)
Discussion started by: mr_awd
2 Replies

5. UNIX Desktop Questions & Answers

Shell script to display user logged in within given time

how can i know which users have logged in at specified given start and end time in 24 hour format? (3 Replies)
Discussion started by: meherzad4u
3 Replies

6. Shell Programming and Scripting

How to write a shell script to display files in single path?

Hello friends, I am a script which dispalys a multiple files with their contents. for exm: suppose two file test1.txt and test2.txt. when I run my script it have to display the below O/P. test1.txt -rw-r----- 1 sranga staff 91 Sep 23 02:18 calc.sh -rw-r----- 1 sranga ... (2 Replies)
Discussion started by: sivaranga001
2 Replies

7. Shell Programming and Scripting

Display both html and plain text in email in shell script

Hi, I want to display both html and plain in email in my script. i tried the below code code: export MAILTO="ssi@a.com" export CONTENT1="$htmlfile" export CONTENT2="$plainfile" export SUBJECT="INFO " export MAILFROM="si@a.com" ( echo "Subject: $SUBJECT" echo "MIME-Version:... (4 Replies)
Discussion started by: sreelu
4 Replies

8. Shell Programming and Scripting

How to display a counter in shell script?

Hi, I am writing a script which processes large number of files in a directory. I wanto display a counter which increment after processing each file. I am processing each file in a for loop. If I echo a variable with its value increasing with each file, I will get around 5000 lines as output.... (10 Replies)
Discussion started by: jaiseaugustine
10 Replies

9. Shell Programming and Scripting

Help with Display Shell Script for date

hi friends, I am working on extracting data from sar logs for analysis. What is want to do is insert the date. The way i am doing is incrementing the date if i see the hour gets reduced (i.e. from 23 hours to 00 hours). Somehow the script which i have made is not able to handle the logic w.r.t... (3 Replies)
Discussion started by: kunwar
3 Replies

10. Shell Programming and Scripting

Display calendar in correct format using shell script

Hi All, I'm trying to print calendar using shell script and i'm able to print it. But the format is not good. Here is the script. #!/bin/bash echo $(date) echo "Hello $USER" echo Hostname $(hostname) echo Working in $(pwd) echo Here is this month calender echo $(cal) $ sh first.sh... (7 Replies)
Discussion started by: chandrakanth
7 Replies
sar(1)								   User Commands							    sar(1)

NAME
sar - system activity reporter SYNOPSIS
sar [-aAbcdgkmpqruvwy] [-o filename] t [n] sar [-aAbcdgkmpqruvwy] [-e time] [-f filename] [-i sec] [-s time] DESCRIPTION
In the first instance, the sar utility samples cumulative activity counters in the operating system at n intervals of t seconds, where t should be 5 or greater. If t is specified with more than one option, all headers are printed together and the output can be difficult to read. (If the sampling interval is less than 5, the activity of sar itself can affect the sample.) If the -o option is specified, it saves the samples in filename in binary format. The default value of n is 1. In the second instance, no sampling interval is specified. sar extracts data from a previously recorded filename, either the one specified by the -f option or, by default, the standard system activity daily data file /var/adm/sa/sadd for the current day dd. The starting and ending times of the report can be bounded using the -e and -s arguments with time specified in the form hh[:mm[:ss]]. The -i option selects records at sec second intervals. Otherwise, all intervals found in the data file are reported. OPTIONS
The following options modify the subsets of information reported by sar. -a Reports use of file access system routines: iget/s, namei/s, dirblk/s -A Reports all data. Equivalent to -abcdgkmpqruvwy. -b Reports buffer activity: bread/s, bwrit/s transfers per second of data between system buffers and disk or other block devices. lread/s, lwrit/s accesses of system buffers. %rcache, %wcache cache hit ratios, that is, (1-bread/lread) as a percentage. pread/s, pwrit/s transfers using raw (physical) device mechanism. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -c Reports system calls: scall/s system calls of all types. sread/s, swrit/s, fork/s, exec/s specific system calls. rchar/s, wchar/s characters transferred by read and write system calls. No incoming or outgoing exec(2) and fork(2) calls are reported. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -d Reports activity for each block device (for example, disk or tape drive) with the exception of XDC disks and tape drives. When data is displayed, the device specification dsk- is generally used to represent a disk drive. The device specification used to represent a tape drive is machine dependent. The activity data reported is: %busy, avque portion of time device was busy servicing a transfer request, average number of requests outstanding during that time. read/s, write/s, blks/s number of read/write transfers from or to device, number of bytes transferred in 512-byte units. avwait average wait time in milliseconds. avserv average service time in milliseconds. For more general system statistics, use iostat(1M), sar(1M), or vmstat(1M). See System Administration Guide: Basic Administration for naming conventions for disks. -e time Selects data up to time. Default is 18:00. -f filename Uses filename as the data source for sar. Default is the current daily data file /var/adm/sa/sadd. -g Reports paging activities: pgout/s page-out requests per second. ppgout/s pages paged-out per second. pgfree/s pages per second placed on the free list by the page stealing daemon. pgscan/s pages per second scanned by the page stealing daemon. %ufs_ipf the percentage of UFS inodes taken off the freelist by iget which had reusable pages associated with them. These pages are flushed and cannot be reclaimed by processes. Thus, this is the percentage of igets with page flushes. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -i sec Selects data at intervals as close as possible to sec seconds. -k Reports kernel memory allocation (KMA) activities: sml_mem, alloc, fail information about the memory pool reserving and allocating space for small requests: the amount of memory in bytes KMA has for the small pool, the number of bytes allocated to satisfy requests for small amounts of memory, and the number of requests for small amounts of memory that were not satisfied (failed). lg_mem, alloc, fail information for the large memory pool (analogous to the information for the small memory pool). ovsz_alloc, fail the amount of memory allocated for oversize requests and the number of oversize requests which could not be satisfied (because oversized memory is allocated dynamically, there is not a pool). -m Reports message and semaphore activities: msg/s, sema/s primitives per second. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -o filename Saves samples in file, filename, in binary format. -p Reports paging activities: atch/s page faults per second that are satisfied by reclaiming a page currently in memory (attaches per second). pgin/s page-in requests per second. ppgin/s pages paged-in per second. pflt/s page faults from protection errors per second (illegal access to page) or "copy-on-writes". vflt/s address translation page faults per second (valid page not in memory). slock/s faults per second caused by software lock requests requiring physical I/O. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -q Reports average queue length while occupied, and percent of time occupied: runq-sz, %runocc Run queue of kernel threads in memory and runnable swpq-sz, %swpocc Swap queue of processes -r Reports unused memory pages and disk blocks: freemem average pages available to user processes. freeswap disk blocks available for page swapping. -s time Selects data later than time in the form hh[:mm]. Default is 08:00. -u Reports CPU utilization (the default): %usr, %sys, %wio, %idle portion of time running in user mode, running in system mode, idle with some process waiting for block I/O, and other- wise idle. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -v Reports status of process, i-node, file tables: proc-sz, inod-sz, file-sz, lock-sz entries/size for each table, evaluated once at sampling point. ov overflows that occur between sampling points for each table. -w Reports system swapping and switching activity: swpin/s, swpot/s, bswin/s, bswot/s number of transfers and number of 512-byte units transferred for swapins and swapouts (including initial loading of some programs). pswch/s process switches. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. -y Reports TTY device activity: rawch/s, canch/s, outch/s input character rate, input character rate processed by canon, output character rate. rcvin/s, xmtin/s, mdmin/s receive, transmit and modem interrupt rates. If run in a non-global zone and the pools facility is active, these values reflect activity on the processors of the pro- cessor set of the pool to which the zone is bound. EXAMPLES
Example 1: Viewing System Activity The following example displays today's CPU activity so far: example% sar Example 2: Watching System Activity Evolve To watch CPU activity evolve for 10 minutes and save data: example% sar -o temp 60 10 Example 3: Reviewing Disk and Tape Activity To later review disk and tape activity from that period: example% sar -d -f temp FILES
/var/adm/sa/sadd daily data file, where dd are digits representing the day of the month ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWaccu | +-----------------------------+-----------------------------+ SEE ALSO
sag(1), iostat(1M), sar(1M), vmstat(1M), exec(2), fork(2), attributes(5) System Administration Guide: Basic Administration NOTES
The sum of CPU utilization might vary slightly from 100 because of rounding errors in the production of a percentage figure. SunOS 5.10 24 Jul 2004 sar(1)
All times are GMT -4. The time now is 03:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy