Python網路裝置巡檢(異常自動報警)
思想
1、python抓取交換機的資訊
2、提取需要的檢查結果,並寫入excel表格
3、如果某一檢查結果超出閾值或不符合某一關鍵字,自動傳送報警郵件
4、每十分鐘執行一次python程式碼
程式碼
抓取交換機資訊
import pexpect
import sys
import datetime
import os
#today=datetime.date.today().strftime('%Y%m%d')
print(3)
ip='x.x.x.x'
passwd='xxxx'
txt='F5hexin.txt'
name='<F5-Core-S12508>'
name1="---- More ----"
child=pexpect.spawn('telnet %s'%ip)
fout=open('/root/F5Core/Core/'+txt,'wb+')
child.logfile = fout
child.expect('login:')
child.sendline("admin")
child.expect('(?i)ssword:')
child.sendline("%s"%passwd)
child.expect("%s"%name)
child.sendline("display power")
child.expect("%s"%name)
child.sendline("display version" )
for i in range(20):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display environment")
break
for i in range(20):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display fan" )
break
for i in range(10):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display cpu-usage")
break
for i in range(10):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display memory")
break
for i in range(10):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display interface brief")
break
for i in range(10):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("dis logbuffer")
break
for i in range(50):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display ip routing-table")
break
for i in range(50):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("display irf link ")
break
for i in range(3):
index = child.expect([name1,"%s"%name])
if ( index == 0 ):
child.send(" ")
else:
child.sendline("quit")
sys.exit()
程式碼
匹配閾值,報警
#coding:utf-8
import pymssql
import xlwt
import datetime
from xlwt import *
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib
import datetime
from email import encoders
from email.mime.image import MIMEImage
from email.mime.base import MIMEBase
import re
import xlrd
file = open('/root/F5Core/Core/F5hexin.txt','r+')
listlist=file.readlines()
i=1
for line in listlist:#匹配檢查結果,超出閾值,把結果換成error。
if '<F5-Core-S12508>display power' in line:
power11=listlist[i+6][8:15].strip()
if power11 != 'Normal':
power11='Error'
print(power11)
power12=listlist[i+8][8:15].strip()
if power12 != 'Normal':
power12='Error'
print(power11)
power13=listlist[i+10][8:15].strip()
if power13 != 'Normal':
power13='Error'
print(power11)
power14=listlist[i+12][8:15].strip()
if power14 != 'Normal':
power14='Error'
print(power11)
power21=listlist[i+28][8:15].strip()
if power21 != 'Normal':
power21='Error'
print(power11)
power22=listlist[i+30][8:15].strip()
if power22 != 'Normal':
power22='Error'
print(power11)
power23=listlist[i+32][8:15].strip()
if power23 != 'Normal':
power23='Error'
print(power23)
power24=listlist[i+34][8:15].strip()
if power24 != 'Normal':
power24='Error'
print(power24)
if 'MPU(M) Chassis 1 Slot 0:' in line:
time11=listlist[i+1][9:].strip()
print(time11)
if 'LPU Chassis 1 Slot 2:' in line:
time12=listlist[i+1][9:].strip()
print(time12)
if 'MPU(S) Chassis 2 Slot 0:' in line:
time13=listlist[i+1][9:].strip()
print(time13)
if 'LPU Chassis 2 Slot 2:' in line:
time14=listlist[i+1][9:].strip()
print(time14)
if '<F5-Core-S12508>display environment' in line:
environment11=listlist[i+10][26:29].strip() + ' ' + listlist[i+12][26:29].strip()
environment12=listlist[i+14][26:29].strip() + ' ' + listlist[i+16][26:29].strip()+ ' ' + listlist[i+18][26:29].strip()
environment13=listlist[i+46][26:29].strip() + ' ' + listlist[i+51][26:29].strip()
environment14=listlist[i+53][26:29].strip() + ' ' + listlist[i+55][26:29].strip()+ ' ' + listlist[i+57][26:29].strip()
if int(listlist[i+10][26:29].strip()) > 70:
environment11='Error'
print(environment11)
if int(listlist[i+12][26:29].strip()) > 70:
environment11='Error'
print(environment11)
if int(listlist[i+14][26:29].strip()) > 70:
environment12='Error'
print(environment12)
if int(listlist[i+16][26:29].strip()) > 70:
environment12='Error'
print(environment12)
if int(listlist[i+18][26:29].strip()) > 70:
environment12='Error'
print(environment12)
if int(listlist[i+46][26:29].strip()) > 70:
environment13='Error'
print(environment13)
if int(listlist[i+51][26:29].strip()) > 70:
environment13='Error'
print(environment13)
if int(listlist[i+53][26:29].strip()) > 70:
environment14='Error'
print(environment14)
if int(listlist[i+55][26:29].strip()) > 70:
environment14='Error'
print(environment14)
if int(listlist[i+57][26:29].strip()) > 70:
environment14='Error'
print(environment14)
if '<F5-Core-S12508>display fan' in line:
fana11=listlist[i+6][-8:].strip()
if fana11 != 'Normal':
fana11='Error'
print(fana11)
fana12=listlist[i+26][-8:].strip()
if fana12 != 'Normal':
fana12='Error'
print(fana12)
fana13=listlist[i+53][-8:].strip()
if fana13 != 'Normal':
fana13='Error'
print(fana13)
fana14=listlist[i+73][-8:].strip()
if fana14 != 'Normal':
fana14='Error'
print(fana14)
if 'Chassis 1 Slot 0 CPU 0 CPU usage:' in line:
cpu11=listlist[i+5][6:10].strip()
if int(re.sub('%','',cpu11)) > 30:
cpu11='Error'
print(cpu11)
if 'Chassis 1 Slot 2 CPU 0 CPU usage:' in line:
cpu12=listlist[i+5][6:10].strip()
if int(re.sub('%','',cpu12)) > 30:
cpu12='Error'
print(cpu12)
if 'Chassis 2 Slot 0 CPU 0 CPU usage:' in line:
cpu13=listlist[i+5][6:10].strip()
if int(re.sub('%','',cpu13)) > 30:
cpu13='Error'
print(cpu13)
if 'Chassis 2 Slot 2 CPU 0 CPU usage:' in line:
cpu14=listlist[i+8][6:10].strip()
if int(re.sub('%','',cpu14)) > 30:
cpu14='Error'
print(cpu14)
if '<F5-Core-S12508>display memory' in line:
memory11=listlist[i+8][-6:].strip()
if float(re.sub('%','',memory11)) < 30.0:
memory11='Error'
print(memory11)
memory12=listlist[i+20][-6:].strip()
if float(re.sub('%','',memory12)) < 30.0:
memory12='Error'
print(memory12)
memory13=listlist[i+110][-6:].strip()
if float(re.sub('%','',memory13)) < 30.0:
memory13='Error'
print(memory13)
memory14=listlist[i+122][-6:].strip()
if float(re.sub('%','',memory14))< 30.0:
memory14='Error'
print(memory14)
if 'RAGG1 ' in line:
briefa11=line[20:30].strip()
if briefa11 != 'UP UP':
briefa11='Error'
print(briefa11)
if 'RAGG2 ' in line:
briefa12=line[20:30].strip()
if briefa12 != 'UP UP':
briefa12='Error'
print(briefa12)
if 'RAGG3 ' in line:
briefa13=line[20:30].strip()
if briefa13 != 'UP UP':
briefa13='Error'
print(briefa13)
if 'RAGG4 ' in line:
briefa14=line[20:30].strip()
if briefa14 != 'UP UP':
briefa14='Error'
print(briefa14)
if 'RAGG125 ' in line:
briefa15=line[20:30].strip()
if briefa15 != 'UP UP':
briefa15='Error'
print(briefa15)
if 'Current messages:' in line:
log11=line[-5:].strip()
if int(log11)> 530:
log11='Error'
print(log11)
if 'Routes :' in line:
routingtable11=line[-5:].strip()
if int(routingtable11)< 240:
routingtable11 = 'Error'
print(routingtable11)
if 'Ten-GigabitEthernet1/2/0/47(MDC1)' in line:
IRF11=line[-10:].strip()
if IRF11 != 'UP':
IRF11='Error'
print(IRF11)
if 'Ten-GigabitEthernet1/2/0/48(MDC1)' in line:
IRF12=line[-10:].strip()
if IRF12 != 'UP':
IRF12='Error'
print(IRF12)
if 'Ten-GigabitEthernet2/2/0/47(MDC1)' in line:
IRF13=line[-10:].strip()
if IRF13 != 'UP':
IRF13='Error'
print(IRF13)
if 'Ten-GigabitEthernet2/2/0/48(MDC1)' in line:
IRF14=line[-10:].strip()
if IRF14 != 'UP':
IRF14='Error'
print(IRF14)
i += 1
workbook = xlwt.Workbook()
style = XFStyle()
pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = Style.colour_map['red'] #設定單元格背景色為藍色
style.pattern = pattern
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style.borders = borders
font = xlwt.Font()
font.name = 'Arial' #字型型別
font.colour_index = 0 #字型顏色
font.height = 280 #字型大小
style.font = font
al = xlwt.Alignment()
al.horz = 0x02 # 設定水平居中
al.vert = 0x01 # 設定垂直居中
style.alignment = al
style1 = XFStyle()
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style1.borders = borders
style2 = XFStyle()
al = xlwt.Alignment()
al.horz = 0x02 # 設定水平居中
al.vert = 0x01 # 設定垂直居中
style2.alignment = al
style3 = XFStyle()
borders = xlwt.Borders()
borders.left = 1
#borders.left = xlwt.Borders.THIN
borders.right = 1
borders.top = 1
borders.bottom = 1
style3.borders = borders
al = xlwt.Alignment()
al.horz = 0x02 # 設定水平居中
al.vert = 0x01 # 設定垂直居中
style3.alignment = al
F5Core = workbook.add_sheet('F5核心狀態資訊',cell_overwrite_ok=True)
first_col=F5Core.col(0)
sec_col=F5Core.col(1)
thr_col=F5Core.col(2)
for_col=F5Core.col(3)
five_col=F5Core.col(4)
six_col=F5Core.col(5)
first_col.width=150*25
sec_col.width=150*25
thr_col.width=120*25
for_col.width=180*25
five_col.width=360*25
six_col.width=400*25
F5Core.write_merge(1,39,0,0,'F5Core_12508',style3)
F5Core.write_merge(1,39,1,1,'10.20.5.254',style3)
F5Core.write(0,0,'裝置名稱',style)
F5Core.write(0,1,'管理地址',style)
F5Core.write(0,2,'檢查項',style)
F5Core.write_merge(0,0,3,4,'位置',style)
F5Core.write(0,5,'檢查結果',style)
F5Core.write_merge(1,8,2,2,'裝置狀態',style3)
F5Core.write_merge(9,12,2,2,'執行時間',style3)
F5Core.write_merge(13,16,2,2,'執行溫度',style3)
F5Core.write_merge(17,20,2,2,'風扇狀態',style3)
F5Core.write_merge(21,24,2,2,'CPU使用率',style3)
F5Core.write_merge(25,28,2,2,'記憶體空置率',style3)
F5Core.write_merge(29,33,2,2,'聚合口',style3)
F5Core.write_merge(34,37,2,2,'IRF',style3)
F5Core.write(38,2,'日誌條目',style3)
F5Core.write(39,2,'路由條目',style3)
F5Core.write_merge(1,4,3,4,'Chassis 1',style3)
F5Core.write_merge(5,8,3,4,'Chassis 2',style3)
F5Core.write_merge(9,9,3,4,'MPU(M) Chassis 1 Slot 0',style3)
F5Core.write_merge(10,10,3,4,'LPU Chassis 1 Slot 2',style3)
F5Core.write_merge(11,11,3,4,'MPU(S) Chassis 2 Slot 0',style3)
F5Core.write_merge(12,12,3,4,'LPU Chassis 2 Slot 2',style3)
F5Core.write_merge(13,14,3,3,'Chassis 1',style3)
F5Core.write_merge(15,16,3,3,'Chassis 2',style3)
F5Core.write_merge(17,18,3,3,'Chassis 1',style3)
F5Core.write_merge(19,20,3,3,'Chassis 2',style3)
F5Core.write_merge(21,22,3,3,'Chassis 1',style3)
F5Core.write_merge(23,24,3,3,'Chassis 2',style3)
F5Core.write_merge(25,26,3,3,'Chassis 1',style3)
F5Core.write_merge(27,28,3,3,'Chassis 2',style3)
F5Core.write_merge(29,29,3,3,'RAGG1',style3)
F5Core.write_merge(30,30,3,3,'RAGG2',style3)
F5Core.write_merge(31,31,3,3,'RAGG3',style3)
F5Core.write_merge(32,32,3,3,'RAGG4',style3)
F5Core.write_merge(33,33,3,3,'RAGG125',style3)
F5Core.write_merge(34,35,3,3,'Member 1',style3)
F5Core.write_merge(36,37,3,3,'Member 2',style3)
F5Core.write_merge(38,38,3,4,'',style3)
F5Core.write_merge(39,39,3,4,'',style3)
F5Core.write_merge(13,13,4,4,'slot0',style3)
F5Core.write_merge(14,14,4,4,'slot2',style3)
F5Core.write_merge(15,15,4,4,'slot0',style3)
F5Core.write_merge(16,16,4,4,'slot2',style3)
F5Core.write_merge(17,17,4,4,'Fan-tray 1',style3)
F5Core.write_merge(18,18,4,4,'Fan-tray 2',style3)
F5Core.write_merge(19,19,4,4,'Fan-tray 1',style3)
F5Core.write_merge(20,20,4,4,'Fan-tray 2',style3)
F5Core.write_merge(21,21,4,4,'slot0',style3)
F5Core.write_merge(22,22,4,4,'slot2',style3)
F5Core.write_merge(23,23,4,4,'slot0',style3)
F5Core.write_merge(24,24,4,4,'slot2',style3)
F5Core.write_merge(25,25,4,4,'slot0',style3)
F5Core.write_merge(26,26,4,4,'slot2',style3)
F5Core.write_merge(27,27,4,4,'slot0',style3)
F5Core.write_merge(28,28,4,4,'slot2',style3)
F5Core.write_merge(29,29,4,4,'To_F1-N7K',style3)
F5Core.write_merge(30,30,4,4,'To_F1-N7K-S',style3)
F5Core.write_merge(31,31,4,4,'F5 MIS TO F5 QMS',style3)
F5Core.write_merge(32,32,4,4,'F5 MIS TO F5 JMET',style3)
F5Core.write_merge(33,33,4,4,'To_F5-server-HJ-S7502E_RAGG',style3)
F5Core.write_merge(34,34,4,4,'Ten-GigabitEthernet1/2/0/47(MDC1)',style3)
F5Core.write_merge(35,35,4,4,'Ten-GigabitEthernet1/2/0/48(MDC1)',style3)
F5Core.write_merge(36,36,4,4,'Ten-GigabitEthernet2/2/0/47(MDC1) ',style3)
F5Core.write_merge(37,37,4,4,'Ten-GigabitEthernet2/2/0/48(MDC1)',style3)
F5Core.write(1,5,power11,style3)
F5Core.write(2,5,power12,style3)
F5Core.write(3,5,power13,style3)
F5Core.write(4,5,power14,style3)
F5Core.write(5,5,power21,style3)
F5Core.write(6,5,power22,style3)
F5Core.write(7,5,power23,style3)
F5Core.write(8,5,power24,style3)
F5Core.write(9,5,time11,style3)
F5Core.write(10,5,time12,style3)
F5Core.write(11,5,time13,style3)
F5Core.write(12,5,time14,style3)
F5Core.write(13,5,environment11,style3)
F5Core.write(14,5,environment12,style3)
F5Core.write(15,5,environment13,style3)
F5Core.write(16,5,environment14,style3)
F5Core.write(17,5,fana11,style3)
F5Core.write(18,5,fana12,style3)
F5Core.write(19,5,fana13,style3)
F5Core.write(20,5,fana14,style3)
F5Core.write(21,5,cpu11,style3)
F5Core.write(22,5,cpu12,style3)
F5Core.write(23,5,cpu13,style3)
F5Core.write(24,5,cpu14,style3)
F5Core.write(25,5,memory11,style3)
F5Core.write(26,5,memory12,style3)
F5Core.write(27,5,memory13,style3)
F5Core.write(28,5,memory14,style3)
F5Core.write(29,5,briefa11,style3)
F5Core.write(30,5,briefa12,style3)
F5Core.write(31,5,briefa13,style3)
F5Core.write(32,5,briefa14,style3)
F5Core.write(33,5,briefa15,style3)
F5Core.write(34,5,IRF11,style3)
F5Core.write(35,5,IRF12,style3)
F5Core.write(36,5,IRF13,style3)
F5Core.write(37,5,IRF14,style3)
F5Core.write(38,5,log11,style3)
F5Core.write(39,5,routingtable11,style3)
print ('建立excel檔案完成!')
workbook.save('/root/F5Core/F5Core.xls')
workbook = xlrd.open_workbook('/root/F5Core/F5Core.xls')
#輸出Excel檔案中所有sheet的名字
print(workbook.sheet_names())
# 根據sheet索引或者名稱獲取sheet內容
Data_sheet = workbook.sheets()[0] # 通過索引獲取
# Data_sheet = workbook.sheet_by_index(0) # 通過索引獲取
# Data_sheet = workbook.sheet_by_name(u'名稱') # 通過名稱獲取
# 輸出所有單元格的內容
"""for i in range(rowNum):
for j in range(colNum):
print(list[i][j], '\t\t', end="")
print()"""
print(Data_sheet.name) # 獲取sheet名稱
rowNum = Data_sheet.nrows # sheet行數
colNum = Data_sheet.ncols # sheet列數
# 獲取所有單元格的內容
list = []
for i in range(rowNum):
rowlist = []
for j in range(colNum):
rowlist.append(Data_sheet.cell_value(i, j))
list.append(rowlist)
print(rowlist)
for listlist in list:
if 'Error' == listlist[-1]:
def sendmail():
#建立一個帶附件的例項
msg = MIMEMultipart()
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
file1 = MIMEBase(maintype, subtype)
file1.set_payload(open(r'/root/F5Core/F5Core.xls', 'rb').read())
file1.add_header('Content-Disposition', 'attachment', filename='F5核心巡檢異常.xls')
encoders.encode_base64(file1)
msg.attach(file1)
msg_to=['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]']
msg['from'] = '[email protected]'
msg['subject'] = u"F5核心有異常"
msg.attach(MIMEText('F5核心出現異常', 'plain', 'utf-8'))
#傳送郵件
msg['to'] =','.join(msg_to)#群發需要增加的,隱藏收件人不需要此行,直接呼叫msg_to就可以
server = smtplib.SMTP()
server.connect('10.17.37.96',25)
#server.sendmail(msg['from'], msg['to'],msg.as_string()) 單獨一個收件人
server.sendmail(msg['from'], msg['to'].split(','), msg.as_string())#收件人為多個
#server.sendmail(msg['from'], msg_to, msg.as_string())
server.quit()
return '傳送成功'
print (sendmail())
自動執行程式碼
Linux crontab
結果
1、正常巡檢結果
2、出現異常報警的巡檢結果
相關推薦
Python網路裝置巡檢(異常自動報警)
思想 1、python抓取交換機的資訊 2、提取需要的檢查結果,並寫入excel表格 3、如果某一檢查結果超出閾值或不符合某一關鍵字,自動傳送報警郵件 4、每十分鐘執行一次python程式碼 程式碼 抓取交換機資訊 import pexpect i
Python3網路裝置巡檢(交換機篇)
介紹 只寫了交換機的,路由器、防火牆、負載等其它裝置以後,有需求再寫,下面以一組交換機為例。 思路 1、收取交換機的資訊 需要哪些資訊,哪些命令,不同品牌交換機命令不同(本篇以H3C為例),需要提前規劃好。交換機的IP、名字、密碼等資訊,寫
Python測試環境巡檢工具
Python測試環境巡檢 測試過程中,由於測試環境機器較多且全都是在虛擬機器上做的,經常會有某些機器掛掉導致站點訪問出錯的問題,手動去一個一個Ping實在是麻煩,於是用Python寫了一個小指令碼,來批量Ping測試。 實現思路: 一、設計要求: 1.目標機器的IP可配置
python自動化巡檢
python 自動化巡檢 #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "chenhao" # Email:[email protected] # Date: 2017/8/22 import paramiko
服務器自動巡檢shell腳本
服務器自動巡檢 巡檢腳本 shell腳本 #!/bin/sh #定義檢查操作系統版本的函數 NUM_VERSION=$(uname -r) function Check_OS(){ [[ $NUM_VERSION =~ el6 ]] && return 0||return 1 }
Linux伺服器記憶體、CPU、檔案系統、磁碟IO效能以及網路連通性shell巡檢
shell自動巡檢伺服器基礎配置 每個專案都要部署在伺服器上,那麼伺服器的安全效能和一些基本情況是我們需要了解的,比如伺服器CPU、記憶體、檔案系統、磁碟IO、還有一些網路連通性
rsyslog+elk 網路裝置日誌收集及釘釘報警
目錄 一.概要 二.實施 1.資料來源 2.rsyslog 3.elasticsearch 4.logstash 5.kibana 三.日誌展示 1.開啟kibana頁面 四·釘釘報警 1.elastalert 2.dingtalk 3
人生苦短,我用Python(三)—通過Python實現網路裝置指定指標的收集與指標的圖形化展示
寫在前面: 博主自2018年8月底開始,堅持每週更新一篇技術類部落格,含本篇文章在內,目前已經更新了八篇文章。除十一假期外,堅持每週更新。希望自己能堅持下去。 目前已經開啟了三個系列的文章,分別是: 《人生苦短,我用Python》——已釋出三篇文章 《那些你應該知道的
SecureCRT使用VBS指令碼自動備份網路裝置配置,目前支援部分H3C及dptech
根據網路上的指令碼自行搗鼓了下crt自動備份,歡迎各網路管理員試用及提出優化建議。H3C備份方式主要為cfg通過TFTP匯出,dptech為螢幕記錄,請自行準備獨立TFTP工具。 #$language = "VBScript" #$interface = "1.0" D
python 網路爬蟲與資訊採取之異常處理
本篇文章轉自Ryan Mitchell 寫的python:網路資料採集 網路是十分複雜的。網頁資料格式不友好,網站伺服器宕機,目標資料的標籤找不到,都是很麻煩的事情。網路資料採集最痛苦的遭遇之一,就是爬蟲執行的時候你洗洗睡了,夢想著明天一早資料就都會採集好放在
python-網路爬蟲初學三:網路異常的捕獲
一、URLError產生原因 # 網路無連線,即本機無法上網 # 連線不到特定伺服器 # 伺服器不存在 # 使用try-except捕獲異常 request = urllib2.Request("http://www.xxxxx.com") try: urllib2
Python網路程式設計 ---Socket模組學習之獲取遠端裝置IP(二)
1、使用內建庫函式gethostbyname(),引數為遠端裝置的主機名。新建檔案 getremotemachineinfo.py#!/usr/bin/python import socket def get_remote_machine_info(): remote
用Python怎麼SSH到網路裝置
[ TOC ] 0. 前言 自上一篇文章《用python怎麼telnet到網路裝置》,簡單使用了telnetlib庫給大家演示了下
十六.監控系統cpu.內存,磁盤等,自動報警,發送郵件
subject sub percent tmp 工具 exc sendmai join pri 發送郵箱小工具,將它放在#/usr/bin/mail chmod +x /usr/bin/mail #!/usr/bin/python #-*- coding: UTF-8 -
DBA巡檢常用的SQL語句
dba巡檢常用的sql語句1.查看當前數據庫有多少processselect count(1) from v$process;2.查看當前數據庫有多少session(session=process*1.1)select count(1) from v$session;3.查看當前執行的SQL語句select
滲透測試02------windows日常巡檢,應急響應等總結
windows 日常巡檢 應急響應等 一:日常巡檢:1.日誌: a:事件查看器中,查看日誌。應用程序,安全性,系統,觀察是否被入侵。 b:查看歷史記錄在c:\DOCUMENTS AND SETTINGS c:修改後門賬號密碼。進去查看歷史瀏覽網頁等一
Python 小程序-微信AI自動回復
ges images 微信 ccf try 消息 .post style register 一簡介 使用itcha實現微信登錄及消息發送接收,使用圖靈AI實現智能回復。 參考API: http://www.tuling123.com/ https://itchat.re
python學習筆記8:異常處理
mage 可能 str 裏的 tro 信息 學習筆記 異常信息 常見 一、異常處理 在程序運行過程中,總會遇到各種各樣的錯誤。 程序一出錯就停止運行了,那我們不能讓程序停止運行吧,這時候就需要捕捉異常了,通過捕捉到的異常,我們再去做對應的處理。 如下,寫段代碼,
Python之操作Excel、異常處理、網絡編程
方法 ssi request 對象的引用 深拷貝 code text 索引超出 編號 知識補充: 1.falsk模塊中一些方法總結 import flask from flask import request,jsonify server = flask.Flask(_
自己搭建自動化巡檢系統(一) 環境準備系統連接gns3
自動化 巡檢 這系列的博文,講述一個自制的自動巡檢系統,僅僅是在cisco設備中運行,之後會基於這個思路,寫出一個兼容性的通用巡檢系統,傳統網工對網絡設備是非常熟悉的,然而在編程開發這一塊是相對弱勢一點。我在想在SDN的背景下,網工一旦會編程,該有多麽強勢,一些重復執行的步驟,電腦代勞,