Please tune my script for Solaris


 
Thread Tools Search this Thread
Operating Systems Solaris Please tune my script for Solaris
# 1  
Old 12-31-2009
Lightbulb Please tune my script for Solaris

I have very big log file around 2-3 GB in that it contians 24 hours log data. My work is extract only 5-5 data and count the patterns from them. I worte a script in linux and we're using that.

Code:
sed -n "/2009 05:/,/2009 17:/p" trace.log | grep -f patterns.txt > temp.log
while read string ;do
count=$(grep -c "$string" temp.log)
echo "$count\t$string" >> count.log
done <patterns.txt

Now we need to change that to Solaris 9. Some of the functions we cant use in solaris i opted the below one

Code:
sed -n "/2009 05:/,/2009 17:/p" trace.log | egrep "PATTERN1|PATTERN2|PATTERN3|PATTERN4|PATTERN5|PATTERN6" > temp.log
while read string ;do
count=$(grep -c "$string" temp.log)
echo "$count\t$string" >> count.log
done <patterns.txt

Could please tune my script, I have more than 15 patterns. Is it right way to do that..? Since my grep -f is not working in Solaris i'm opted for egrep.
# 2  
Old 12-31-2009
Hi have you checked
Code:
/usr/xpg4/bin/grep

That should have a -f option.

Your title said tune my script, which usually means: make faster. So without thinking I created this awk script:
Code:
awk 'NR==FNR {P[$1]=0;next} /2009 05:/,/2009 17:/{for (i in P) if ($0~i) P[i]++}
     END {for (i in P) if (P[i]>0) print P[i]"\t"i}' patterns.txt trace.log > count.log

Which should process the log in one go, but I guess that is not what you were after. But perhaps it is useful anyway. On Solaris use nawk or /usr/xpg4/bin/awk
# 3  
Old 12-31-2009
thanks for the reply Scrutinizer

If i use the awk i got an error
Code:
/usr/xpg4/bin/awk: line 0 (NR=2139569): Record too long (LIMIT: 19999 bytes)

any way that /usr/xpg4/bin/grep has the -f flag so i served me the purpose.
One more little help from unix experts..this grep wont have the -A flag. So i am opting for

Code:
sed -n '/PATTERN/ {N;p;}' trace.log

but how serach for more than one PATTERN.

Last edited by Yogesh Sawant; 12-31-2009 at 12:40 PM.. Reason: added code tags
# 4  
Old 12-31-2009
Hi.

Do you have /usr/sfw/bin/ggrep?

This has the -A option.
# 5  
Old 12-31-2009
My Master told me that Every Complex problems has a simple solution. this is the example.

I owe a beer to both.

thanks
# 6  
Old 12-31-2009
Smilie Thanks, I'll have a Kingfisher
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tune my script

Hi ! My script read out data out of 144 files per day - every ten minutes a file with data. data-file WR030B 306.71 0 WR050B 315.13 0 WR120B 308.34 0 WV030B 3.52 0 WV050B 5.06 0 WV120B 6.65 0 TLUFT02B 8.60... (3 Replies)
Discussion started by: IMPe
3 Replies

2. HP-UX

Top cmd showing NICE value 97% -what to tune?

Running 2 VM Guests on an HPUX Integrity Server. One Guest runs great, the other is always at a high NICE value and 0% idle as shown in TOP: What do you think should be tuned to bring down the NICE and increase IDLE %? Thanks in advance -hpuxadmin slow VM GUEST Load averages: 2.56,... (5 Replies)
Discussion started by: hpuxadmin
5 Replies

3. Shell Programming and Scripting

Fine tune this perl script to add router

Hi, I have this routine that reads a microsoft dhcp.netsh dump. Where it finds optionvalue 3 STRING "0.0.0.0" Replace it with the router IP based on the network !/usr/bin/perl while ( <> ) { if ( /\# NET / ) { $net = $'; $net =~ s///g; } else { s/set optionvalue 3... (1 Reply)
Discussion started by: richsark
1 Replies

4. UNIX for Dummies Questions & Answers

Need tune my command occupying 90% CPU

Can some body tune the below command, its occupyinh more than 90% of CPU some times. tail -n 1000 /logs/trace.log | awk 'BEGIN{OOM = 0; ScE = 0; NaE = 0; Jms = 0} /OutOfMemoryException/{OOM = 1} /StaleConnectionException/{ScE = 1} /NamingException/{NaE = 1} /JmsTimeOutException/{Jms = 1}... (17 Replies)
Discussion started by: senthil.ak
17 Replies

5. Shell Programming and Scripting

Tune my query

I have a requirement to separate only some numbers from the input file and produce it in a format. The input is ( i have took a sample, the actual file contains more than 50000 rows around 840 MB in size) $cat temp.txt 001 08 002 08 003 06 004 11 005 11 006 08 007 08 008 92* 009 92 010... (1 Reply)
Discussion started by: senthil.ak
1 Replies

6. Cybersecurity

How to fine Tune and Harden the Linux kernel

Hi, As a a security audit, how can I proceed further with Fine tuning and Hardening the linux kernel... I am not sure with the steps how to proceed further... If i do some thing wrong, then its comes with the Kernel panic error. So, I am afraid, how to do the tuning with the kernel.. (1 Reply)
Discussion started by: gsiva
1 Replies

7. UNIX for Dummies Questions & Answers

Tune my logic of script

I have big log file, which contains the netstat output from my application server to a particular DB server. I aim is to plot a daily graph for this. Please find the sample log file below. @ - ........................................................... @ - Total number of connection to the ... (3 Replies)
Discussion started by: senthilkumar_ak
3 Replies

8. Solaris

How to tune kernel Parameters in Solaris 10,9 & how to measure performance

Hi, I want to tune my SUN servers for best performance. My servers are heavily loaded and used. They have Solaris 10. How to tune Kernel Parameters of solaris ? And How can I measue performance before changing parameters and after changing parameters ? Please help Thanks NeeleshG (2 Replies)
Discussion started by: neel.gurjar
2 Replies
Login or Register to Ask a Question