Count the number of online users

Source: Internet
Author: User
Tags file url apache log

After you connect to the device using your mobile phone, some logs will be generated in access. log before you use the browser:

 

When you use a browser but do not perform page operations, the following logs are generated in access. log:

 

Test Apache Log Access. log. Use Android mobile phone

No operation is performed when you connect to the device using your mobile phone.

 

When the pod software is enabled, the software cannot connect to the network, but access. log records a lot of information.

 

When using Baidu map, many of the following log records are generated:

In addition, many logs are generated at the same time.

 

 

When using multi-meter music

 

When the QQ browser is opened, the following information is generated continuously without any operation

 

When you click the browser page, an exception occurs when the mobile phone enters the page. The page cannot jump over and keeps jumping.

The log records in access. Log are:

 

 

Open one of the pages and go to the page,

 

Loads JS, CSS, images, and other information.

Example:/CSS/index.css

/JL/bootstrap-transition.js

/Image/ads_1.jpg

And other information

The following information is displayed on the review page:

 

 

When you click a destination, the following information is displayed:

 

 

The following message is displayed after the same video is opened:

 

 

Click in the movie bar and the following information is displayed:

 

After entering the movie chunqiao and Zhi Ming

 

The access to Apache. the extraction of useful information in log files is based on the Apache Log Analysis 1. Access. in the log file, a 200 status code is generated after the user correctly accesses the home page. Therefore, the file only extracts rows containing 200, including/Media /? The cat keyword line indicates that the user has accessed the bar of the same audio and video. 3. Contains/Media /? For the p-key line, the user uploads the line containing the .html keyword in a specific movie 4、and ends with this, indicating that the user has accessed the statistical result example of other columns (File URL. log.0013): 2013-02-19 frequency and URL: 61/home.html 14/media.html 7/Media /? Cat = 3 6/books.html 5/Media /? Cat = 37 4/Media /? Cat = 37 & paged = 4 3/search.html 3/Media /? P = 3806 3/Media /? Cat = 5 3/Media /? Cat = 37 & paged = 5 2/search-origining.html 2/Media /? Cat = 4 2/Media /? Cat = 3 & paged = 4 2/Media /? Cat = 3 & paged = 3 2/Media /? Cat = 3 & paged = 2 ************* end ************* the script is automatically downloaded from the FTP server log File, then, it analyzes the functions of the number of logon users of Apache and DHCP. This script can count the number of people on each device every day, and then write the number of people into the log file (Note: Because the files on the FTP server are not placed in the specified folder, all files are stored outside the log directory. Therefore, all files are analyzed outside the log directory. If the log files of each device are placed in the corresponding directory after improvement, in the script, you only need to modify part of the code and add a for loop to the FTP code section.) The first parameter indicates the number of visits, and the second parameter indicates the URL of access)

#! /Bin/bash yesterday = 'date-d Yesterday + % Y-% m-% d' # Get date of yesterdaydev_num = 'seq-F' % 04g '13 13 'tar _ error =-1 # ftp serverftphost = "119.188.10.163" username = "adfi_ftp" passwd = "adfi1! "# Ftp server log dirdectyftp_dir =" log "If [-e file_0013] thenfor dir in $ dev_numdo # login FTP server and get fileftp-v-N $ ftphost <eofuser $ username $ passwdcd $ ftp_dirpromptpassivebinarydir $ dir file_new _ $ direoffile_create = 'diff file _ $ dir file_new _ $ dir | awk '{if ($10! = '\ N') \ Print $10}' | xargs 'echo $ file_createjudge_file_create = 'echo $ file_create | awk 'nr = 1 {print $1} ''if [! -S $ judge_file_create] thencd $ dir # login FTP server and get fileftp-v-N $ ftphost <eofuser $ username $ passwdcd $ ftp_dir/$ users $ file_createeoffor I in $ file_create dodev = 'echo $ I | awk-F ". "'{print $3}'' date = 'echo $ I | awk-F ". "'{print $4}'' file _ type = 'echo $ I | awk-F ". "'{print $1}'' # Which type to disdinguish this file is, retrain Apache file get # rid of DHCP fileif [$ File_type! = "Apache"] thencontinuefiecho $ I # Get rid of file which log is empty of device numberif [-S $ Dev] thenrm $ icontinuefi # Get rid of file which is not suit to function, device number is # non-correspondenceif [$ Dev! = $ Dir] thenrm $ icontinuefiapache_file1 = 'tar-xvf $ I '# delete the file which cannot tar to filetar_stat = 'echo $? 'If [$ tar_stat-GT 0] thenecho "Apache: $ date $ tar_error"> .. /log. $ dirrm $ icontinuefiapache_num = 'cat $ apache_file1 | awk '{print $1}' | sort | uniq | \ sed '/:: 1/d' | WC-l 'echo "Apache: $ date $ apache_num"> .. /log. $ dir # Add stat the most number of vistors which vistor device urlfilm_pick = 'cat $ apache_file1 | awk '{if ($9 = 200) print $7} '| grep/Media /? Cat 'Film _ each_pick = 'cat $ apache_file1 | awk '{if ($9 = 200) Print $7}' | grep/Media /? P'html _ Pick = 'cat $ apache_file1 | awk '{if ($9 = 200) print $7} '| grep '.html \> ''echo "$ date frequency and URL:" >> .. /URL. log. $ direcho $ film_pick $ film_each_pick $ html_pick | SED's // \ n/G' | sort | uniq-c | \ sort-Nr | head-15> .. /URL. log. $ direcho "************ end *************"> .. /URL. log. $ dir done for I in $ file_createdodev = 'echo $ I | awk-F ". "'{print $3}'' date = 'echo $ I | awk-F ". "'{PRI NT $4} ''file _ type = 'echo $ I | awk-F ". "'{print $1}'' # Which type to disdinguish this file ISIF [$ file_type! = "DHCP"] thencontinuefiecho $ I # Get rid of file which log is empty of device numberif [-S $ Dev] thenrm $ icontinuefi # Get rid of file which is not suit to functionif [$ Dev! = $ Dir] thenrm $ icontinuefidhcp_file1 = 'tar-xvf $ I '# delete the file which cannot tar to filetar_stat = 'echo $? 'If [$ tar_stat-GT 0] thenecho "DHCP: $ date $ tar_error"> .. /log. $ dirrm $ icontinuefidhcp_num = 'cat $ dhcp_file1 | awk '{print $5}' | sort | uniq | WC-l 'echo "DHCP: $ date $ dhcp_num"> .. /log. $ dirdonmcm .. fimv file_new _ $ dir file _ $ dirdoneelsefor I in $ dev_numdo # login FTP server and get fileftp-v-N $ ftphost <eofuser $ username $ passwdcd $ scheme $ I file _ $ ICD $ imget * EOF if [! -D $ I] thenmkdir $ ifimv Apache * DHCP * $ I/donefor dir in $ dev_numdocd $ dir apache_file = 'ls Apache *. GZ 'dhcp _ file = 'ls DHCP *. GZ 'For I in $ apache_file dodev = 'echo $ I | awk-F ". "'{print $3}'' date = 'echo $ I | awk-F ". "'{print $4}'' # Get rid of file which log is empty of device numberif [-S $ Dev] thenrm $ I

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.