- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- compare script question ..
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:18 PM
03-19-2002 12:18 PM
04:49:08 Checkpoint Completed: duration was 1 seconds.
04:49:12 Checkpoint Completed: duration was 0 seconds.
04:56:13 Checkpoint Completed: duration was 0 seconds.
08:20:57 Checkpoint Completed: duration was 17 seconds.
08:21:30 Checkpoint Completed: duration was 0 seconds.
14:51:00 Checkpoint Completed: duration was 4 seconds.
14:51:25 Checkpoint Completed: duration was 0 seconds.
The objective is to get the number of seconds and warn me if at any time they are greater then 15. Here is what I got so far ..
grep duration /usr/informix/online.log | grep -v Fuzzy | awk '{print $6}'
gives me
1
0
0
17
0
4
0
That gives me just the lines above and then only gives me the seconds ..
So then I tried
grep duration /usr/informix/online.log | grep -v Fuzzy | awk '{print $6}'| read numb
if [ $numb -gt 15 ]
then
echo "You have long checkpoints"
else
echo " Everything is fine"
fi
But that does not work for me. For somereason I cant feed the line of numbers to my test if statement. What Am I missing? I know its simple ..
Thanks
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:26 PM
03-19-2002 12:26 PM
Solutiongrep duration /tmp/online.log | grep -v Fuzzy | awk '{print $6}'| sort -rn| whil
e read numb
do
echo $numb
if [ $numb -gt 15 ]
then
echo "You have long checkpoints"
else
echo " Everything is fine"
fi
done
note I sorted the list in reverse numerical order.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:33 PM
03-19-2002 12:33 PM
Re: compare script question ..
grep duration /tmp/online.log | grep -v Fuzzy | awk '{print $6}'| grep "[0-9][0-9]"
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:34 PM
03-19-2002 12:34 PM
Re: compare script question ..
Your script is not working because you missed "while" before the read
#!/bin/ksh
awk '/duration/{print $6}' test | while read NUM; do
if [[ ${NUM} -gt "15" ]]; then
echo "you have long checkpoints"
else
echo "okay"
fi
done
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:34 PM
03-19-2002 12:34 PM
Re: compare script question ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:35 PM
03-19-2002 12:35 PM
Re: compare script question ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:37 PM
03-19-2002 12:37 PM
Re: compare script question ..
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:48 PM
03-19-2002 12:48 PM
Re: compare script question ..
grep duration /usr/informix/online.log | grep -v Fuzzy | awk ' $6 > 15 {printf "
There is a long checkpoint of %s\n",$6}'
grep duration /usr/informix/online.log | grep -v Fuzzy | awk ' $6 > 15 ' | read
numb
grep "$numb" /usr/informix/online.log
Gives me
There is a long checkpoint of 17
08:20:57 Checkpoint Completed: duration was 17 seconds.
Thanks
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:51 PM
03-19-2002 12:51 PM
Re: compare script question ..
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 12:59 PM
03-19-2002 12:59 PM
Re: compare script question ..
#!/usr/bin/ksh
grep duration /tmp/online.log | grep -v Fuzzy | awk '$6 > 15 {printf "There is a
long checkpoint of %s\n",$6;printf "%s\n",$0;}'
will find all the lines and print their corresponding line. The solution you gave will report the same FULL-LINE if TWO or MORE TIMES are > 15 and equal
line these two lines:
04:49:08 Checkpoint Completed: duration was 1 seconds.
04:49:12 Checkpoint Completed: duration was 0 seconds.
04:56:13 Checkpoint Completed: duration was 0 seconds.
08:20:57 Checkpoint Completed: duration was 17 seconds.
08:21:30 Checkpoint Completed: duration was 0 seconds.
14:51:00 Checkpoint Completed: duration was 4 seconds.
14:51:25 Checkpoint Completed: duration was 17 seconds.
yours will display :
08:20:57 Checkpoint Completed: duration was 17 seconds.
TWICE, when it should display:
08:20:57 Checkpoint Completed: duration was 17 seconds.
14:51:25 Checkpoint Completed: duration was 17 seconds.
give my modifications to your solution a zip
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 01:09 PM
03-19-2002 01:09 PM
Re: compare script question ..
Would you mind breaking it down for me? I understand everything up to the printf ..
of %s\n",$6;printf "%s\n",$0;}'
is the part I dont understand. What I do somewhat understand is that you are printing the output There is a long checkpoint with the $6 (6th row) which is what gives us :
There is a long checkpoint of 17
#!/usr/bin/ksh
grep duration /usr/informix/online.log | grep -v Fuzzy | awk '$6 > 15 {printf "T
here is a long checkpoint of %s\n",$6;printf "%s\n",$0;}'
And just wondering how long have you been writting scripts? It seems that it is 2nd nature to you. Did you read books or just learned as you did.
Thanks,
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 01:20 PM
03-19-2002 01:20 PM
Re: compare script question ..
Both, but first by fire. 12years ago I ported banking software from a Honeywell to an AIX box and I had to learn unix and learn it quick. I've been a developer for EON'S (24 years now).
Here:
grep duration /tmp/online.log | grep -v Fuzzy |
awk '$6 > 15 {printf "There is a
long checkpoint of %s\n",$6;
printf "%s\n",$0;}'
The line:
awk '$6 > 15 {printf "There is a long checkpoint of %s\n",$6;
like Ron suggested matches when the 6th value on the line is greater than 15, then the BODY of the AWK script kicks in:
{printf "There is a long checkpoint of %s\n",$6;
printf "%s\n",$0;}'
The lines in AWK are seperated by ";'s" and $0 is the whole line. Printf's are about the same in perl, C, and Awk.
And will you please learn perl? hehehe
Live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 01:29 PM
03-19-2002 01:29 PM
Re: compare script question ..
thanks harry .. And I am working on learning perl seems to be a pretty cool code. I have SAMS Teach yourself perl in 24 hours. To me it was full of fluff. I am thinking thats why I got burnt out on Perl. But I am willing to try again. Any better books out there?
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 04:25 PM
03-19-2002 04:25 PM
Re: compare script question ..
being a techno-geek I like the O'reilly books as reference manuals. There are a lot good web sites with good crap, hell, I' a cut and paster!!
http://www.perlmonks.org/
http://www.planet-source-code.com/vb/default.asp?lngWId=6#categories
http://www.perlnow.com/
http://www.perl.com/CPAN-local/scripts/
http://use.perl.org/
http://www.sysadminmag.com/tpj/
http://www.perl.org/
http://www-genome.wi.mit.edu/WWW/examples/Ch9/
and at least a few thousand more!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 11:30 PM
03-19-2002 11:30 PM
Re: compare script question ..
That way I'll be sure my answers will work as expected.