Home > Operation and Maintenance > Nginx > How to write Nginx log processing script under windows

How to write Nginx log processing script under windows

王林
Release: 2023-05-14 16:37:06
forward
780 people have browsed it

Running instructions: 20120917.txt is the log that needs to be analyzed, and last.csv is the statistical result (open with execl to facilitate statistics and sorting).
1. [File]
2. [Picture] Running screenshot.jpg

How to write Nginx log processing script under windows

3. [Picture] Running result

How to write Nginx log processing script under windows

4. [Code] Save as bat and double-click to open it

Copy code The code is as follows:

@echo off
setlocal enabledelayedexpansion

rem Extract ip to ip.txt file
awk.exe "{a[$1] =1;}end{for(i in a){print i;}}" 20120917 .txt > ip.txt

rem Read the ip in the ip.txt file line by line, and call the ip address source query interface of youdao.com
del result.txt
del last. txt
del last.csv

for /f "delims=" %%k in (ip.txt) do (
set /a b =1
wget-1.10.2.exe "http://www.youdao.com/smartresult-xml/search.s?type=ip&q=%%k" --output-document=temp.xml >nul 2>nul
echo is processing %% k
for /f "delims=" %%i in (temp.xml) do (
set /a num =1
set str=%%i
set str1=">% %k,!str! if !num! equ 5 (echo !str1! | strrpc "" "" | strrpc "" "">> result. txt)
)
set num=0
)

rem Processing result.txt quotation marks
for /f "tokens=2 delims=>" %%z in (' type result.txt') do (
for /f "delims=> last.txt
)

rem Name last.txt last.csv
rename last.txt last.csv
pause

The above is the detailed content of How to write Nginx log processing script under windows. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template