去除文件中<feff>

最近生成的文件中出现了<feff>乱码,而且单个文件中出现不止一次,在vim中打该文件显示<feff>,而在idea中则显示一个“-”,对数据处理造成了极大的困扰,通过使用其它编辑器打开发现,Windows记事本不出现乱码,notepad++不出现乱码,那么极有可能是该乱码位置写了一些不可见的标志字符。

在Windows下使用winhex打开该文件查看乱码位置的十六进制格式数据为EF BB BF,通过百度了解到是UTF8的bom信息

尝试过用notepad++转换格式去除bom信息,无果,我生成的文件本身编码就是utf8 without bom,那么只好通过shell来去除这个烦人的字符:

sed -i 's/\xEF\xBB\xBF//g' filename

不过这个命令偶尔失效,在我一开始用它就不管用的情况下,我试了以下命令

sed -i 's/<feff>//g' filename

 成了!

不过命令2只成功了1次,之后再用命令1就完全o**k了。玄学问题。。。

命令详解:

        sed的命令格式: sed [-nefri] [动作]

             选项与参数:

                     -n:使用安静(silent)模式。在一般sed的动作中,所有来自stdin的数据一般都会被列出到终端上,但如果加上-n参数后,则只有经过sed特殊                           处理的那一行(或动作)才会被列出来。

                     -e:直接在命令行模式上进行sed的动作编辑

                     -f:直接将sed的动作写在一个文件内, -f  filename则可以运行filename内的sed动作

                     -r:sed的动作支持的是延伸型正则表达式语法(默认是基础正则表达式语法)

                     -i:直接修改读取的文件内容,而不是输出到终端

             function:

                     a:新增

                     c:取代

                     d:删除

                     i:插入

                     p:列印

                     s:取代   直接进行取代的工作,通常搭配正则表达式

       sed -i 就是直接对文本文件进行操作

                 

sed -i 's/原字符串/新字符串'  /home/1.md   #只替换一个
sed -i 's/原字符串/新字符串/g' /home/1.md   #全部替换

参考资料:

sed -i命令详解

UTF8最好不带BOM,附许多经典评论

转载于:https://my.oschina.net/shuangquan/blog/2986922

HTML部分<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>js_sinanav</title> <link rel="stylesheet" href="index.css"> </head> <body> <div class="nav"> <div class="nav_con"> <ul class="nav-left"> <li class="shouye"> <span>设为首页</span> </li> <li class="phone"> <span>手机新浪网</span> </li> <li class="h5"> <span>移动客户端<span class="jiantou"></span></span> <ul> <li>新浪微博</li> <li>新浪新闻</li> <li>新浪财经</li> <li>新浪体育</li> <li>黑猫投诉</li> <li>新浪博客</li> <li>新浪游戏</li> <li>新浪众测</li> <li>新浪邮箱客户端</li> </ul> </li> </ul> <ul class="nav-right"> <li class="web"> <span>网站导航</span> </li> <li class="email"> <span>邮箱<span class="jiantou"></span></span> <ul> <li>免费邮箱</li> <li>VIP邮箱</li> <li>企业邮箱</li> <li>新浪邮箱</li> </ul> </li> <li class="boke"> <span>博客<span class="jiantou"></span></span> <ul> <li>博客评论</li> <li>未读提醒</li> </ul> </li> <li class="weibo"> <span>微博<span class="jiantou"></span></span> <ul> <li>私信</li> <li>评论</li> <li>@我</li> </ul> </li> </ul> </div> </div> <script type="text/javascript" src="index.js"></script> </body> </html> css部分* { margin: 0; padding: 0; } ul, li { list-style: none; margin: 0 auto; cursor: pointer; } .nav { height: 44px; font-size: 12px; color: #333; border-top: 3px solid #ff8500; border-bottom: 1px solid #edeef0; background-color: #fcfcfc; box-sizing: border-box; } .nav_con { width: 1000px; margin: 0 auto; } .nav_con ul>li:hover { background-color: #eee; color: #ff8500; box-sizing: border-box; } .nav-left>li { float: left; padding: 0 2px 0 0; line-height: 16px; } .nav-right>li { float: right; padding: 0 2px 0 0; } .nav-left>li span{ line-height: 41px; padding: 12px 9px 12px 16px; } .nav-right>li span{ line-height: 41px; padding: 12px 9px 12px 16px; } .jiantou { display: inline-block; width: 8px; height: 5px; margin: 0 0 0 5px; overflow: hidden; vertical-align: middle; font-size: 12px; line-height: 13px; background: url(icon.png) 0 -966px no-repeat; } .nav_con ul li ul { display: none; } .nav_con ul li ul li{ border: 1px solid #fecc5b; padding: 8px 0 8px 10px; font-size: 12px; color: #4c4c4c; background-color: #fff; } .nav_con ul li ul li:hover { background-color: rgb(255,245,218); } js部分var uls_left = document.querySelector('.nav-left'); var uls_right = document.querySelector('.nav-right'); var lis_left = uls_left.children; var lis_right = uls_right.children; for (var i = 0;i < lis_left.length;i++) { lis_left[i].onmouseover = function() { this.children[1].style.display = 'block'; } lis_left[i].onmouseout = function() { this.children[1].style.display = 'none'; } } for (var i = 0;i < lis_right.length;i++) { lis_right[i].onmouseover = function() { this.children[1].style.display = 'block'; } lis_right[i].onmouseout = function() { this.children[1].style.display = 'none'; } }。融合为只有HTML和css
最新发布
12-03
<?xml version="1.0" encoding="UTF-8"?> <!-- This file stores bootstrap properties needed by Openfire. Property names must be in the format: "prop.name.is.blah=value" That will be stored as: <prop> <name> <is> <blah>value</blah> </is> </name> </prop> Most properties are stored in the Openfire database. A property viewer and editor is included in the admin console. --> <!-- root element, all properties must be under this element --> <jive> <adminConsole> <!-- Disable either port by setting the value to -1 --> <port>9090</port> <securePort>9091</securePort> <interface>0.0.0.0</interface> </adminConsole> <locale>zh_CN</locale> <!-- Network settings. By default, Openfire will bind to all network interfaces. Alternatively, you can specify a specific network interfaces that the server will listen on. For example, 127.0.0.1. This setting is generally only useful on multi-homed servers. --> <!-- <network> <interface></interface> </network> --> <!-- One time token to gain temporary access to the admin console. --> <!-- <oneTimeAccessToken>secretToken</oneTimeAccessToken> --> <connectionProvider> <className>org.jivesoftware.database.DefaultConnectionProvider</className> </connectionProvider> <database> <defaultProvider> <driver>com.mysql.cj.jdbc.Driver</driver> <serverURL>jdbc:mysql://localhost:3306/openfire?rewriteBatchedStatements=true&characterEncoding=UTF-8&characterSetResults=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true</serverURL> <username encrypted="true">11121a25dd0d4de9a3dba5b4f37cb1be6010fa93210406ad015db29faab0027d</username> <password encrypted="true">598f5f31f8b6c1709b98c4ae9fda41ca799fb77a6047ff878e4edd77c36353c2fd52046d48eb688dd0a578e00070607c</password> <testSQL>select 1</testSQL> <testBeforeUse>false</testBeforeUse> <testAfterUse>false</testAfterUse> <testTimeout>PT0.5S</testTimeout> <timeBetweenEvictionRuns>PT30S</timeBetweenEvictionRuns> <minIdleTime>PT15M</minIdleTime> <maxWaitTime>PT0.5S</maxWaitTime> <minConnections>10</minConnections> <maxConnections>50</maxConnections> <connectionTimeout>1.0</connectionTimeout> </defaultProvider> </database> <setup>true</setup> <fqdn>zxkf.szrengjing.com</fqdn> <admin.authorizedJIDs>admin@zxkf.szrengjing.com</admin.authorizedJIDs> <locale>zh_CN</locale> <!-- 额外的安全和性能配置 --> <security> <allowPlainTextAuth>true</allowPlainTextAuth> </security> <system> <cache> <enabled>true</enabled> </cache> </system> </jive> 登录不上 账号admin 密码 ZXcv506448#
11-01
10月 28 10:00:22 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/alertmanager.service:1] Assignment outside of section. Ignoring. 10月 28 10:00:22 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/alertmanager.service:5] Unknown lvalue 'wants' in section 'Unit' 10月 28 10:00:22 localhost.localdomain systemd[1]: Started Alert Manager. 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.270Z level=INFO source=main.go:191 msg="Starting Alertmanager" version="(version=0.28.0, branch=HEAD, revision=4ce04fb010bd626fca35928dcfe82f6f2da52ced)" 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.270Z level=INFO source=main.go:192 msg="Build context" build_context="(go=go1.23.4, platform=linux/amd64, user=root@40be7f318ba7, date=20250115-14:22:34, tags=netgo)" 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.273Z level=INFO source=cluster.go:185 msg="setting advertise address explicitly" component=cluster addr=10.213.70.7 port=9094 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.276Z level=INFO source=cluster.go:674 msg="Waiting for gossip to settle..." component=cluster interval=2s 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.310Z level=INFO source=coordinator.go:112 msg="Loading configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.311Z level=INFO source=coordinator.go:125 msg="Completed loading of configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.313Z level=ERROR source=coordinator.go:131 msg="one or more config change subscribers failed to apply new config" component=configuration file=/prometheus/alertmanager/alertmanager.yml err="failed to parse templates: template: email_final.tmpl:66: function \"now\" not defined" 10月 28 10:00:22 localhost.localdomain alertmanager[87820]: time=2025-10-28T02:00:22.313Z level=INFO source=cluster.go:683 msg="gossip not settled but continuing anyway" component=cluster polls=0 elapsed=37.055332ms 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service: main process exited, code=exited, status=1/FAILURE 10月 28 10:00:22 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service failed. 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service holdoff time over, scheduling restart. 10月 28 10:00:22 localhost.localdomain systemd[1]: Stopped Alert Manager. 10月 28 10:00:22 localhost.localdomain systemd[1]: Started Alert Manager. 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.622Z level=INFO source=main.go:191 msg="Starting Alertmanager" version="(version=0.28.0, branch=HEAD, revision=4ce04fb010bd626fca35928dcfe82f6f2da52ced)" 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.622Z level=INFO source=main.go:192 msg="Build context" build_context="(go=go1.23.4, platform=linux/amd64, user=root@40be7f318ba7, date=20250115-14:22:34, tags=netgo)" 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.624Z level=INFO source=cluster.go:185 msg="setting advertise address explicitly" component=cluster addr=10.213.70.7 port=9094 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.627Z level=INFO source=cluster.go:674 msg="Waiting for gossip to settle..." component=cluster interval=2s 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.659Z level=INFO source=coordinator.go:112 msg="Loading configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.659Z level=INFO source=coordinator.go:125 msg="Completed loading of configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.663Z level=ERROR source=coordinator.go:131 msg="one or more config change subscribers failed to apply new config" component=configuration file=/prometheus/alertmanager/alertmanager.yml err="failed to parse templates: template: email_final.tmpl:66: function \"now\" not defined" 10月 28 10:00:22 localhost.localdomain alertmanager[87840]: time=2025-10-28T02:00:22.663Z level=INFO source=cluster.go:683 msg="gossip not settled but continuing anyway" component=cluster polls=0 elapsed=36.323876ms 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service: main process exited, code=exited, status=1/FAILURE 10月 28 10:00:22 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service failed. 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service holdoff time over, scheduling restart. 10月 28 10:00:22 localhost.localdomain systemd[1]: Stopped Alert Manager. 10月 28 10:00:22 localhost.localdomain systemd[1]: Started Alert Manager. 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.871Z level=INFO source=main.go:191 msg="Starting Alertmanager" version="(version=0.28.0, branch=HEAD, revision=4ce04fb010bd626fca35928dcfe82f6f2da52ced)" 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.871Z level=INFO source=main.go:192 msg="Build context" build_context="(go=go1.23.4, platform=linux/amd64, user=root@40be7f318ba7, date=20250115-14:22:34, tags=netgo)" 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.874Z level=INFO source=cluster.go:185 msg="setting advertise address explicitly" component=cluster addr=10.213.70.7 port=9094 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.876Z level=INFO source=cluster.go:674 msg="Waiting for gossip to settle..." component=cluster interval=2s 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.907Z level=INFO source=coordinator.go:112 msg="Loading configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.908Z level=INFO source=coordinator.go:125 msg="Completed loading of configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.911Z level=ERROR source=coordinator.go:131 msg="one or more config change subscribers failed to apply new config" component=configuration file=/prometheus/alertmanager/alertmanager.yml err="failed to parse templates: template: email_final.tmpl:66: function \"now\" not defined" 10月 28 10:00:22 localhost.localdomain alertmanager[87856]: time=2025-10-28T02:00:22.911Z level=INFO source=cluster.go:683 msg="gossip not settled but continuing anyway" component=cluster polls=0 elapsed=34.577104ms 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service: main process exited, code=exited, status=1/FAILURE 10月 28 10:00:22 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:22 localhost.localdomain systemd[1]: alertmanager.service failed. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service holdoff time over, scheduling restart. 10月 28 10:00:23 localhost.localdomain systemd[1]: Stopped Alert Manager. 10月 28 10:00:23 localhost.localdomain systemd[1]: Started Alert Manager. 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.122Z level=INFO source=main.go:191 msg="Starting Alertmanager" version="(version=0.28.0, branch=HEAD, revision=4ce04fb010bd626fca35928dcfe82f6f2da52ced)" 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.122Z level=INFO source=main.go:192 msg="Build context" build_context="(go=go1.23.4, platform=linux/amd64, user=root@40be7f318ba7, date=20250115-14:22:34, tags=netgo)" 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.125Z level=INFO source=cluster.go:185 msg="setting advertise address explicitly" component=cluster addr=10.213.70.7 port=9094 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.127Z level=INFO source=cluster.go:674 msg="Waiting for gossip to settle..." component=cluster interval=2s 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.161Z level=INFO source=coordinator.go:112 msg="Loading configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.161Z level=INFO source=coordinator.go:125 msg="Completed loading of configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.163Z level=ERROR source=coordinator.go:131 msg="one or more config change subscribers failed to apply new config" component=configuration file=/prometheus/alertmanager/alertmanager.yml err="failed to parse templates: template: email_final.tmpl:66: function \"now\" not defined" 10月 28 10:00:23 localhost.localdomain alertmanager[87872]: time=2025-10-28T02:00:23.163Z level=INFO source=cluster.go:683 msg="gossip not settled but continuing anyway" component=cluster polls=0 elapsed=35.955593ms 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service: main process exited, code=exited, status=1/FAILURE 10月 28 10:00:23 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service failed. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service holdoff time over, scheduling restart. 10月 28 10:00:23 localhost.localdomain systemd[1]: Stopped Alert Manager. 10月 28 10:00:23 localhost.localdomain systemd[1]: Started Alert Manager. 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.371Z level=INFO source=main.go:191 msg="Starting Alertmanager" version="(version=0.28.0, branch=HEAD, revision=4ce04fb010bd626fca35928dcfe82f6f2da52ced)" 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.371Z level=INFO source=main.go:192 msg="Build context" build_context="(go=go1.23.4, platform=linux/amd64, user=root@40be7f318ba7, date=20250115-14:22:34, tags=netgo)" 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.374Z level=INFO source=cluster.go:185 msg="setting advertise address explicitly" component=cluster addr=10.213.70.7 port=9094 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.376Z level=INFO source=cluster.go:674 msg="Waiting for gossip to settle..." component=cluster interval=2s 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.408Z level=INFO source=coordinator.go:112 msg="Loading configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.409Z level=INFO source=coordinator.go:125 msg="Completed loading of configuration file" component=configuration file=/prometheus/alertmanager/alertmanager.yml 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.411Z level=ERROR source=coordinator.go:131 msg="one or more config change subscribers failed to apply new config" component=configuration file=/prometheus/alertmanager/alertmanager.yml err="failed to parse templates: template: email_final.tmpl:66: function \"now\" not defined" 10月 28 10:00:23 localhost.localdomain alertmanager[87888]: time=2025-10-28T02:00:23.411Z level=INFO source=cluster.go:683 msg="gossip not settled but continuing anyway" component=cluster polls=0 elapsed=34.366194ms 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service: main process exited, code=exited, status=1/FAILURE 10月 28 10:00:23 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service failed. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service holdoff time over, scheduling restart. 10月 28 10:00:23 localhost.localdomain systemd[1]: Stopped Alert Manager. 10月 28 10:00:23 localhost.localdomain systemd[1]: start request repeated too quickly for alertmanager.service 10月 28 10:00:23 localhost.localdomain systemd[1]: Failed to start Alert Manager. 10月 28 10:00:23 localhost.localdomain systemd[1]: Unit alertmanager.service entered failed state. 10月 28 10:00:23 localhost.localdomain systemd[1]: alertmanager.service failed. [root@localhost ~]# cat /prometheus/alertmanager/templates/email_final.tmpl {{ define "custom.subject" }} {{- if eq .Status "firing" -}} {{- if eq .CommonLabels.alertname "WeeklyUnresolvedAlerts" -}} 📋 长期未处理告警汇总 - {{ .GroupLabels.instance }} {{- else -}} 🚨 监控报警 - {{ .GroupLabels.instance }} - {{ .CommonLabels.alertname }} {{- end -}} {{- else -}} ✅ 恢复通知 - {{ .GroupLabels.instance }} - {{ .CommonLabels.alertname }} {{- end -}} {{ end }} {{ define "custom.html" }} <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{{ template "custom.subject" . }}</title> <style> body { font-family: Arial, sans-serif; margin: 20px; } .alert-box { border: 2px solid; padding: 15px; margin: 10px 0; border-radius: 5px; } .firing { border-color: #ff4d4d; background-color: #fff5f5; } .resolved { border-color: #52c41a; background-color: #f6ffed; } .unresolved { border-color: #ffc107; background-color: #fff8e1; } table { width: 100%; border-collapse: collapse; margin: 10px 0; } th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #ddd; } th { background-color: #f5f5f5; font-weight: bold; } .promql { background-color: #f0f0f0; padding: 8px; border-radius: 3px; font-family: monospace; word-break: break-all; } </style> </head> <body> {{ if eq .CommonLabels.alertname "WeeklyUnresolvedAlerts" }} <div class="alert-box unresolved"> <h2>📋 长期未处理告警汇总</h2> <table> <tr><th>汇总时间:</th><td>{{ (index .Alerts 0).StartsAt.Format "2006-01-02 15:04:05" }}</td></tr> <tr><th>告警数量:</th><td>{{ len .Alerts }}</td></tr> <tr><th>汇总描述:</th><td>以下告警在过去一周内未处理,请及时处理</td></tr> </table> <h3>未处理告警详情</h3> <table> <tr> <th>告警类型</th> <th>告警级别</th> <th>故障主机</th> <th>告警主题</th> <th>故障时间</th> <th>持续时间</th> <th>查询地址</th> </tr> {{ range .Alerts }} <tr> <td>{{ .Labels.alertname }}</td> <td> {{- if eq .Labels.severity "critical" }}<strong style="color: red;">严重</strong> {{- else if eq .Labels.severity "warning" }}<strong style="color: orange;">警告</strong> {{- else }}{{ .Labels.severity }}{{ end -}} </td> <td>{{ .Labels.instance }}</td> <td>{{ .Annotations.summary }}</td> <td>{{ .StartsAt.Format "2006-01-02 15:04:05" }}</td> <td>{{ now.Sub .StartsAt }}</td> <td><a href="{{ .GeneratorURL }}">查看详情</a></td> </tr> {{ end }} </table> <p><strong>历史数据:</strong><a href="http://10.213.70.8:3000">http://10.213.70.8:3000</a></p> <p>请及时处理以上长期未处理的告警</p> </div> {{ else if eq .Status "firing" }} <div class="alert-box firing"> <h2>监控报警(🚨 故障告警通知)</h2> <table> <tr><th>告警类型:</th><td>{{ .CommonLabels.alertname }}</td></tr> <tr><th>告警级别:</th><td><strong style="color: red;"> {{- if eq .CommonLabels.severity "critical" }}严重 {{- else if eq .CommonLabels.severity "warning" }}警告 {{- else }}{{ .CommonLabels.severity }}{{ end -}} </strong></td></tr> <tr><th>告警状态:</th><td><strong style="color: red;">触发中</strong></td></tr> <tr><th>故障主机:</th><td>{{ .GroupLabels.instance }}</td></tr> <tr><th>服务名称:</th><td>{{ .CommonLabels.job }}</td></tr> <tr><th>告警主题:</th><td>{{ (index .Alerts 0).Annotations.summary }}</td></tr> <tr><th>告警详情:</th><td>{{ (index .Alerts 0).Annotations.description }}</td></tr> <tr><th>故障时间:</th><td>{{ (index .Alerts 0).StartsAt.Format "2006-01-02 15:04:05" }}</td></tr> </table> <p><strong>查询地址:</strong></p> <div class="promql"> <a href="{{ (index .Alerts 0).GeneratorURL }}">{{ (index .Alerts 0).GeneratorURL }}</a> </div> <p><strong>历史数据:</strong><a href="http://10.213.70.8:3000">http://10.213.70.8:3000</a></p> </div> {{ else }} <div class="alert-box resolved"> <h2>✅ 恢复通知 - 监控报警</h2> <table> <tr><th>告警类型:</th><td>{{ .CommonLabels.alertname }}</td></tr> <tr><th>告警级别:</th><td> {{- if eq .CommonLabels.severity "critical" }}严重 {{- else if eq .CommonLabels.severity "warning" }}警告 {{- else }}{{ .CommonLabels.severity }}{{ end -}} </td></tr> <tr><th>告警状态:</th><td><strong style="color: green;">已恢复</strong></td></tr> <tr><th>故障主机:</th><td>{{ .GroupLabels.instance }}</td></tr> <tr><th>服务名称:</th><td>{{ .CommonLabels.job }}</td></tr> <tr><th>告警主题:</th><td>{{ (index .Alerts 0).Annotations.summary }}</td></tr> <tr><th>告警详情:</th><td>{{ (index .Alerts 0).Annotations.description }}</td></tr> <tr><th>故障时间:</th><td>{{ (index .Alerts 0).StartsAt.Format "2006-01-02 15:04:05" }}</td></tr> <tr><th>恢复时间:</th><td>{{ (index .Alerts 0).EndsAt.Format "2006-01-02 15:04:05" }}</td></tr> <tr><th>持续时间:</th><td>{{ (index .Alerts 0).EndsAt.Sub (index .Alerts 0).StartsAt }}</td></tr> </table> <p><strong>查询地址:</strong></p> <div class="promql"> <a href="{{ (index .Alerts 0).GeneratorURL }}">{{ (index .Alerts 0).GeneratorURL }}</a> </div> <p><strong>历史数据:</strong><a href="http://10.213.70.8:3000">http://10.213.70.8:3000</a></p> <p>问题已自动恢复,无需人工干预</p> </div> {{ end }} </body> </html> {{ end }} 修复
10-29
<!DOCTYPE html> <html lang="zh" class="van-theme-light"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>每日进度 - 日历选择</title> <!-- ✅ 确保 Vant 样式已下载到本地 --> <link rel="stylesheet" href="assets/lib/index.css" /> <style> body { margin: 0; padding: 0; background: #f7f8fa; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; } .divbox { margin: 10px; padding: 15px; background: #fff; border-radius: 8px; } .flexbox { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 16px 0; } .van-button__text { font-size: 16px; color: #333; } </style> </head> <body> <div id="app"> <!-- 导航栏 --> <van-nav-bar title="每日进度" left-arrow @click-left="goBack" /> <!-- 日期选择区域 --> <div class="flexbox"> <van-button icon="arrow-left" type="default" size="small" @click="prevDay"></van-button> <van-button type="primary" @click="showCalendar = true"> <span class="van-button__text">{{ formattedDate }}</span> </van-button> <van-button icon="arrow" type="default" size="small" @click="nextDay"></van-button> </div> <van-divider hairline /> <!-- 主内容区 --> <div class="divbox"> <p>当前选中日期:{{ currentDate.toLocaleDateString() }}</p> </div> <!-- 日历弹窗 --> <van-popup v-model:show="showCalendar" position="bottom"> <van-calendar v-model:show="showCalendar" :default-date="currentDate" @confirm="onSelectDate" :min-date="minDate" :max-date="maxDate" color="#1989fa" /> </van-popup> </div> <!-- 🔁 顺序至关重要 --> <script src="assets/lib/vue.global.js"></script> <script> if (typeof Vue === 'undefined') { console.error("❌ Vue 未加载成功,请检查文件路径!"); alert("Vue 加载失败"); } </script> <script src="./assets/lib/vant.min.js"></script> <script> if (typeof Vant === 'undefined') { console.error("❌ Vant 未加载成功,请检查文件路径!"); alert("Vant 加载失败"); } </script> <script> const { createApp } = Vue; const { NavBar, Button, Divider, Popup, Calendar } = Vant; // 确保组件存在 if (!Calendar) { console.warn("⚠️ Calendar 组件未找到,可能是 Vant 构建不完整"); } createApp({ data() { const today = new Date(); return { currentDate: today, showCalendar: false, minDate: new Date(today.getFullYear() - 1, 0, 1), maxDate: new Date(today.getFullYear() + 1, 11, 31) }; }, computed: { formattedDate() { const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']; const d = this.currentDate; const y = d.getFullYear(); const m = String(d.getMonth() + 1).padStart(2, '0'); const day = String(d.getDate()).padStart(2, '0'); const w = week[d.getDay()]; return `${y}/${m}/${day}(${w})`; } }, methods: { goBack() { history.back(); }, prevDay() { const d = new Date(this.currentDate); d.setDate(d.getDate() - 1); this.currentDate = d; }, nextDay() { const d = new Date(this.currentDate); d.setDate(d.getDate() + 1); this.currentDate = d; }, onSelectDate(date) { this.currentDate = new Date(date); this.showCalendar = false; } } }) .use(NavBar) .use(Button) .use(Divider) .use(Popup) .use(Calendar) .mount('#app'); </script> </body> </html> 你看下代码,对不对
11-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值