查看华为防火墙会话和流量top数据
from netmiko.ssh_dispatcher import ConnectHandler
import pymysql
import time
device = {
"device_type": "huawei",
"ip": "ip",
"username": "backup",
"password": "密码",
}
with ConnectHandler(**device) as ssh_conn:
output = ssh_conn.send_command_timing( # command_string可以较好的回显数据
command_string="""
system-view
firewall realtime-statistics enable
diagnose
display firewall online ip traffic top10
display firewall online ip session top10
quit
undo firewall realtime-statistics enable
quit
quit
"""
)
conn = pymysql.connect(host="10.32.236.8",
port=8080,
user="root",
passwd="xxx",
db="firewall",
charset="utf8", )
cursor = conn.cursor(pymysql.cursors.DictCursor)
sql = 'insert into topn(paihang,zhi,time_now) value(%s,%s,%s);'
time_now=time.strftime('%Y-%m-%d %H:%M:%S')
a =0
for s in output.splitlines():
a += 1
if 15 < a < 27 or 34 < a < 46:
try:
num = s.split(' ')
shuzi=num[1] + ':' + num[3]
cursor.execute(sql, (shuzi,num[-1],time_now))
conn.commit()
except Exception as e :
if 16 < a < 27 or 35 < a < 46:
num = s.split(' ')
shuzi=num[1] + ':' + num[3]
cursor.execute(sql, (shuzi, num[-1], time_now))
conn.commit()
—————————————第二版---------------------------------------------------
from netmiko.ssh_dispatcher import ConnectHandler
import pymysql
import time
H3C = {
"device_type": "huawei",
"ip": "ip",
"username": "账号",
"password": "密码",
}
conn = pymysql.connect(host="",
port=8080,
user="root",
passwd="密码",
db="库名",
charset="utf8", )
cursor = conn.cursor(pymysql.cursors.DictCursor)
sql = 'insert into 表名(direction,paihang,time_now) value(%s,%s,%s);'
net_connect = ConnectHandler(**H3C)
net_connect.send_command(command_string='display firewall topn source-ip traffic',expect_string ='')
net_connect.send_command(command_string=r'Y',expect_string = '>',cmd_verify = False)
time.sleep(12)
output = net_connect.send_command(command_string=r'',expect_string = '',cmd_verify = False)
time.sleep(2)
time_now = time.strftime('%Y-%m-%d %H:%M:%S')
cursor.execute(sql, ('source_ip',output,time_now))
time.sleep(1)
# print(output)
net_connect.send_command(command_string='display firewall topn destination-ip traffic',expect_string ='')
time.sleep(14)
outpute = net_connect.send_command(command_string=r'',expect_string = '>',cmd_verify = False)
time.sleep(2)
net_connect.send_command(command_string=r'quit',expect_string = '',cmd_verify = False)
cursor.execute(sql, ('destination_ip',outpute,time_now))
# print(outpute)
conn.commit()
conn.close()
查看华为防火墙会话和流量top数据相关推荐
- 华为防火墙会话 session table
display firewall session table reset firewall session table protocol tcp service http reset firewal ...
- 查看防火墙状态_干货 | 华为防火墙配置,这篇文章强烈推荐收藏学习
1.命令行界面密码:Admin@123 [ ]web-manager enable 开启web 界面管理 2.web界面:默认 admin Admin@123 3.区域 默认区域:trust ...
- 华为防火墙查看日志命令_防火墙接入互联网方式,到底有哪些呢?5分钟学会防火墙入网...
通过静态IP接入互联网 局域网内部所有的PC都不是在10.3.0.0/24网段,均通过DHCP动态获取IP地址.企业从运营商处获取固定的IP地址为1.1.1.1/24.企业需要利用防火墙接入互联网. ...
- ELK+grok+华为防火墙USG6500会话日志
一. 前言 作为一名网络工程师进程要分析网络设备.防火墙设备日志,网上大部分都是通过logstash进行收集syslog日志,但是没有对国产设备防火墙分析.本次项目采用centos 7.2操作系统,e ...
- 华为防火墙如何配置双出口,特定IP段流量走指定出接口地址上网
环境: 华为USG6311E VRP ® Software, Version 5.170 (USG6300E V600R007C00SPC200) V200R007C00SPC091 电信宽带:拨号 ...
- 华为防火墙简介及其工作原理
防火墙作为一种安全设备被广泛使用于各种网络环境中,他在网络间起到了间隔作用.华为作为著名的网络设备厂商,2001年便发布了首款防火墙插卡,而后根据网络发展及技术需求,推出了一代又一代防护墙及安全系列产 ...
- 华为防火墙及它的工作原理
一.华为防火墙产品介绍 USG2000.USG5000.USG6000和USG9500构成了华为防火墙的四大部分,分别适合于不同环境的网络需求,其中,USG2000和USG5000系列定位于UTM(统 ...
- 华为防火墙(NGFW)的双机热备
目录 VRRP技术 VGMP协议 VGMP报文格式 VGMP组管理 HRP HRP心跳接口 双机热备的备份方式 实验 实验拓扑 实验说明 实验配置 实现网络高可靠性的一种技术 VRRP技术 虚拟路由冗 ...
- 华为防火墙VRRP双机热备的配置
双机热备 概念 一.华为双机热备的两种模式 二.相关术语 三.配置 概念 双机热备特指基于高可用系统中的两台服务器的热备(或高可用),因两机高可用在国内使用较多,故得名双机热备,双机高可用按工作中的切 ...
最新文章
- vue调试工具如何使用_教你使用Vue.js的DevTools来调试vue项目
- Zeppelin-源码编译
- 腾讯,字节,阿里,小米,京东大厂Offer拿到手软!绝对干货
- python3里面的图片处理库 pillow
- Netty工作笔记0031---NIO零拷贝应用案例
- 有人问现在做自媒体还有前途吗?还有钱赚吗?
- jetson windows_生命不息,折腾不止:Jetson Nano填坑之软件篇
- 基于情感词典的文本情感分析(一个最简单的举例能直接运行)
- 线报采集监控|人工智能+线报采集算法+大数据过滤无效线报
- (C语言)教师信息管理系统
- 用python开发手机游戏_python开发安卓app
- php日志写什么内容,Monolog-PHP日志类库介绍
- Java参数变量_Java变量参数
- 什么叫数据与程序的物理独立性?什…
- SQL server 获取一周前到两周后之间的所有日期
- element-ui upload上传技巧
- 华为ensp的缺省_利用华为ENSP模拟器分析和配置中小型企业网络的综合实验
- 基于RFID技术的营区车辆管理解决方案-沈阳博能科技
- 设置element ui table表格线条颜色以及设置圆角/解决element ui table设置圆角后线条不显示或显示模糊问题,亲测有效
- Visio标注、批注位置