Parse Apache log file, regular expression
/** Copyright (c) Ian F. Darwin, http://www.darwinsys.com/, 1996-2002.* All rights reserved. Software written by Ian F. Darwin and others.* $Id: license,v 1.8 2004/02/09 03:33:38 Ian Exp $** Redistributio
}‘ | lessView the most recent 1000 records with the highest volume of visited pagestail -1000 access.log |awk ‘{print $7}‘|sort|uniq -c|sort -nr|lessRequest Volume statistics per secondCount requests per second, Top100 Point in time (accurate to seconds)awk ‘{print $4}‘ access.log |cut -c 14-21|sort|uniq -c|sort -nr|head -n 100Request Volume statistics per minuteCount requests per minute, Top100 point in time (accurate to minutes)awk ‘{print $4}‘ access.log |cut -c 14-18|sort|uniq -c|sort -nr|he
returns the array object of the file name.Use the FO = Open (FileName) method to read the entire contents of the file, lines = Fo.readlines () reads the contents of the file by line. (PS: Although I end each line with a ' \ R ' character, Python may have the entire file con
': [40.218102,-111.613297]}3. List-GeneratedSee: http://www.cnblogs.com/janes/p/5530979.htmlsecond, parse the JSON file into a dictionary listTo parse the JSON file, we first read the file line by row, converting each line into the corresponding Dictionary object, and then f
Linux under many configuration files in addition to the INI format can be used in Python configparser module, you can write a simple code of their own only "key=value" such a conf configuration file to parse into a dictionary, The key corresponding to key can be easily obtained by using the dictionary keys. The Python
Example of how to parse a json file in python,
Preface
JSON (JavaScript Object Notation) is a lightweight data exchange format. It is based on a subset of JavaScript (Standard ECMA-262 3rd Edition-December 1999. JSON uses a completely language-independent text format, but it also uses a habit similar to the C language family (including C, C ++, C #, Java, JavaScr
The INI file is a frequently used configuration file in Windows, and the main format is:
Copy Code code as follows:
[Section1]
Option1:value1
Option2:value2
Python provides a simple module configparser can be used to parse files similar to this form. For the Configparser module, you can
This article mainly introduces the code for parsing the crontab configuration file implemented by python. It can also be called the crontab of python. the code contains a large number of comments. For more information, see
#/Usr/bin/env python #-*-coding: UTF-8-*-"" 1. parse
Because the company's internal interface returns the string support 2 kinds of forms: PHP array, XML; results php array python can not be used directly, and XML string format is not standard, so also can not use the standard module parsing. "Non-standard place is the name of some node will be the beginning of the number", so write a simple step to parse the file,
#/usr/bin/env python#-*-coding:utf-8-*-"" "1. Parse the five-digit parameter in the crontab configuration file (time-sharing week) get their corresponding range of values 2. Compare the timestamp with a row of time parameters in the crontab configuration to determine if the timestamp is within the configured time range "" "# $Id $ import Re, times, Sysfrom Core.F
Python's most recent work is the component compatibility test, the original framework has a lot of features are not perfect, need to add! For example, you need to write the results of the AutoIt script to Excel, and the final solution is to use the local log to parse the result!
The following class is added to complete the above functions:
Copy Code code as follows:
Class Autoitresultparser ()
One of the requirements of the project is to parse the Nginx log file.
The simple arrangement is as follows:
Log Rule description
First of all to clarify their own nginx log format, where the default Nginx log format:
Log_format
Log on to the system with the Python username and password (MD5 encryption and file storage, and the password will be locked after three input errors) and perform the encryption and decryption of the string with the Caesar password,
#-*-Coding: gb2312-*-# log on to the system with the username and password (MD5 encrypt
Tnlog. py
# ! /Usr/bin/ENV Python # -*-Coding: UTF-8 -*- Import OS Import Sys Import Time Import Logging Import Inspect ''' Import inspectdef test (): A = inspect. stack () [1] print a To Get A tuples, such as: (CodeThe runtime of the function (called function) Stack is 0. According to the call sequence, the swap offset value of the function stack on the call chain increases by 1.A-> B-> C (A calls B, B calls C) C obtains the stack seq
: pieexploded3d-charttitle:" Agent reason spread "-E 200-dtlines: 600
After running log parse, we can see that the table we generated is as follows:
We can find out the number of mails in the current classification. The figure above is not very intuitive. We use a pie chart to analyze the number of mails. We can use the following chart for intuitive performance, run the following statement:
"C: \ Pr
Run Python programs in the background and standard output to fileNow there is a test.py program to deploy in the background, there are output contentUse the command:nohup python -u test.py > test.log 2>1
The last indication of the background run
2 output error message to the prompt window
1 represents the output information to the prompt window, 1 before the Note is added, otherwise a
We often encounter this situation in the operation of data, the need for some environment-generated log data analysis, and some large company friends, often do not have the authority of the server, so we need to automatically import data into MySQL, this content is based on.
Article Focus:
1st log files are read by row, prevent logging data from being too large, use row reads when operating, and do not occu
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.