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
Preface Everyone should be familiar with the watc...
Table of contents Preface Modifiers of v-model: l...
Table of contents Before transformation: After tr...
1. Basic lines 2. Special effects (the effects ar...
Use jQuery to implement form validation, for your...
Today, when we were learning about the Niu Nan new...
Table of contents Mixins implementation Hook func...
/****************** * Linux kernel time managemen...
Vertical table Vertical table splitting means spl...
Table of contents 1. Comments on MySQL primary ke...
question: Recently, garbled data appeared when de...
Because Ubuntu 20.04 manages the network through ...
1. Use of Iframe tag <br />When it comes to ...
Following the previous article 202 Free High-Qual...
Table of contents 1. Map method 2. Application ba...