Get the App
SLTechnology News&Howtos  ›  Servers  › 

Get the alarm log within one week (python | Oracle)

Shulou Source: shulou.com Published: 2022-06-02 06:51:28 11月16日 Update

#-*-coding:UTF-8-*-

# author: Rui Zhang

# date: 2017-08-09

# email: sharpzhang_2008@126.com

Import datetime

Def time_check ():

Yesterday=datetime.datetime.now ()-datetime.timedelta (days=1)

# yesterday_wk=yesterday.strftime ('% a')

# yesterday_mh=yesterday.strftime ('% b')

# yesterday_dy=yesterday.strftime ('% d')

Yesterday_wmd=yesterday.strftime ('a b d')

Today=datetime.datetime.now ()

# today_wk=today.strftime ('% a')

# today_mh=today.strftime ('% b')

# today_dy=today.strftime ('% d')

Today_wmd=today.strftime ('a b d')

# argv1=yesterday_wmd

# argv2=today_wmd

Return yesterday_wmd,today_wmd

Def chk_db_log (time1,time2):

Count_1=0

Count_2=0

# with open ("D:/alert_test1.log") as f:

F = open ('DRU _ red _ alertalarm _ 1.logbook _ journal _ r')

A = f.readlines ()

For line in a:

Count_1=count_1+1

If time1 in line:

# print time

# print (count)

Break

Elif time2 in line:

Break

For line in a:

Count_2=count_2+1

If count_1

Tags: Log time all day data database cutoff UTF-8 Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Docker Linux macOS