# -*- 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('D:/alert_test1.log','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<=count_2:
print(line.strip())
#else:
#print(line.strip())
f.close()
def main():
yday,tday=time_check()
#yday=time_check(argv1)
#tday=time_check(argv2)
#print yday,tday
#print yday
#print tday
print "------當(dāng)前時(shí)間截止到昨天全天的所有數(shù)據(jù)庫(kù)告警日志--------"
print " 當(dāng)前獲取日志時(shí)間:"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');
print "------當(dāng)前時(shí)間截止到昨天全天的所有數(shù)據(jù)庫(kù)告警日志--------"
chk_db_log(yday,tday)
if __name__ == "__main__":
main()
名稱(chēng)欄目:獲取一周內(nèi)的告警日志(python|Oracle)
本文網(wǎng)址:http://jinyejixie.com/article28/pshjcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、ChatGPT、微信公眾號(hào)、企業(yè)建站、自適應(yīng)網(wǎng)站、服務(wù)器托管
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)