[SOLVED] counting 503 errors in a log for the last hour...
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What I have worked out are the dates, as I planned to use bash to do this, but I think I'm using the wrong tool for the job.
Code:
date '+%d/%b/%Y:%I:%M:%S'
date '+%d/%b/%Y:%I:%M:%S' --date="1 hour ago"
"'now' minus 1 hour" is the requirement and the ‘hour’ and the ‘count' part should be "configurable" (allow the client, or us to readily adjust these 2 options)
I can't use grep with a from/to range (can I?) and sed is only good for replace in a from/to format, so I concluded that awk (or perl) must be the choice and I know neither.
I'd appreciate any direction, or pointers to a working solution.
I need to acquire the total number of 503 errors in a log file for the last hour.
This task is simplified if your one-hour "window" may be defined as falling on neat hourly bounds. For example, 14:00:00 to 14:59:59 but not 14:17:05 to 15:17:04.
I asked that very thing too!
"in the last hour" I would grep and count from 0700 - 0800
otherwise
grep and count as "'now' - 1 hour" and he replied the latter.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.