首页
统计信息
友情链接
壁纸
Search
1
【更新】CommentToMail typecho2017&v4.1& Mailer三版本,支持php5.6/7,插件详解
157,977 阅读
2
CentOS 7安装bbr教程
12,735 阅读
3
纯小白10分钟变身linux建站高手?宝塔linux面板全体验
12,349 阅读
4
深信服超融合架构测试介绍
11,516 阅读
5
优秀的个人博客系统,typecho从入门到精通
7,501 阅读
技术相关
ACG相关
胡言乱语
数码杂烩
登录
Search
标签搜索
进击的巨人
漫画
宝塔
php
typecho
diy
vps
折腾
动漫
优酷路由宝
ubuntu
路由器
QQ
KMS
王忘杰
累计撰写
268
篇文章
累计收到
179
条评论
首页
栏目
技术相关
ACG相关
胡言乱语
数码杂烩
页面
统计信息
友情链接
壁纸
搜索到
236
篇与
的结果
2023-09-01
【MSSQL】SQL SERVER 收缩日志
收缩日志不影响数据库运行,但会影响数据库按日志恢复,进行收缩前应进行数据库完整备份。1、登录数据库,打开要收缩的数据库的属性2、更改数据库恢复模式,“完整”改为“简单”3、收缩数据库日志,在对应数据库上右键,“任务” - “收缩” - “文件”文件类型:日志,收缩大小一般填写2MB4、收缩完成后,将数据库恢复模式改回“完整”5、收缩完成,检查业务系统工作是否正常
2023年09月01日
230 阅读
0 评论
0 点赞
2023-08-21
H3C STP生成树协议与环路检测配置实战
一、环境介绍 本次实验环境为一台H3C S5130交换机,两台TP-LINK TL-SG1008D八口千兆傻瓜交换机,一台TP-LINK TL-SG1005D五口千兆傻瓜交换机。二、实验目的 在各种条件下,测试交换机防环功能和状态,H3C交换机默认STP协议为MSTP协议。三、实验步骤 1、普通环路实验拓扑图关闭STP协议[H3C]un stp global en [H3C]%Jan 1 02:19:16:001 2013 H3C STP/6/STP_DISABLE: STP is now disabled on the device.将交换机1口2口通过网线连接,查看接口状态[H3C]dis int br Interface Link Speed Duplex Type PVID Description GE1/0/1 UP 1G(a) F(a) A 1 GE1/0/2 UP 1G(a) F(a) A 1查看CPU使用率[H3C]dis cpu Slot 1 CPU 0 CPU usage: 3% in last 5 seconds 4% in last 1 minute 3% in last 5 minutes 在网络静默状态下,无广播包,CPU使用率不会飙升将电脑接入交换机,交换机ping电脑,仅一台电脑的网络下,因为环路,CPU使用率即出现飙升,交换机指示灯狂闪,且通讯中断。[H3C]dis cpu Slot 1 CPU 0 CPU usage: 30% in last 5 seconds 31% in last 1 minute 3% in last 5 minutes 在交换机开启STP协议[H3C]stp global en %Jan 1 02:25:56:729 2013 H3C STP/6/STP_ENABLE: STP is now enabled on the device. %Jan 1 02:25:56:775 2013 H3C STP/6/STP_DETECTED_TC: Instance 0's port GigabitEthernet1/0/1 detected a topology change.查看CPU使用率恢复正常[H3C]dis cpu Slot 1 CPU 0 CPU usage: 2% in last 5 seconds 30% in last 1 minute 3% in last 5 minutes 查看接口状态,1 2口仍为UP状态Interface Link Speed Duplex Type PVID Description GE1/0/1 UP 1G(a) F(a) A 1 GE1/0/2 UP 1G(a) F(a) A 1查看STP接口状态,2号口为DISCARDING阻塞状态,防环功能正常启动。[H3C]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI FORWARDING NONE 0 GigabitEthernet1/0/2 BACK DISCARDING NONE 0 GigabitEthernet1/0/15 DESI FORWARDING NONE 2、接入傻瓜交换机形成大环路网络拓扑通过傻瓜交换机串联形成环路,STP工作正常,环路被屏蔽[H3C]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI FORWARDING NONE 0 GigabitEthernet1/0/2 BACK DISCARDING NONE 3、接入傻瓜交换机形成小环路网络拓扑通过傻瓜交换机串联形成小环路,STP工作正常,环路在网管交换机处被屏蔽,但傻瓜交换机等狂闪,仍为环路状态。[H3C]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI DISCARDING NONE 一段时间后,STP进入转发状态,网络瘫痪,即STP可以无法运行在傻瓜交换机上[H3C]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI FORWARDING NONE 4、普通环路检测拓扑图开启基于VLAN的全局环路检测,配置环路检测处理模式为关闭接口,配置检测间隔为35秒[H3C]loopback-detection global enable vlan all [H3C]loopback-detection global action shutdown [H3C]loopback-detection interval-time 35使用网线连接1 2口,查看STP状态[H3C]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI FORWARDING NONE 0 GigabitEthernet1/0/2 BACK DISCARDING NONE 查看接口状态,当STP正常工作时,环路检测不会检测出环路Interface Link Speed Duplex Type PVID Description GE1/0/1 UP 1G(a) F(a) A 1 GE1/0/2 UP 1G(a) F(a) A 1 关闭STP[H3C]un stp global en查看接口状态[H3C]%Jan 1 03:02:05:069 2013 H3C LPDT/4/LPDT_LOOPED: A loop was detected on GigabitEthernet1/0/1. %Jan 1 03:02:05:076 2013 H3C LLDP/6/LLDP_DELETE_NEIGHBOR: Nearest bridge agent neighbor deleted on port GigabitEthernet1/0/2 (IfIndex 2), neighbor's chassis ID is 6893-20d4-f004, port ID is GigabitEthernet1/0/1. %Jan 1 03:02:05:212 2013 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface GigabitEthernet1/0/1 changed to down. %Jan 1 03:02:05:223 2013 H3C IFNET/5/LINK_UPDOWN: Line protocol state on the interface GigabitEthernet1/0/1 changed to down. %Jan 1 03:02:05:227 2013 H3C LPDT/4/LPDT_VLAN_LOOPED: A loop was detected on GigabitEthernet1/0/1 in VLAN 1. 环路的两个接口被关闭,环路检测功能正常Interface Link Speed Duplex Type PVID Description GE1/0/1 DOWN auto A A 1 GE1/0/2 DOWN auto A A 1 5、接入傻瓜交换机形成大环路进行环路检测网络拓扑检测到环路%Jan 1 03:12:36:560 2013 H3C LPDT/4/LPDT_VLAN_LOOPED: A loop was detected on GigabitEthernet1/0/1 in VLAN 1. %Jan 1 03:12:36:560 2013 H3C LPDT/5/LPDT_VLAN_RECOVERED: A loop was removed on GigabitEthernet1/0/11 in VLAN 1. %Jan 1 03:12:36:561 2013 H3C LPDT/5/LPDT_RECOVERED: All loops were removed on GigabitEthernet1/0/11. %Jan 1 03:12:36:563 2013 H3C LPDT/5/LPDT_VLAN_RECOVERED: A loop was removed on GigabitEthernet1/0/1 in VLAN 1. %Jan 1 03:12:36:563 2013 H3C LPDT/5/LPDT_RECOVERED: All loops were removed on GigabitEthernet1/0/1. %Jan 1 03:12:36:571 2013 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface1 changed to down. %Jan 1 03:12:36:572 2013 H3C IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface1 changed to down. 查看接口状态,接口被Loopback关闭,环路检测正常Type: A - access; T - trunk; H - hybrid Interface Link Speed Duplex Type PVID Description GE1/0/1 DOWN auto A A 1 GE1/0/2 DOWN auto A A 1 [H3C]dis interface g1/0/1 GigabitEthernet1/0/1 Current state: DOWN (Loopback detection down) Line protocol state: DOWN 6、接入傻瓜交换机形成小环路进行环路检测网络拓扑环路检测检测到环路,接口被关闭%Jan 1 03:18:51:179 2013 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface GigabitEthernet1/0/1 changed to down. %Jan 1 03:18:51:186 2013 H3C IFNET/5/LINK_UPDOWN: Line protocol state on the interface GigabitEthernet1/0/1 changed to down. %Jan 1 03:18:51:189 2013 H3C LPDT/4/LPDT_VLAN_LOOPED: A loop was detected on GigabitEthernet1/0/1 in VLAN 1. %Jan 1 03:18:51:213 2013 H3C LPDT/5/LPDT_VLAN_RECOVERED: A loop was removed on GigabitEthernet1/0/1 in VLAN 1. %Jan 1 03:18:51:214 2013 H3C LPDT/5/LPDT_RECOVERED: All loops were removed on GigabitEthernet1/0/1. %Jan 1 03:18:51:231 2013 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface1 changed to down. Interface Link Speed Duplex Type PVID Description GE1/0/1 DOWN auto A A 1 GE1/0/2 DOWN auto A A 1但傻瓜交换机的网络仍然为瘫痪状态四、实验总结 网管交换机不可与傻瓜交换机混用1、即使STP与环路检测生效,傻瓜交换机仍为环路满载状态。2、傻瓜交换机无法支持STP与环路检测协议,仍会造成网络故障另外,配置环路检测后,需要配置日志告警系统,对环路协议报告进行告警。
2023年08月21日
691 阅读
0 评论
2 点赞
2023-08-08
0基础上手python3编程,多进程交换机配置自动备份软件
架构图 通过多线程telnet备份交换机配置并企业微信通知备份结果,生成log日志,速度飞快;配置文件均通过json定义预览 系统组成 由两个文件组成 swnetmiko.py swnetmiko.jsonnetmiko项目主页http://ktbyers.github.io/netmiko/如H3C交换机telnet代码为"device_type" : "hp_comware_telnet"代码 swnetmiko.pyfrom multiprocessing import Pool import os,json,time,requests,redis,multiprocessing,codecs from netmiko import ConnectHandler def get_config(): config = json.loads(open("swnetmiko.json", encoding='utf-8').read()) #读取配置文件 return config def post_weixin(stats): #发送微信 url = swnetmiko_config['weixin']['url'] body = { "msgtype": "news", "news": { "articles": [ { "title": swnetmiko_config['weixin']['title'], "description": tianqi()+yiyan()+stats, "url": swnetmiko_config['weixin']['url2'], "picurl": swnetmiko_config['weixin']['picurl'] } ] }} response = requests.post(url, json=body) print(response.text) print(response.status_code) def yiyan(): try: url = 'https://v1.hitokoto.cn/?c=d&c=k' response = requests.get(url) res = json.loads(response.text) text1 = res['hitokoto'] if res['from'] == None: text2 = "" else: text2 = res['from'] if res['from_who'] == None: text3 = "" else: text3 = res['from_who'] return text1 + " " + text2 + " " + text3 + "\n\n" except: return "一言API故障\n\n" def tianqi(): try: response2 = requests.get(swnetmiko_config['weatherapi']) data1 = json.loads(response2.text) data2 = json.dumps(data1['now']) data2 = json.loads(data2) data3 = "环境温度" + data2['temp'] + " 体感温度" + data2['feelsLike'] + " 天气状况 " + data2[ 'text'] + "\n风向 " + data2['windDir'] + " 风力等级" + data2['windScale'] + " 风速" + data2[ 'windSpeed'] + " 湿度" + data2['humidity'] + " 能见度" + data2['vis'] + "公里\n\n" return data3 except: return "天气API故障\n\n" dirpath = os.path.abspath('.') # 配置运行目录为当前目录 nowtime = time.strftime("%Y%m%d", time.localtime()) # 获取当前日期 try: os.mkdir(dirpath + "/" + nowtime) print("创建当日目录") except: print("当日目录已存在") nowdir = (dirpath + "/" + nowtime) print(nowdir) swnetmiko_config = get_config() # 读取配置文件 readredis = redis.Redis(connection_pool=redis.ConnectionPool(host=swnetmiko_config['redis']['host'], port=swnetmiko_config['redis']['port'], password=swnetmiko_config['redis']['password'], decode_responses=swnetmiko_config['redis']['decode'])) def sw_save(swconfig): #保存交换机配置 try: net_connect = ConnectHandler(**swconfig) output = net_connect.send_command("dis cu") print(swconfig['ip']+" OK") readredis.set(swconfig['ip'], "success") saveconfig = codecs.open(nowdir +'/'+ swconfig['ip'] +".conf", 'w+', encoding='utf-8') saveconfig.write(output) saveconfig.close() except: print(swconfig['ip'] + " NO") readredis.set(swconfig['ip'], "fail") if __name__ == '__main__': total = 0 fail = 0 weixindata = "" readredis.flushall() print("初始化redis数据库") #multiprocessing.freeze_support() #防止windows无限创建进程 multi_process = int(swnetmiko_config["multi-process"]) with Pool(multi_process) as p: p.map(sw_save, swnetmiko_config["data"]) for key in swnetmiko_config["data"]: if readredis.get(key["ip"]) == "fail": weixindata = weixindata + (key["ip"]+" 网络或账号密码错误\n") fail = fail + 1 total = total + 1 weixinpost = "总计巡检:"+str(total)+"台"+",故障交换机:"+str(fail)+"台\n"+weixindata post_weixin(weixinpost) flog = codecs.open(nowdir + "/" + nowtime + ".log", 'w', encoding='utf-8') flog.write(weixinpost) flog.close() print("程序执行完成")config.json{ "multi-process" : "4", "weatherapi" : "qweather.com申请api", "weixin" : { "url" : "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=用自己的", "title": "交换机巡检多线程版", "url2": "90apt.com", "picurl": "用自己的图片" }, "redis" : { "host": "自己的redis数据库IP", "port": "端口", "password": "密码", "decode": "True" }, "data" : [ {"device_type" : "hp_comware_telnet" , "ip" : "172.16.1.1" , "username" : "admin" , "password" : "passwd" , "port" : "23"}, {"device_type" : "hp_comware_telnet" , "ip" : "172.16.1.2" , "username" : "admin" , "password" : "passwd" , "port" : "23"} ] }配置定时任务crontab 每天早上7:30巡检30 7 * * * cd /root/swbackup/;python3.11 /root/swbackup/swnetmiko.py总结 简单
2023年08月08日
414 阅读
0 评论
3 点赞
2023-08-07
0基础上手python3编程,多进程监控摄像头巡检平台
架构图 读取配置文件;通过rtsp连接摄像头,保存一张截图;发送企业微信通知;记录log日志;多线程运行,速度起飞!预览 系统组成 rtsps.py rtsp.json代码 由于代码在windows平台运行,因此使用绝对路径C:\\jiankong\,文件放置在此目录下。rtsps.pyfrom multiprocessing import Pool,Value,Manager import cv2,os,json,time,requests,codecs,sys,redis,multiprocessing from func_timeout import func_set_timeout def get_config(): config = json.loads(open("C:\\jiankong\\rtsp.json", encoding='utf-8').read()) #读取配置文件 return config rtsp_config = get_config() path1 = ("C:\\jiankong\\") nowtime = time.strftime("%Y%m%d", time.localtime()) try: os.mkdir(path1 + "\\" + nowtime) print("创建当日目录") except: print("当日目录已存在") nowdir = (path1 + "\\" + nowtime) rtsp_config = get_config() readredis = redis.Redis(connection_pool=redis.ConnectionPool(host="IP地址", port="端口", password="密码",decode_responses=True)) #redis连接信息 #企业微信机器人 def post_weixin(stats): url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=用你自己的' body = { "msgtype": "news", "news": { "articles": [ { "title": "监控摄像头自动巡检多进程版", "description": stats, "url": "90apt.com", "picurl": "https://www.hikvision.com/content/dam/hikvision/cn/product/network-camera/fixed-ipc/%E7%BB%8F%E9%94%80%E7%B3%BB%E5%88%97/%E7%BB%8F%E9%94%80%E7%B3%BB%E5%88%97%E5%AF%BC%E8%88%AA%E7%9B%AE%E5%BD%95.jpg" } ] }} response = requests.post(url, json=body) print(response.text) print(response.status_code) @func_set_timeout(5) #连接失败超时时间5秒 def linkvideo(link): video = cv2.VideoCapture(link) return video def dayin(rtspconfig): video1 = "rtsp://" + rtspconfig['name'] + ":" + rtspconfig['password'] + "@" + rtspconfig['ip'] + rtsp_config[rtspconfig['brand']] #拼接rtsp参数 try: cap = linkvideo(video1) i = 0 for i in range(5): i = i + 1 ret, frame = cap.read() if ret == False: # 若没有帧返回,则重新刷新rtsp视频流 print("重新获取图像") print(i) if i == 5: readredis.set(rtspconfig['ip'], "fail") print("重新连接5次失败") else: cv2.imwrite(nowdir + "\\" + rtspconfig['ip'] + ".jpeg", frame) #保存图像 print("图像保存成功") readredis.set(rtspconfig['ip'], "success") cap.release() #关闭摄像头 break except: print("连接失败,网络或用户名密码错误") readredis.set(rtspconfig['ip'], "fail") if __name__ == '__main__': total = 0 fail = 0 weixindata = "" readredis.flushall() print("初始化redis数据库") multiprocessing.freeze_support() #防止windows无限创建进程 with Pool(8) as p: #8进程 p.map(dayin, rtsp_config["rtsp"]) for key in rtsp_config["rtsp"]: if readredis.get(key["ip"]) == "fail": weixindata = weixindata + (key["ip"]+" 网络或账号密码错误\n") fail = fail + 1 total = total + 1 weixinpost = "总计巡检:"+str(total)+"台"+",故障摄像头:"+str(fail)+"台\n"+weixindata post_weixin(weixinpost) flog = codecs.open(nowdir + "\\" + nowtime + ".log", 'w', encoding='utf-8') flog.write(weixinpost) flog.close() print("程序执行完成") rtsp.json yushi指宇视品牌摄像头,haikang指海康威视{ "haikang" : ":554/h264/ch1/main/av_stream", "yushi" : ":554/video1", "rtsp" : [ {"ip" : "172.16.1.1","hostname" : "摄像头1","brand" : "yushi","name": "admin","password": "admin"}, {"ip" : "172.16.1.2","hostname" : "摄像头2","brand" : "yushi","name": "admin","password": "admin"}, {"ip" : "172.16.1.3","hostname" : "摄像头3","brand" : "haikang","name": "admin","password": "admin"} ] }总结 有点困难哦
2023年08月07日
318 阅读
0 评论
3 点赞
2023-08-07
docker一键部署redis
红帽系系统默认为podman替代dockerpodman pull redis podman run --restart=always -p 6379:6379 --name myredis -d redis --requirepass passwd@123
2023年08月07日
144 阅读
0 评论
0 点赞
2023-08-04
VLAN非常规实验,给你带来一个不一样的VLAN2
查看本文前请先查看第一篇VLAN非常规实验,给你带来一个不一样的VLAN1https://90apt.com/2901本期为大家带来两个VLAN非常规实验1、傻瓜网络网管改造2、VLAN串联一、傻瓜网络网管改造 1、项目需求此需求来源真实,监控网络全部为傻瓜式连接交换机,需求逐步进行网管改造,改造应减小对监控网络的影响,监控网络可临时中断数分钟,不允许完全停机进行改造。2、改造前简化拓扑交换机均无配置,硬盘录像机与摄像头互通3、改造思路监控网络配置为vlan10,监控交换机管理网络配置为vlan20SW1 SW2 SW3 IP配置为192.168.20.1 192.168.20.2 192.168.20.3为保证监控不完全停机,需要用到trunk与pvid技术4、监控汇聚交换机改造将1-24口划入vlan10,将25-28划入trunk,配置vlan1 10 20通过,配置pvid10,为vlan20配置ip,最后测试硬盘录像机与摄像头是否互通[SW1]vlan 10 [SW1-vlan10]vlan 20 [SW1-vlan20]qu [SW1]int range g1/0/1 to g1/0/24 [SW1-if-range]port access vlan 10 [SW1-if-range]qu [SW1]int range g1/0/25 to g1/0/28 [SW1-if-range]port link-type trunk [SW1-if-range]port trunk permit vlan 1 10 20 [SW1-if-range]port trunk pvid vlan 10 [SW1]int vlan 20 [SW1-Vlan-interface20]ip add 192.168.20.1 24使用硬盘录像机ping摄像头[H3C]ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.2: icmp_seq=0 ttl=255 time=1.658 ms 56 bytes from 192.168.1.2: icmp_seq=1 ttl=255 time=2.110 ms5、技术解析在此改造中,为什么可以使用trunk接口对接无配置交换机并且不影响监控网络运行?此配置重点在于对vlan的理解,access接口为出撕标签入打标签,trunk接口默认不处理标签,当trunk接口配置pvid时,trunk接口对于此pvid的vlan同样具备access的作用,即出撕标签入打标签,因此trunk pvid vlan10可以与傻瓜交换机的access接口通讯,保证监控网络运行。6、其他监控交换机改造,测试监控交换机之间是否互通,测试硬盘录像机与摄像头是否互通[SW2]vlan 10 [SW2-vlan10]vlan 20 [SW2]int range g1/0/1 to g1/0/24 [SW2-if-range]port access vlan 10 [SW2-if-range]int range g1/0/25 to g1/0/28 [SW2-if-range]port link-type trunk [SW2-if-range]port trunk permit vlan 1 10 20 [SW2-if-range]port trunk pvid vlan 10 [SW2-if-range]qu [SW2]int vlan 20 [SW2-Vlan-interface20]ip add 192.168.20.2 24[SW3]vlan 10 [SW3-vlan10]vlan 20 [SW3-vlan20]qu [SW3]int range g1/0/1 to g1/0/24 [SW3-if-range]port access vlan 10 [SW3-if-range]int range g1/0/25 to g1/0/28 [SW3-if-range]port link-type trunk [SW3-if-range]port trunk permit vlan 1 10 20 [SW3-if-range]port trunk pvid vlan 10 [SW3-if-range]qu [SW3]int vlan 20 [SW3-Vlan-interface20]ip add 192.168.20.3 24硬盘录像机ping摄像头[H3C]ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.2: icmp_seq=0 ttl=255 time=1.230 ms 56 bytes from 192.168.1.2: icmp_seq=1 ttl=255 time=2.140 ms监控汇聚ping监控交换机3<SW1>ping 192.168.20.3 Ping 192.168.20.3 (192.168.20.3): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.20.3: icmp_seq=0 ttl=255 time=1.000 ms 56 bytes from 192.168.20.3: icmp_seq=1 ttl=255 time=1.000 ms改造完成二、VLAN串联 1、项目需求此需求来源真实,SW1、SW2均为网管交换机,SW1 g1-g24为accessVLAN5 g25-g28为trunkALL,SW2 g1-g24为accessVLAN1 g25-g28为trunkALL,此时SW2所在区域已经封闭无法进入,请通过SW1的调整使服务器与读卡器互通。2、现状测试服务器无法ping通读卡器<H3C>ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break Request time out Request time out3、技术解析由于SW2无法操作,因此要在SW1上将VLAN5与VLAN1互联,通过VLAN1穿过trunk接口将数据送达读卡器,我们在SW1上创建一个VLAN1接口,将VLAN1与VLAN5接口通过网线串联。注意:我们是无法直接为端口配置VLAN1的,但可以通过default使接口恢复为VLAN1.[SW1-GigabitEthernet1/0/4]dis th # interface GigabitEthernet1/0/4 port link-mode bridge port access vlan 5 combo enable fiber # return [SW1-GigabitEthernet1/0/4]default This command will restore the default settings. Continue? [Y/N]:y [SW1-GigabitEthernet1/0/4]dis th # interface GigabitEthernet1/0/4 port link-mode bridge combo enable fiber # return [SW1-GigabitEthernet1/0/4]dis interface brief GE1/0/1 UP 1G(a) F(a) A 5 GE1/0/2 DOWN auto A A 5 GE1/0/3 DOWN auto A A 5 GE1/0/4 DOWN auto A A 1 GE1/0/5 DOWN auto A A 54、测试发现仍无法ping通ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break Request time out Request time out5、技术分析在同一台交换机上串联接口,我们首先要考虑STP防环协议是否阻止了接口,查看STP接口状态,发现g4接口被屏蔽[SW1]dis stp brief MST ID Port Role STP State Protection 0 GigabitEthernet1/0/1 DESI FORWARDING NONE 0 GigabitEthernet1/0/3 DESI FORWARDING NONE 0 GigabitEthernet1/0/4 BACK DISCARDING NONE 0 GigabitEthernet1/0/28 DESI FORWARDING NONE关闭stp协议[SW1]un stp global en检查服务器与读卡器是否互通<H3C>ping 192.168.1.2 Ping 192.168.1.2 (192.168.1.2): 56 data bytes, press CTRL_C to break 56 bytes from 192.168.1.2: icmp_seq=0 ttl=255 time=1.227 ms 56 bytes from 192.168.1.2: icmp_seq=1 ttl=255 time=1.665 ms测试通过注意:此方法仅用于特殊情况下的紧急处理,请勿实施于正常网络中。
2023年08月04日
309 阅读
0 评论
0 点赞
2023-08-03
almalinux8安装tomcat9
从yum源直接安装tomcat9yum install tomcat tomcat-webapps tomcat-admin-webapps启动服务systemctl enable --now tomcat访问tomcat正常http://IP:8080/配置Manager App访问范围/usr/share/tomcat/webapps/manager/META-INF/context.xml原内容 <Context antiResourceLocking="false" privileged="true" > <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor" sameSiteCookies="strict" /> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/> </Context> 增加任意IP访问 \d+\.\d+\.\d+\.\d+ 修改后 <Context antiResourceLocking="false" privileged="true" > <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor" sameSiteCookies="strict" /> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|\d+\.\d+\.\d+\.\d+" /> <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/> </Context> 配置Manager App用户名密码/usr/share/tomcat/conf/tomcat-users.xml在倒数第二行添加 <role rolename="manager-gui"/> <user username="admin" password="admin" roles="manager-gui"/>重启服务systemctl restart tomcat完毕
2023年08月03日
138 阅读
0 评论
0 点赞
2023-07-27
0基础上手python3编程,本地文件存活监控
架构图 判断文件是否存在;如果文件不存在,判断check.config是否为1,如果为1程序退出,如果不存在或为0,生成或写入1并发送企业微信告警;如果文件存在,判断check.config是否为0,如果为0程序退出,如果不存在或为1,生成或写入0并发送企业微信告警;预览 系统组成 由两个文件组成 check.py check.conf,其中 check.conf为自动生成代码 check.pyimport os,requests #企业微信机器人 def post_weixin(stats): url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=用自己的' body = { "msgtype": "news", "news": { "articles": [ { "title": "文件监控", "description": stats, "url": "90apt.com", "picurl": "用自己的" } ] }} response = requests.post(url, json=body) print(response.text) print(response.status_code) if os.path.exists("D:\hello.txt") == False: #判断文件是否存在 f1 = open("D:\check.config", 'r') #读取文件 config = f1.read() if config == "1": f1.close() else: f1.close() f1 = open("D:\check.config", 'w+') f1.write("1") #写入文件 post_weixin("监控到文件丢失") f1.close() else: f1 = open("D:\check.config", 'r') config = f1.read() if config == "0": f1.close() else: f1 = open("D:\check.config", 'w+') f1.write("0") post_weixin("监控到文件已生成") f1.close()总结 简单
2023年07月27日
157 阅读
0 评论
0 点赞
2023-07-27
0基础上手python3编程,单线程监控摄像头巡检平台
架构图 读取配置文件;通过rtsp连接摄像头,保存一张截图;发送企业微信通知;记录log日志;预览 系统组成 rtsp.py rtsp.json代码 由于代码在windows平台运行,因此使用绝对路径C:\\jiankong\,文件放置在此目录下。rtsp.pyimport cv2,os,json,time,requests,codecs from func_timeout import func_set_timeout from multiprocessing import Process @func_set_timeout(5) def dayin(): video1 = "rtsp://"+rtspconfig['name']+":"+rtspconfig['password']+"@"+rtspconfig['ip']+rtsp_config[rtspconfig['brand']] cap = cv2.VideoCapture(video1) # 使用整数,此处打开的本地摄像头 while 1: ret, frame = cap.read() if ret == False: # 若没有帧返回,则重新刷新rtsp视频流 continue else: break; # cv2.imshow("capture",frame) cv2.imwrite(nowdir+"\\"+rtspconfig['ip']+".jpeg", frame) cap.release() return rtspconfig['hostname']+"保存成功" def get_config(): config = json.loads(open("C:\\jiankong\\rtsp.json", encoding='utf-8').read()) return config def post_weixin(stats): url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=用自己的' body = { "msgtype": "news", "news": { "articles": [ { "title": "监控摄像头自动巡检", "description": stats, "url": "90apt.com", "picurl": "https://www.hikvision.com/content/dam/hikvision/cn/product/network-camera/fixed-ipc/%E7%BB%8F%E9%94%80%E7%B3%BB%E5%88%97/%E7%BB%8F%E9%94%80%E7%B3%BB%E5%88%97%E5%AF%BC%E8%88%AA%E7%9B%AE%E5%BD%95.jpg" } ] }} response = requests.post(url, json=body) print(response.text) print(response.status_code) total = 0 fail = 0 weixindata = "" rtsp_config = get_config() print(rtsp_config) #path1=os.path.abspath('.') path1=("C:\\jiankong\\") nowtime = time.strftime("%Y%m%d", time.localtime()) try: os.mkdir(path1 + "\\" + nowtime) except: None nowdir = (path1 + "\\" + nowtime) for rtspconfig in rtsp_config['rtsp']: total = total + 1 try: dayin() except: weixindata = weixindata + (rtspconfig['hostname']+" "+rtspconfig['ip']+" 网络或账号密码错误\n") fail = fail + 1 weixinpost = "总计巡检:"+str(total)+"台"+",故障摄像头:"+str(fail)+"台\n"+weixindata post_weixin(weixinpost) flog = codecs.open(nowdir+"\\"+nowtime+".log", 'w',encoding='utf-8') flog.write(weixinpost) flog.close() rtsp.json yushi指宇视品牌摄像头,haikang指海康威视{ "haikang" : ":554/h264/ch1/main/av_stream", "yushi" : ":554/video1", "rtsp" : [ {"ip" : "172.16.1.1","hostname" : "摄像头1","brand" : "yushi","name": "admin","password": "admin"}, {"ip" : "172.16.1.2","hostname" : "摄像头2","brand" : "yushi","name": "admin","password": "admin"}, {"ip" : "172.16.1.3","hostname" : "摄像头3","brand" : "haikang","name": "admin","password": "admin"} ] }总结 简单
2023年07月27日
173 阅读
0 评论
1 点赞
2023-07-20
python编译exe可执行文件
安装pyinstaller模块在终端运行pyinstaller -F -w 自己的py名字.py -F 打包为1个文件 -w 隐藏窗口模式
2023年07月20日
121 阅读
0 评论
0 点赞
2023-07-12
RHEL8+Graylog5.1日志监控系统快速部署接入
本教程适用于RHEL8/Oracle linux8/ALMA Linux8操作系统,当前组件版本信息为:java-17-openjdk-17.0.7.0.7-3.0.1.el8.x86_64 opensearch-2.8.0-1.x86_64 mongodb-org-database-6.0.8-1.el8.x86_64 graylog-server-5.1.3-1.x86_64建议 装一台Alma8服务器,安装graylog,关闭selinux,保持系统更新。全部采用yum源安装,方便快速更新我防火墙仅开放了9000/TCP 1514/UDP 和 SSH端口官方安装教程 https://go2docs.graylog.org/5-1/downloading_and_installing_graylog/red_hat_installation.htm安装OpenJdk17yum install java-17-openjdk安装MongoDB 创建yum源文件/etc/yum.repos.d/mongodb-org.repo[mongodb-org-6.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc安装并启动sudo yum install -y mongodb-org sudo systemctl daemon-reload sudo systemctl enable mongod sudo systemctl start mongod sudo systemctl status mongod安装OpenSearchsudo curl -SL https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/opensearch-2.x.repo -o /etc/yum.repos.d/opensearch-2.x.repo sudo yum install -y opensearch配置OpenSearch端口监听/etc/opensearch/opensearch.ymlcluster.name: graylog node.name: ${HOSTNAME} path.data: /var/lib/opensearch path.logs: /var/log/opensearch discovery.type: single-node network.host: 0.0.0.0 action.auto_create_index: false plugins.security.disabled: true修改内存占用/etc/opensearch/jvm.options-Xms6g -Xmx8g修改内核参数sudo sysctl -w vm.max_map_count=262144 sudo echo 'vm.max_map_count=262144' >> /etc/sysctl.conf启动程序sudo systemctl daemon-reload sudo systemctl enable opensearch sudo systemctl start opensearch sudo systemctl status opensearch安装Graylogsudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-5.1-repository_latest.rpm sudo yum install graylog-server修改配置/etc/graylog/server/server.conf增加password_secret和root_password_sha2选项,不增加这两项不允许访问,配置http_bind_address,默认只监听127.0.0.1,修改为0.0.0.0取得root_password_sha2值echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1取得password_secret值< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-96};echo;启动程序sudo systemctl daemon-reload sudo systemctl enable graylog-server.service sudo systemctl start graylog-server.service sudo systemctl --type=service --state=active | grep graylog登录系统 默认为http://IP:9000/用户名和密码均在server.conf中定义启动Syslog UDP监听器 注意:graylog无法监听1024以内端口,因此Syslog将使用1514UDP端口 graylog - system -inputsH3C交换机快速接入info-center loghost 172.16.0.1 port 1514浪潮BMC快速接入 群晖快速接入 预览 问题处理 时间不对,修改时区 server.confroot_timezone = Asia/Shanghai总结 为什么不用ELK? 你研究ELK? 等你研究出来马斯克都上火星了! 人生苦短,我用Graylog!
2023年07月12日
526 阅读
0 评论
3 点赞
2023-07-10
0基础上手python3编程,通用Mysql数据库字段监控,企业微信告警
架构图 通过redis缓存mysql数据库字段进行对比,当发现内容变动时,进行企业微信告警预览 系统组成 由两部分组成 check.py和redis数据库,从mysql中读取指定字段存储到redis中代码import requests,redis import mysql.connector def post_weixin(data): url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=用自己的' body = { "msgtype": "news", "news": { "articles": [ { "title": "卡号监控机器人", "description": data, "url": "90apt.com", "picurl": "https://www.zkteco.com/cn/uploads/image/20210301/3e1adaa2dce94812e658c5d42afc1525.png" } ] } } headers = {"Content-Type": "application/json"} response = requests.post(url, json=body) print(response.text) print(response.status_code) def sqlread(): mqdb = mysql.connector.connect( host="127.0.0.1", user="admin", passwd="password", database="mysqldata" ) mqcursor = mqdb.cursor() getconfig_sql = "SELECT number,card,name FROM userinfo where ifnull(name, '') <> ''" mqcursor.execute(getconfig_sql) mqconfig = mqcursor.fetchall() global cardchange cardchange = "" readredis = redis.Redis(connection_pool=redis.ConnectionPool(host="127.0.0.1", port="6379", password="password",decode_responses=True)) for i in mqconfig: if readredis.get(i[0]) == str(i[1]): None else: cardchange = cardchange + i[2]+readredis.get(i[0])+"变为"+str(i[1])+"\n" readredis.set(i[0], str(i[1])) sqlread() post_weixin(cardchange)总结 简单
2023年07月10日
180 阅读
0 评论
3 点赞
1
...
6
7
8
...
20