Checking for higher usage and mark it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking for higher usage and mark it
# 1  
Old 06-30-2010
Question Checking for higher usage and mark it

Hi Gurus,

I'm using HPUX B.11.23 U ia64 with sh shell.

Is it possible to insert a word "Warning" in the end of this line if there is high percentage? For example: if the percentage is higher than 80%?

Sample data:
Code:
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84%
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%

Desired output:
Code:
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84%  Warning
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%

Would appreciate for any of your help and advice.

Thank you.


Regards,
Peter
# 2  
Old 06-30-2010
Code:
awk '$9~"(^[8-9])|(^100)"{print $0" Warning";next}1' file


Last edited by bartus11; 06-30-2010 at 01:00 PM..
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 06-30-2010
Hi bartus11,

Thanks for your response.

I've tried your method with more data, but it is not working. The result is not as expected. Please see below.

Sample data (TESTDATA2):
Code:
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84%
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%
/dev/vgsap/ORA2          /oracle/TST/ORA2          28.12 GB    0.02 GB   28.10 GB     8%
/dev/vgsap/ORA3          /oracle/TST/ORA3          28.12 GB    0.02 GB   28.10 GB    30%
/dev/vgsap/ORA4          /oracle/TST/ORA4          28.12 GB    0.02 GB   28.10 GB     1%

Code:
# awk '$9~"(^[8-9])|(^100)"{print $0" Warning";next}1' TESTDATA2
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84% Warning
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%
/dev/vgsap/ORA2          /oracle/TST/ORA2          28.12 GB    0.02 GB   28.10 GB     8% Warning
/dev/vgsap/ORA3          /oracle/TST/ORA3          28.12 GB    0.02 GB   28.10 GB    30%
/dev/vgsap/ORA4          /oracle/TST/ORA4          28.12 GB    0.02 GB   28.10 GB     1%

Please kindly advice.

Thank you.


Regards,
Peter

Last edited by superHonda123; 06-30-2010 at 10:19 PM.. Reason: typo
# 4  
Old 06-30-2010
Hi

Code:
awk '{split($NF,a,"%"); if (a[1]>80) $0=$0 "  Warning";}1' file

Guru.
This User Gave Thanks to guruprasadpr For This Post:
# 5  
Old 06-30-2010
Hi guruprasadpr,

Thanks a lot for your help.

Your method actually is working, however, when I added some header into the file, it's also showing "Warning" comment. What went wrong?

TESTDATA2C:
Code:
Filesystem               Path Location             Size        Size      Size       Used(%) 
--------------------------------------------------------------------------------------------
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84%
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%
/dev/vgsap/ORA2          /oracle/TST/ORA2          28.12 GB    0.02 GB   28.10 GB     8%
/dev/vgsap/ORA3          /oracle/TST/ORA3          28.12 GB    0.02 GB   28.10 GB    30%
/dev/vgsap/ORA4          /oracle/TST/ORA4          28.12 GB    0.02 GB   28.10 GB     1%

Output:
Code:
Filesystem               Path Location             Size        Size      Size       Used(%) Warning
--------------------------------------------------------------------------------------------
/dev/vgsap/TEST1         /oracle/TST/TEST1          9.89 GB    8.37 GB    1.52 GB    84%  Warning
/dev/vgsap/TEST23        /oracle/TST/TEST123        0.48 GB    0.26 GB    0.21 GB    71%
/dev/vgsap/TEST1234      /oracle/TST/TEST1234       0.48 GB    0.26 GB    0.21 GB    54%
/dev/vgsap/ORA           /oracle/TST/ORA           28.12 GB    0.02 GB   28.10 GB     0%
/dev/vgsap/ORA2          /oracle/TST/ORA2          28.12 GB    0.02 GB   28.10 GB     8%
/dev/vgsap/ORA3          /oracle/TST/ORA3          28.12 GB    0.02 GB   28.10 GB    30%
/dev/vgsap/ORA4          /oracle/TST/ORA4          28.12 GB    0.02 GB   28.10 GB     1%

Please kindly advice.

Thanks.


Regards,
Peter

Last edited by superHonda123; 06-30-2010 at 11:56 PM.. Reason: correction
# 6  
Old 07-01-2010
Code:
awk '/\// {split($NF,a,"%"); if (a[1]>80) $0=$0 "  Warning";}1' file

This User Gave Thanks to rdcwayx For This Post:
# 7  
Old 07-01-2010
Hi rdcwayx,

Thanks a lot for your help.

I’ve tested your method and it’s working perfectly. Smilie


Regards,
Peter
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. OS X (Apple)

A simple plaything for a 19 month old and higher.

This thread today reminded me of it: https://www.unix.com/shell-programming-and-scripting/279465-larger-window.html#post303021017 This is OSX 10.13.6 and greater centric only. This expands the terminal window on the fly in bash. You initially need to put the standard terminal window to the top... (0 Replies)
Discussion started by: wisecracker
0 Replies

2. UNIX for Dummies Questions & Answers

Remove when date is higher

Dear Masters, I need to eliminate lines from file input 2 when the date in column 1 more than date in column 1 in file input 1 input 1 20141101|USA|CANSEL|496420000 20141101|USA|CANUT|1069740000 20141101|USA|CANTENG|625920000 20141102|USA|CANUT|413180000 20141103|USA|CANSEL|1364245000... (5 Replies)
Discussion started by: radius
5 Replies

3. What is on Your Mind?

Where to find higher consulting rates?

Have any IT consultants here been on a project where you knew the bill rate was really high but you only got a tiny piece of it (like paid $60/hr and billed out around $200)? Does anyone know of a company that pays consultants well - like 70-80% or more of what they're getting? (5 Replies)
Discussion started by: apierce
5 Replies

4. UNIX for Dummies Questions & Answers

grep 2000 and higher

i have content that looks like this: 0003326050 A E LITHO 0023823422 AMERICAN RED CROSS 0005713642 ARUP LABORATORIES 0003206450 CAEL 0002519930 CARDINAL HEALTH 0002619063 FISHER HEALTHCAR 0065203177 OWENS & MINOR INC 0016552938 STAPLES INC 0000002001 MSC... (8 Replies)
Discussion started by: tjmannonline
8 Replies

5. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

6. UNIX for Advanced & Expert Users

Checking mem usage at specific times in a program

Hi all, I'm running a simulator and I'm noticing an slow increase in memory for long simulations such that the simulation has to end because of a lack of memory. A colleague of mine ran Valgrind memcheck and reported that nothing of interest was reported other than known mem leaks. My advisor... (2 Replies)
Discussion started by: pl4u
2 Replies

7. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

8. UNIX for Dummies Questions & Answers

Checking CPU Usage and available free physical and virtual memories

Hi , can anyone please guide me on how do i go about getting the CPU Usage and available free physical and virtual memories? i know i can get it by using prstat, but i want to get an overall CPU Usage and not a breakdown of all same for the free physical and virtual memories ? (2 Replies)
Discussion started by: filthymonk
2 Replies

9. UNIX for Advanced & Expert Users

Backgrounding process with higher priority

I have been troubleshooting a mysterious performance problem with the nightly batch programs on our primary system for quite some time and just found something very interesting. All batch processes are running with a nice value of 24. I don't know what the default is on other systems but I do know... (3 Replies)
Discussion started by: keelba
3 Replies
Login or Register to Ask a Question