Python log monitoring (pronunciation)
Some friends asked me to help with a log monitoring script some time ago. The requirements are as follows:
1. windows Environment
2. Sound is triggered when the keyword of the log is matched. The matching keyword is different and the
Log files are usually generated by day, then replace the monitored log files by judging the file's date of production and the current time in the programThe program is just a simple example, monitor test1.log 10 seconds, turn to monitor Test2.log
Program monitoring uses Lin
Label:Modify My.ini (My MySQL installation location is:E:\MySQL\MySQL Server 5.6) log-output=FILE general-log=1 general_log_file= "LvJin.log" The default build log is in the following location: E:\MySQL\MySQL Server 5.6\data\lvjin.log I simply executed a SQL in MySQL. Open the
Zabbix Monitoring Windows log Scripts The script is used to monitor the logs on the Windows Server, view the log file at the end of n rows, and if n rows contain a field, output 0, otherwise output 1, and then zabbix the profile empty definition Kye, for monitoring.Text file
First look at the code:Nginx log monitoring script Python#! /Usr/bin/python2.6# Coding = UTF-8Import OSImport time# LoggingNum_file = '/data/www/www.111cn.net/log/num'Log_file = '/data/www/www.111cn.net/log/www.111cn.net.log'# Ip shield functionDef shellcmd (ip, con ):OS. system ('/root/shell/nginx/
regular file under the directory, pattern specifies the regular expression, and the negate and what mates are used to indicate that this line belongs to the forward when it does not match the pattern. This accumulates until the line that matches the pattern ends as a line of content.extension: The Application log is often used for log4j, although this type of log
Customize the key value to match the number of Nginx error log occurrences 1 minutes ago.Nginx_error_log Log Format:2016/12/05 21:01:29 [ERROR] 13672#0: *440841 open () "/data/didipingang/steel-front/js/libs/ Angular-file-upload.js.map "failed (2:no such file or directory), client:10.10.1.27, Server: _, Request:" get/j
->{arg}) and\ $event->{hostname}=\ "$HOSTNAME \" "/data/mysql/ mysql3307/data/slow.log-$ (date+%y%m%d) Endscript}You can also place the configuration file in the/ETC/LOGROTATE.D directory by executing the logrotate-f mysql.slow.conf with a timed task.10.10.206.93 Operation Ibid.Note:(1) Log switch, you can also write a script, the method is not limited.(2) currently does not support 5.7 of the database, the
-- Create a temporary table to store the system error information createtablesuperflow (cust_idnumber (10), cust_namevarchar2 (100), dvarchar (50), error_in
-- Create a temporary table to store system error information: create table superflow (cust_id number (10), cust_name varchar2 (100), d varchar (50), error_in
-- Create a temporary table to store system error informationCreate table superflow (cust_id number (10), cust_name varchar2 (100), d varchar (50), error_info varchar2 (500), clie
A simple log monitoring script with the following functions: 1.windows environment 2. When the log keyword is matched, a sound is emitted, different keywords are matched, and different sounds are played 3. Real-time response possible
Note: It is in the win environment OH
Go directly to the code.
#!/usr/bin/env python# encoding:utf-8 "" "monitorlog.py Usage:Monit
We often need to know the server's real-time monitoring of the health of the server, such as which URLs are the largest number of visits, the server per second requests, which search engine is crawling our site? Faced with these problems, although we can go to the analysis of the statistical access log files, but it can not let us real-time statistics, can not give us intuitive statistical data. Now, apache
A process is running and constantly writing logs. You need to monitor log file updates in real time (usually used in debug). What should you do? Keep opening and closing files? No. There are at least two methods from two frequently-used commands:
Tail-F log.txt, another process is writing logs, and you can use tail to print new content in real time.
Less log.txt. If you want to monitor updates, press F.
, Head-n 100 will display the first 100 lines
More queries
Maximum access per minute
awk ' {print $} ' Access_log |cut-c 14-18|sort|uniq-c|sort-nr|head the
highest hourly access number
awk ' {print $} ' acces S_log |cut-c 14-15|sort|uniq-c|sort-nr|head-n
Specifies the number of accesses per second of a minute
grep ' 01/nov/2013:15:59 ' access.log | cut-d ' ["- F 2 | awk ' {print $} ' | Sort | uniq-c | Sort-nr | Head-60
2. Record CPU and memory usage to
In general, the log first reflects the application of the current problem, in the mass log found in our abnormal records, and then recorded, and according to the situation alarm, we can monitor the system log, Nginx, Apache, business log. Here I take the common MySQL log to
Tags: thread use star Das Plog related detail output and When using a Linux system, consume CPU resources too high and use scripting to troubleshoot:1, real-time monitoring, once there is a high CPU consumption process, the program starts;2, then the process analysis, to draw the corresponding thread;3, the corresponding thread is located in the program log document analysis, such as Websphere Middleware ha
There is a access.log log, formatted as follows, with each line starting with an IP address:1. Demand:#1, if you access more than 200 times within the same IP address 60s, add IP to blacklist#需求分析: #1, 60 seconds to read a file #2, split, take the first element, IP address #3, add all the IP to a list, if the IP number more than 200 times, blacklistImport timePoint = 0 #文件指针While True: IPS = [] #存放
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.