1. Under Windows Python code import mysqldb errorImport MySQLdbImporterror:no module named MySQLdb2.Python Connect to database, note to specify character setImport MySQLdbdb = MySQLdb.connect (host = ' 192.168.1.101 ', user = ' user ', passwd = ' password ', db= ' PERFDB ', charset= ' UTF8 ')cursor = Db.cursor ()3.Kali Linux turn on MySQL remote accessKali default MySQL only allows native access, so you nee
Python (2.7.6) Standard Log Module, python2.7.6
In addition to using the basicConfig method in the logging module to configure logs, in the logging. config module of Python, The dictConfig and fileConfig methods support Logger, Handler, and Formatter configuration through dictionaries and files respectively. The following uses an example to illustrate how to use
This article describes how to use a Python script to easily enable the default browser to log on to the user and enable QQ. It involves Python related operations on browsers and applications. The code is very simple and practical, for more information, see the following example. We will share this with you for your reference. The details are as follows:
The fi
1. Requires root user execution2. The Hosts.deny file will be generated in the directory where the script resides, and the data is storedScript to Serve "I rookie, do not spray ah":#!/usr/bin/python#_*_coding:utf-8_*_importtimeimportreimportsysimport Osfromdatetimeimportdatelogfile=r '/var/log/secure ' current_path= Sys.path[0]denyfile=r '/' +current_path+ '/host
indicates the current time in the string format; % (levelname) s, for logger. debug, it is DEBUG, if it is logger. error, it is ERROR; % (message) s, if there is a logger. warning ("HAHA") is the string HAHA at the % (message) s position. The more detailed format is as follows:
% (Name) s
Logger name
% (Levelno) s
Log level in digital form
% (Levelname) s
Log level in t
For N reasons, a task for analyzing intrusion logs falls on me. How can I quickly analyze 1 GB of logs ?? Shi said that he could make a script to parse the database and then analyze it in the database... If you forget it, it hurts. Simply code a script to analyze the problematic logs. So we have this little script. As for how to use it, it depends on yourself. Haha, for example, if you find the SQL Injection statement and then see the IP address, you
In addition to using the Basicconfig method in the logging module to configure the log, the Dictconfig and Fileconfig methods in Python's Logging.config module support the configuration of Logger, Handl, and files by dictionary and file respectively. ER and Formatter. Here is an example of how to use the file configuration lo
The maintenance script is a bit confusing, just as an example of how to quickly use the tool to achieve the goal quickly:
Apply to: Shell and Python data interaction, data capture, encoding conversion
The code is as follows:
#coding: Utf-8#!/usr/bin/python'''Program Description: Apache access.log log AnalysisAnalysis of access to website IP sourcesDate: 2014-01
The connection failure log for killing tornado in python, pythontornado
Tornado is really comfortable, and many things are done for you.
But there is also something unsatisfactory-For me, it is intolerable to automatically print out uncontrolled information to my console.
Connect to a new location. If the connection fails, tornado will use the python
Use this program to analyze errors or other error keywords in/var/log/message. And after the discovery of the collection, send mail operations management personnel.You can define additional functions, such as obtaining the IP address of the server. Placed in the message content. Send an email together.#!/usr/bin/env/python#coding: UTF8Import commandsImport Os,sysImport datetimeImport time#import file_seekwo
Copy codeThe Code is as follows: import OS
Import sys
Import ftplib
Import socket
######################################## ########################### Sign in the ftp server and download the log file.# Log on to the production server to download logs######################################## #########################Def getServerLog (dir, fileName, host, userName,
Copy Code code as follows:
Import OS
Import Sys
Import Ftplib
Import socket
################################################################### Sign in the FTP server and download the log file.# Login to production server download log#################################################################def getserverlog (Dir,filename,host,username,password)
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 Linux's command tail-f to dynamically monitor ne
options for use
That's why THE PEP 0263 is only given to Python's official advice.
This recommendation is:
Allows in a python file, by the beginning of the file, placed in the comments, in the form of a string, declaration of its own python file, with what encoding.
FTP Server1) Read file name2) Check if the file exists3) Open File4) Check the file size5) Send file size to client6) such as client confirmation7) Start reading and sending data on the side Download FileClient#-*-coding:utf-8-*-__author__='Shisanjun'ImportSocketImportJSONImportOshost=("127.0.0.1", 9000) Client=Socket.
We need to retrieve the logs from the remote machine and analyze the logs. the logs are directly uploaded and backed up by dumpel.exe. I didn't find any better tools at the moment, but I had python in my hand. Below is a simple
Source code Only meet your current needs
1
#
-*-Coding: cp936 -*-
2
Def
Usage ():
3
Print
'
-F Windows event log. EVT format backup
'
4
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.