awk or sed script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk or sed script
# 1  
Old 01-10-2007
awk or sed script

hi guys,

perhaps you can help me again

I have a file generated with the AIX-tool lparstat the looks like this:
Code:
%user  %sys  %wait  %idle physc %entc  lbusy   app  vcsw phint
-----  ----  -----  ----- ----- ----- ------   ---  ---- -----
 21.8   8.8    1.8   67.6  0.17  34.1    9.4  7.22   668    14
 24.3  10.7    1.9   63.1  0.20  39.3   10.9  7.57   716    18
 18.9   9.0    0.7   71.4  0.16  31.4    9.3  7.31   665    16
 17.8  10.7    0.5   71.0  0.16  32.3    9.2  8.10   674    15
 16.3  10.1    0.5   73.1  0.15  30.2    8.3  7.78   671    15
 25.4  11.9    1.6   61.1  0.21  41.7   11.9  8.46   649    17
 21.7  10.3    0.9   67.1  0.18  35.4   10.9  7.50   647    21
 12.6   8.8    0.7   77.9  0.12  24.5    6.6  7.37   635    12
 15.3   9.3    1.1   74.2  0.14  28.1    7.8  7.95   665    12
 21.4  10.9    1.6   66.1  0.18  36.3   10.1  8.23   686    16
 21.9  11.4    4.7   62.0  0.19  37.6   10.9  8.52   714    15
 16.4   9.4    1.6   72.6  0.15  29.3    8.5  9.00   643    10
 27.9   9.7    3.1   59.3  0.21  42.4   11.6  9.85   713    12
 24.4  10.9    1.5   63.2  0.20  39.6   11.5  9.69   697    13
 18.9  10.0    1.5   69.5  0.16  32.9    8.9  9.07   668    10
 16.8  10.1    1.4   71.7  0.15  30.7    8.7  9.49   674     7
 27.0  10.5    1.0   61.5  0.21  41.7   11.8  9.15   688    12
 44.1   9.5    0.5   45.9  0.29  57.9   16.8 10.25   628    10
 22.1  10.7    0.7   66.5  0.18  36.5   10.7  8.17   670    15
 13.3   9.0    0.5   77.1  0.13  25.6    6.9  8.36   637     9
 14.7  10.0    0.4   74.9  0.14  28.2    7.7  8.33   646    14
%user  %sys  %wait  %idle physc %entc  lbusy   app  vcsw phint
-----  ----  -----  ----- ----- ----- ------   ---  ---- -----
59395921418.6 112289.9    0.4   77.8  0.12  25.0    7.2  9.65   621    15
16.8  10.1    1.4   71.7  0.15  30.7    8.7  9.49   674     7
 27.0  10.5    1.0   61.5  0.21  41.7   11.8  9.15   688    12

and so on

sometimes I get big values as you can see, our tivoli guys use this file for performance monitoring with a simple tail -1 every five minutes

the header lines are not the problem, but I need a (sed?) script the checks if one value has more then say 6 digits, and modifies it to a valid value like
10.0 or any value that fits in the schema xx.x or xx.xx

or perhaps you have another idea how to solve this problem?

this is just a workaround


thanks in advance

funksen

Last edited by Perderabo; 01-10-2007 at 01:26 PM.. Reason: add code tags for readability
# 2  
Old 01-10-2007
With tools like this, the errors tend to occur on the first output line and once in a blue moon otherwise. You might want to consider deleting these lines rather than making something up.

These tools read kernel counters, each second or so. They subtract the current value from the previous value to see what happened during the past second. But the first time, the previous counters are all zero, so the first line is often silly. Sometimes a counter wraps around back to zero also producing garbage results, although a very smart tool could actually cope with that.
# 3  
Old 01-10-2007
hm my post has been lost Smilie, I repeat it:


a collegue told me now that this may happen when the system dynamically allocates processor resources from the pool in the measure-periode (IBM p590)

but your explaination also sounds possible, I'll modify their great tail -1 script Smilie
I'll just delete this lines and the header

is grep able to find files greater than a value? or longer then a number of digits?

I know how to make this the long way with if, but you always surprised me with a short cryptical command ^^

PS: tivoli system management unfortunately isn't a smart tool, or perhaps they did a bad job in implementing it, just problems, ~20 servers (win,lin and unix) is too much for just a monitoring tool that calls perl scripts with java ^^
I prefer big brother, just needs one machine to work

edit: the 20 servers are just for tivoli to work, not our server farm, my english is not the best ^^

Last edited by funksen; 01-10-2007 at 03:18 PM..
# 4  
Old 01-11-2007
so finally this is my noob script, just for thread completion


Code:
VAL=$(tail -1 /tmp/apvcpu_lparstat_288.log | awk '{print $1}')
if [[ $VAL -ge 101 ]] ; then grep -v "$VAL" /tmp/apvcpu_lparstat_288.log | grep -v "\-\-\-\-" | grep -v "wait" | tail -1 ; else
tail -1 /tmp/apvcpu_lparstat_288.log; fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed or awk script problem

Hi All I am having a file as shown below File1# modyle 1 { test jsj hhsjh 13e3 jsjjs } memP(dbg_trace) { ajjs jsjs jsjs Test(claer) { jsjs (7 Replies)
Discussion started by: kshitij
7 Replies

2. UNIX for Dummies Questions & Answers

Use of Variables in a sed/awk script

Hi, After looking at the differents post on this forum, I am convinced that I will benefit from the experience of advanced Unix user on some script I have already done for an aeronautical study. Here is one of them : Step 1 : sed -e "s/??/00/g" Base_Awk.txt > Awk_Cut_00.txt4; sed... (11 Replies)
Discussion started by: Marc_Camoc
11 Replies

3. Shell Programming and Scripting

awk or sed script to remove strings

Below am trying to separate FA-7A:1, In output file it should display 7A 1 Command am using Gives same output as below format: 22B7 10000000c9720873 0 22B7 10000000c95d5d8b 0 22BB 10000000c97843a2 0 22BB 10000000c975adbd 0 Not showing FA ports as required format... (5 Replies)
Discussion started by: aix_admin_007
5 Replies

4. Shell Programming and Scripting

help with writing a awk/sed script

Hi, I thought I am getting pretty good with sed and awk, but now I dont have a way out of this question. I have a table 0.5 16 1.3 14 0.25 15 0.85 16 I want to make a column 3 which contains values that are (corresponding $2 value/sum of all $2). Please help me out here. Thanks. (6 Replies)
Discussion started by: jamie_123
6 Replies

5. Programming

Shell script using sed or awk

Hi, I want to read a file from the command line and remove all the spaces, tabs in it, replacing it with comma(,), and write it to a new file. can you help me out with this scenario. (1 Reply)
Discussion started by: sudhanshu12788
1 Replies

6. Shell Programming and Scripting

XML- Sed || Awk Bash script... Help!

Hi ! I'm working into my first bash script to make some xml modification and it's going to make me crazy lol .. so I decide to try into this forum to take some ideas from people that really know about this! This is my situation I've and xml file with a lots of positional values with another tags... (9 Replies)
Discussion started by: juampal
9 Replies

7. Shell Programming and Scripting

AWK/SED script help

Hi, was hoping someone may be able to help me with a script solution to move one line to another line from my log file: My log file currently looks like this: 01:21:12:383 Request 01:21:12:639 Response 01:21:12:386 Request 01:21:12:639 Response 01:21:12:389 Request 01:21:12:640 Response... (8 Replies)
Discussion started by: jimbobla
8 Replies

8. Shell Programming and Scripting

sed or an awk script should help

num desc ind code 11 hi,feather y food 121 edible,oil y food 100 meal-pack y food 010 health,prod 120 ... (5 Replies)
Discussion started by: thumsup9
5 Replies

9. UNIX for Dummies Questions & Answers

Script Help (sed awk)

Hi there I'am new here and could use some help. I probably haven't used the correct terms but have tried my best. I work for a newspaper who run a database for their classifieds. All the adds are input on an atex system and then each day dumped into three files. (*.eps *.srt *.prn) I'am trying... (1 Reply)
Discussion started by: StiCKmaN
1 Replies

10. UNIX for Dummies Questions & Answers

sed/awk script

I have a file with three fields, where the first two fields are of fixed length, left justified, and right padded with spaces. The third field is truncated to the length of the data (max length 5), and possibly contains a single letter. Each field is separated by an additional space. How can I... (1 Reply)
Discussion started by: Duckman
1 Replies
Login or Register to Ask a Question