LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-01-2016, 12:21 PM   #1
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Rep: Reputation: Disabled
Linux project So LOST!!!!


Hello my name is Jen Garcia I am very new to Linux and I’m currently working on a log file project and I’m totally lost and have no idea where to begin

Here is the sample log file format

192.168.28.168 user143 [08/May/2010:09:52:52] "GET /NoAuth/js/scriptaculous/scriptaculous.js?load=effects,controls HTTP/1.1" "http://www.example.com/index.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0"

192.168.28.168 user147 [08/May/2010:09:52:52] "GET /NoAuth/js/prototype/prototype.js HTTP/1.1" "http://www.example.com/index.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0"

192.168.28.168 user174 [08/May/2010:09:52:52] "GET /NoAuth/js/ahah.js HTTP/1.1" "http://www.example.com/index.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0"

The final output has to look like this:



Access log for date’s XX/May/20xx to xx/May/20xx

Total # of hits: 999999

Total # of unique visitors: 999

Top 10 Users:
9999 user116
9999 user0
9999 user54
9999 user177
9999 user56
9999 user7
9999 user44
9999 user70
9999 user47
9999 user126

Top 5 most used resources:
10000 /NoAuth/js/util.js
10000 /NoAuth/js/titlebox-state.js
10000 /NoAuth/js/ahah.js
10000 /NoAuth/js/prototype/prototype.js
10000 /NoAuth/js/scriptaculous/scriptaculous.js?load=effects,controls

Top 5 most vistited URL's:
100000 http://www.example.com/index.html
60000 http://www.example.com/index.html?Ho...shInterval=120
7000 http://www.example.com/NoAuth/RichTe...fckeditor.html
5000 http://www.example.com/index.html?Ho...shInterval=300
4000 http://www.example.com/index.html?Ho...shInterval=600

Browser Statistics:
100000 MSIE 6.0
100000 MSIE 7.0
10000 MSIE 8.0
2000 Firefox/3.6.3
1000 Firefox/3.5.9
1000 Firefox/3.6.3
1000 Firefox/3.0.19
500 Firefox/3.0.11
80 Firefox/1.5.0.12
80 Firefox/3.5.7
40 Firefox/3.0.19
1000 Other Browsers
 
Old 03-01-2016, 12:34 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Looks suspiciously like an Apache access log. If it is then use an existing perl or python log file parser rather than write one from scratch, like:

https://github.com/rory/apache-log-parser
 
Old 03-01-2016, 12:35 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
logs
there are MANY kinds
and not everyone will recognize just what the above file is from
it looks to be from a Apache log


you might want to include all the needed information

because there are also operating system logs , and two different types ( old and new )

then there are individual program logs


for Apache
have a look at the perl based program built to parse weblogs
AWStats
http://www.awstats.org/
 
Old 03-01-2016, 12:40 PM   #4
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
I have #!/bin/bash since I was instructed not to change anything. Date the range of the log. from oldest to newest using head, tail, cut. Any suggestions?
 
Old 03-01-2016, 12:41 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Welcome to LQ!
You can and should start your own thread at http://www.linuxquestions.org/questions/linux-newbie-8/
Please review some things we'll need when you post, eg: https://www.linuxquestions.org/quest...#faq_lqwelcome

Thank you,
"So LOST!!!!" is not a good thread topic.
Does
http://www.linuxquestions.org/questi...ml#post5506705 not work?

I never thought 2 people from the same class (Hi Teacher!) would be discussing the exact same course/instruction/lab.
 
Old 03-01-2016, 12:41 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
You could maybe include some more information on what exactly it is you were asked to do?

As suggested above there are many scripts already written for parsing these types of logs, but your teacher may have asked you to write something based on what you have been learning.
If it is the latter you would have to indicate this and what it is you have learned so your question may be better addressed.

If the question is simply put as here is data and here is the desired output, which can be produced by any means necessary, then go down the road of finding tools already designed for the task.

No need to reinvent the wheel, unless you are learning how they attach to cars and help you to drive
 
Old 03-01-2016, 12:45 PM   #7
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
details

Quote:
Originally Posted by grail View Post
You could maybe include some more information on what exactly it is you were asked to do?

As suggested above there are many scripts already written for parsing these types of logs, but your teacher may have asked you to write something based on what you have been learning.
If it is the latter you would have to indicate this and what it is you have learned so your question may be better addressed.

If the question is simply put as here is data and here is the desired output, which can be produced by any means necessary, then go down the road of finding tools already designed for the task.

No need to reinvent the wheel, unless you are learning how they attach to cars and help you to drive
I have to write a bash script analyzes the access logs of web servers which indicates web statistics
 
Old 03-01-2016, 12:47 PM   #8
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
"So LOST!!!!" is not a good thread topic.
Does
http://www.linuxquestions.org/questi...ml#post5506705 not work?

I never thought 2 people from the same class (Hi Teacher!) would be discussing the exact same course/instruction/lab.
Habitual, this is very difficult for me. If you're going to be mean please do not write me.
 
Old 03-01-2016, 12:51 PM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by JenGarcia33 View Post
Habitual, this is very difficult for me. If you're going to be mean please do not write me.
I am not being "mean".
I could have been mean in the other thread. So relax.

.dbaseIII+ made me cry in 1993

What are you struggling with exactly?
 
Old 03-01-2016, 12:53 PM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Firstly, Habitual is not intending to be "mean", but rather point out that you do indeed have what appears to be a co-student asking very similar questions.
This would make it prudent that you look at what has already been written as it may assist you

As to your extra information ... so a bash script to parse a log file and then deliver the required statistics ... if I have understood you correctly.

So as you will have learned many things in your course already, you should be able to show what basic things you have already done.

For instance, how would you go about reading from a file and storing the data into worthwhile variables?
Your current shown data for the log file appears reduced from that of the other thread, so show all data that would appear on a line from the log file.

Start simple and build the script by pieces.
 
Old 03-01-2016, 01:00 PM   #11
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
Firstly, Habitual is not intending to be "mean", but rather point out that you do indeed have what appears to be a co-student asking very similar questions.
This would make it prudent that you look at what has already been written as it may assist you

As to your extra information ... so a bash script to parse a log file and then deliver the required statistics ... if I have understood you correctly.

So as you will have learned many things in your course already, you should be able to show what basic things you have already done.

For instance, how would you go about reading from a file and storing the data into worthwhile variables?
Your current shown data for the log file appears reduced from that of the other thread, so show all data that would appear on a line from the log file.

Start simple and build the script by pieces.
Thanks for your advice, how would you pm a user on here?
 
Old 03-01-2016, 01:05 PM   #12
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
I am not being "mean".
I could have been mean in the other thread. So relax.

.dbaseIII+ made me cry in 1993

What are you struggling with exactly?
I'm struggling with writing the bash script all together.

Is there any way we can talk in real time so I can explain it better? Something like pm or yahoo messenger?
 
Old 03-01-2016, 01:09 PM   #13
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
You can send an email to a user but that may not be any quicker than the replies you get here.

No one will tell you what to do, but we are all more than willing to help you learn.

You have said:
Quote:
I'm struggling with writing the bash script all together.
But in my last post I gave you a starting position ... ie. start from reading the file in ... how would you do this in bash?
 
Old 03-01-2016, 01:15 PM   #14
JenGarcia33
LQ Newbie
 
Registered: Mar 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
You can send an email to a user but that may not be any quicker than the replies you get here.

No one will tell you what to do, but we are all more than willing to help you learn.

You have said:

But in my last post I gave you a starting position ... ie. start from reading the file in ... how would you do this in bash?
Of course, I know that and I was thinking start_date =`$date.example.log
 
Old 03-01-2016, 01:26 PM   #15
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Ok, so start and write the small pieces you know and slowly put your script together. When stuck, come back and show what you have written and what the current hurdle is.

You have to remember that your first statement was:
Quote:
Hello my name is Jen Garcia I am very new to Linux and I’m currently working on a log file project and I’m totally lost and have no idea where to begin
So now you have a place to begin
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Apple kills a Kickstarter project: Portable power project POP refunding $139,170 to backers LXer Syndicated Linux News 0 12-23-2012 06:41 AM
project related help needed...linux based project tpsamant88 Programming 2 06-20-2012 11:42 AM
[SOLVED] How to store all files related to a c++ project and build in linux. Like project dir sharanlinux Programming 1 04-29-2010 06:52 AM
LXer: Archiveteam Project Collects Lost Web 2.0 Content LXer Syndicated Linux News 0 05-28-2009 04:40 PM
Beginning a big project - Need an Good Project Manager gamehack Programming 3 01-15-2004 11:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration