- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Grep lines from a log based on time specific in mi...
Operating System - HP-UX
1753821
Members
8698
Online
108805
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО12-04-2008 02:41 PM
тАО12-04-2008 02:41 PM
Grep lines from a log based on time specific in minutes
Hi,
I am writing a korn shell script to calculate average response times from a weblogic log. I need to grep lines based on time in minutes specified by a user and display the average time. For e.g. if a user specifies 30 mins, I need to grep transaction lines from the log in the last 30 mins and calculate the average times from that.
Will I be able to do that kind of date/time calculation from a ksh scipt? Also in the logs, this is the timestamp format for the weblogic transactions: 2008.12.04 13:51:15:106 PST. How can I convert back and forth if I use epoch seconds to do this calculation? I can use perl for this but the requirement is do it from a ksh script which I am not very comfortable with. Any help is greatly appreciated. Thanks.
I am writing a korn shell script to calculate average response times from a weblogic log. I need to grep lines based on time in minutes specified by a user and display the average time. For e.g. if a user specifies 30 mins, I need to grep transaction lines from the log in the last 30 mins and calculate the average times from that.
Will I be able to do that kind of date/time calculation from a ksh scipt? Also in the logs, this is the timestamp format for the weblogic transactions: 2008.12.04 13:51:15:106 PST. How can I convert back and forth if I use epoch seconds to do this calculation? I can use perl for this but the requirement is do it from a ksh script which I am not very comfortable with. Any help is greatly appreciated. Thanks.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 03:14 PM
тАО12-04-2008 03:14 PM
Re: Grep lines from a log based on time specific in minutes
Hi:
> How can I convert back and forth if I use epoch seconds to do this calculation? I can use perl for this but the requirement is do it from a ksh script which I am not very comfortable with.
You can write your Korn shell script as you want. Simply use Perl to do the work of converting the log's timestamps into epoch seconds. Look for log records that lie in the epoch second-based range.
For example:
...
E=$(./make_epoch "2008.12.04 13:51:15")
echo ${E}
1228431720
Your current time is given simply from:
C=$(perl -le 'print time')
1228431725
Regards!
...JRF...
> How can I convert back and forth if I use epoch seconds to do this calculation? I can use perl for this but the requirement is do it from a ksh script which I am not very comfortable with.
You can write your Korn shell script as you want. Simply use Perl to do the work of converting the log's timestamps into epoch seconds. Look for log records that lie in the epoch second-based range.
For example:
...
E=$(./make_epoch "2008.12.04 13:51:15")
echo ${E}
1228431720
Your current time is given simply from:
C=$(perl -le 'print time')
1228431725
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 03:29 PM
тАО12-04-2008 03:29 PM
Re: Grep lines from a log based on time specific in minutes
Thanks James. The machine they script is going to be run on doesn't have perl installed, thats why I wanted to find out if I could do it purely in ksh. I will get them to install perl on the machine so it makes everybody's life easier :). Appreciate your help! Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-04-2008 06:08 PM
тАО12-04-2008 06:08 PM
Re: Grep lines from a log based on time specific in minutes
Hi (again):
I'm losing it...I forgot to insert the Perl script I'm suggesting:
# cat ./make_epoch
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my $date = shift or die "Timestamp expected\n";
my $fmt = qr{(\d+)\.(\d+)\.(\d+)\s(\d+):(\d+):(\d+)};
die "Wrong format; 'yyyy.mm.dd hh:mm:ss' expected\n" unless $date =~ $fmt;
my ( $yyyy, $mm, $dd, $hrs, $min, $sec ) = ( $date =~ $fmt );
my $epoch = timelocal( $sec, $min, $hrs, $dd, $mm - 1, $yyyy );
print "$epoch\n";
1;
Regards!
...JRF...
I'm losing it...I forgot to insert the Perl script I'm suggesting:
# cat ./make_epoch
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my $date = shift or die "Timestamp expected\n";
my $fmt = qr{(\d+)\.(\d+)\.(\d+)\s(\d+):(\d+):(\d+)};
die "Wrong format; 'yyyy.mm.dd hh:mm:ss' expected\n" unless $date =~ $fmt;
my ( $yyyy, $mm, $dd, $hrs, $min, $sec ) = ( $date =~ $fmt );
my $epoch = timelocal( $sec, $min, $hrs, $dd, $mm - 1, $yyyy );
print "$epoch\n";
1;
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP