獲取一週內的告警日誌(python|Oracle)
# -*- 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 "------當前時間截止到昨天全天的所有資料庫告警日誌--------"
print " 當前獲取日誌時間:"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');
print "------當前時間截止到昨天全天的所有資料庫告警日誌--------"
chk_db_log(yday,tday)
if __name__ == "__main__":
main()
#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 "------當前時間截止到昨天全天的所有資料庫告警日誌--------"
print " 當前獲取日誌時間:"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');
print "------當前時間截止到昨天全天的所有資料庫告警日誌--------"
chk_db_log(yday,tday)
if __name__ == "__main__":
main()
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-2143412/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 獲取兩天內的告警日誌(bash|shell|oracle)Oracle
- 獲取兩天內的告警日誌(AIX|ksh|shell|oracle)AIOracle
- Zabbix如何監控Oracle的告警日誌Oracle
- Oracle 自動化運維-Python監控Oracle告警日誌Oracle運維Python
- Oracle告警日誌ora-04030Oracle
- oracle12告警日誌檔案?Oracle
- 使用外部表管理Oracle 告警日誌Oracle
- Oracle 11g 中告警日誌的位置Oracle
- ORACLE 告警日誌alert過大的處理Oracle
- 利用外部表讀取告警日誌檔案
- Oracle redo日誌內容探索(一)Oracle Redo
- 【ELK】elastalert 日誌告警AST
- 告警日誌介紹
- Oracle之備份和清理監聽日誌、告警日誌指令碼Oracle指令碼
- RAC的告警日誌檔案
- Oracle 跟蹤/告警/監聽日誌的清理指令碼Oracle指令碼
- Oracle的告警日誌之v$diag_alert_ext檢視Oracle
- 智慧手環core日誌獲取
- 智慧手環guard日誌獲取
- 獲取Tomcat更詳細的日誌Tomcat
- java獲取指定日期所在周的 週一 和 週日Java
- 告警日誌出現kewastUnPackStats資訊AST
- ELK日誌告警elastalert2AST
- 一個用python寫的自動監控alert日誌告警資訊的小程式Python
- DB2_獲取診斷日誌DB2
- 【轉】oracle學習筆記(三)之檢查Oracle的告警日誌檔案Oracle筆記
- 使用 adb 命令獲取指定應用的日誌
- 使用外部表管理Oracle 告警日誌(ALAERT_$SID.LOG)Oracle
- 日誌服務之告警接入與管理
- Oracle redo日誌內容探索之二Oracle Redo
- 本地檔案包含之包含日誌獲取webshellWebshell
- java 獲取上月、一個月最後一天、週一、週日、本月日期Java
- apache日誌匯入oracle(日誌經過python處理)ApacheOraclePython
- 日誌和告警資料探勘經驗談
- WKWebView 獲取JS端的console.log日誌WebViewJS
- java獲取redis的日誌資訊和動態監控資訊JavaRedis
- Oracle 日誌管理一例Oracle
- Flutter生命週期的獲取Flutter