• 摸鱼神器老板告警


    前言

    适当摸鱼,有助于身心健康,本文带来摸鱼小技巧。
    在这里插入图片描述

    环境

    本公司的门禁功能以及其它摄像头的人脸识别对接由本人开发,所以可以借助这两个功能实现老板告警功能。

    选型考虑

    优雅的方式——在业务识别入库服务中调用自己编写的独立服务,无论server方式还是webhook都行,独立服务实现调用im推送以及各种告警方式,且部署在私有服务器可以有效防止摸鱼计划败露后证据外泄。

    毕竟修改代码有svn记录,所以直接通过canal监控数据库,再告警也不失为一个好方法。

    再三考虑下,决定怎么简单怎么来,轮询查询接口方式实现。

    实现

    监听页面

    以最简洁的html来实现
    ajax请求门禁记录分页查询接口limit3,将最新3条记录的人名回显至页面,将最新的记录人名回显至titile,和计算统计定时器执行次数以防假死了还没发现
    最关键判断count改变然后通过浏览器Notification推送最新记录弹窗,首次必推以测试弹窗。
    当然可以比对名字再推送,我这是宁可错杀不可放过。

    在这里插入图片描述
    在这里插入图片描述

    监听html

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>bbq</title>
    <script src="/js/jquery.min.js"></script>
    </head>
    <body >
    <P id='p'></p>
    </body>
    <script>
    var i = 0;
    var count = 0;
    var token = "token。。。";
    var url = "https://domain/nolog/a/.../api/get-data?"
     //+"token=" + token 
     + "&pageNo=1&pageSize=3";
    var bbq=document.getElementById("p");
    
    var interval;
    interval=window.setInterval(function(){
    i=i+1;
    $.ajax({
        url: url,
    	type: "POST",
        success: function (data) {
    		document.title=data.data.list[0].personName + i;
    		bbq.innerText = data.data.list[0].personName + "\n" 
    		+ data.data.list[1].personName + "\n" + data.data.list[2].personName + "\n" + i + "\n" + data.data.count;
    		if(data.data.count != count) {
    			showNotice(data.data.list[0].personName, data.data.list[0].imgUrl);
    		}
    		count= data.data.count;
        }
    })
    },2000)
    
    // 发送通知
    function showNotice(msg, url) {
        newNotify = function () {
            var notification = new Notification("通知:", {
                dir: "auto",
                lang: "hi",
                requireInteraction: true,
                icon: url,
                body: msg
            });
            notification.onclick = function (event) {
                window.focus();
            }
        }
        if (Notification.permission == "granted") {
            newNotify();
        } else {
            Notification.requestPermission(function (perm) {
                if (perm == "granted") {
                    newNotify();
                }
            })
        }
    }
    </script>
    </html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62

    细节

    ① 免设置token:html丢到门禁接口同域名下,可以利用同域cookie自动携带而不用设置token(实为sessionID),
    如果丢在私服或者本地,得设置token。

    ② 直接html方式打开无法弹窗,Notification需要https才能弹窗,所以不论部署线上还是本地,都要配置ssl证书。

    ③ 接口免log:
    nginx配置中偷偷加上一个代理,且配置access_log off,防止轮询被elk统计进去;

    location /nolog/{
    	proxy_pass   http://doman/;
    	#proxy_connect_timeout 1;
    	access_log off;
    	proxy_set_header isMobile weixin;
    	proxy_set_header Host $host;
    	proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	proxy_set_header X-Forwarded-Proto $scheme;
    	proxy_set_header Connection "";
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    最后

    这样即可实现老板告警功能,duang~
    来了,撤了

  • 相关阅读:
    springboot整合Excel填充数据
    【Ubuntu系统重启以后串口驱动丢失的问题】
    LANG 环境变量
    热点不热!如何修复笔记本电脑未连接到移动热点的问题
    如何根据不同仪器选择适合的电源模块?
    用html编写的小广告板
    华为机试:报文解压缩
    ESP8266--Arduino开发(搭建HTTP网络服务器)
    Spring的创建和使用
    duilib 进阶 之 list 容器使用 及扩展
  • 原文地址:https://blog.csdn.net/qq_24054301/article/details/125546460