1. Statistics of PV and IP Count the PV (Page View) of the day cat access.log | sed -n /`date "+%d\/%b\/%Y"`/p |wc -l Count the PV of a certain day cat access.log | sed -n '/20\/Sep\/2018/p' | wc -l View the top 10 IP addresses with the most visits in the log cat access.log.1 |cut -d ' ' -f 1 | sort |uniq -c | sort -nr | awk '{print $0 }' | head -n 10 View the top 10 IP addresses with more than 1,000 visits in the log cat access.log.1 |cut -d ' ' -f 1 | sort |uniq -c | sort -nr | awk '{if($1>1000) print $0 }' | head -n 10 2. curl sends data Sending a GET request using curl Sending a POST request using curl curl -d "user=admin&passwd=12345678" http://127.0.0.1:8080/login Send JSON data using curl curl -H "Content-Type:application/json" -X POST -d '{"user": "admin", "passwd":"12345678"}' http://127.0.0.1:8000/login Sending dynamic parameter POST request using curl curl -i -X POST -H "'Content-type':'application/json'" -d '{"ATime":"'$atime'","BTime":"'$btime'"}' $url curl -i -X POST -H "'Content-type':'application/json'" -d '{"ATime":"'${atime}'","BTime":"'{$btime}'"}' ${url} 3. Shell script statistics and sending #!/bin/bash log_path=/var/log/nginx/access.log domain="http://127.0.0.1:8080/data/count" log_date = `date "+%d/%b/%Y"` echo ${log_date} total_visit=`cat ${log_path} | grep $log_date|wc -l` curl -d "count=${total_visit}" ${domain} echo $total_visit 4. The server accepts and saves it to the database @RequestMapping(value = "/count") public void count(String count){ //Business code} Summarize The above is the shell script that I introduced to you. It regularly counts the PV of access.log under Nginx and sends it to the API to save it in the database. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Detailed tutorial on installation and configuration of MySql 5.7.17 winx64
>>: Native js implements a minesweeper game with custom difficulty
Table of contents 1. The origin of fork 2. Early ...
1. Problem description: MysqlERROR1698 (28000) so...
one. First of all, you have to package it in idea...
Intro Introduces and collects some simple and pra...
Preface When creating a primary and foreign key f...
Design the web page shown above: <!DOCTYPE htm...
In this section, we will learn about list element...
Often when we open foreign websites, garbled char...
Table of contents Preface What is Hot Change Coco...
1. Problem Description Today I need to check the ...
Method 1: <input id= "File1" type= &q...
1. The proxy_pass directive of the 1.ngx_stream_p...
Suppose there is a table: reward (reward table), ...
HTML <dl> Tag #Definition and Usage The <...
1. Leading fuzzy query cannot use index (like ...