溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

獲取一周內(nèi)的告警日志(python|Oracle)

發(fā)布時(shí)間:2020-08-07 17:36:15 來(lái)源:ITPUB博客 閱讀:220 作者:zhangsharp20 欄目:建站服務(wù)器
# -*- 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()

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI