测试中文标题的文章
测试中文标题的文章
这是第一段内容。 这是第二段内容。 这是第三段内容。
这是第一段内容。 这是第二段内容。 这是第三段内容。
本文介绍如何在 Alpine Linux 系统上部署 SmokePing 网络延迟监控工具,使用 Caddy 作为 Web 服务器,FCGIWrap 处理 CGI 脚本。
# 更新软件包索引
apk update
# 安装 SmokePing 及相关组件
apk add fcgiwrap fcgiwrap-openrc caddy smokeping smokeping-openrc
# 创建 fcgiwrap 服务用户
useradd -r fcgiwrap-openrc
# 创建 SmokePing 数据目录
mkdir -p /var/lib/smokeping/Ping
mkdir -p /var/lib/smokeping/DNS
# 设置权限
chown smokeping:smokeping /var/lib/smokeping/Ping
chown smokeping:smokeping /var/lib/smokeping/DNS
chmod 777 /var/lib/smokeping/images/Ping
chmod 777 /var/lib/smokeping/images/DNS
创建 Caddy 配置文件 /etc/caddy/Caddyfile:
{
log {
output file /var/log/caddy/access.log {
roll_size 100MB # 单个日志文件最大 100MB
roll_keep 10 # 保留最近 10 个日志文件
roll_keep_for 720h # 保留 30 天(720 小时)
}
format console # 易读的格式,也可改用 json 格式(format json)
}
}
http://192.168.1.100 {
# 处理静态资源
handle_path /js/* {
root * /usr/share/webapps/smokeping/
file_server
}
handle_path /css/* {
root * /usr/share/webapps/smokeping/
file_server
}
handle_path /imgcache/* {
root * /usr/share/webapps/smokeping/
file_server
}
handle_path /images/* {
root * /var/lib/smokeping/images
file_server browse
}
# 处理 CGI 请求
handle {
root * /usr/share/webapps/smokeping/
reverse_proxy unix//run/fcgiwrap/fcgiwrap.sock {
transport fastcgi {
env SCRIPT_FILENAME /usr/share/webapps/smokeping/smokeping.cgi
split ""
}
}
}
}
创建配置文件 /etc/smokeping/config:
*** General ***
owner = Demo User
contact = admin@example.com
mailhost = mail.example.com
sendmail = /usr/sbin/sendmail
# NOTE: do not put the Image Cache below cgi-bin
# since all files under cgi-bin will be executed ... this is not
# good for images.
imgcache = /var/lib/smokeping/images
imgurl = /images
datadir = /var/lib/smokeping
piddir = /run/smokeping
cgiurl = http://192.168.1.100/smokeping.cgi
smokemail = /etc/smokeping/smokemail
tmail = /etc/smokeping/tmail
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no
*** Alerts ***
to = admin@example.com
from = smokeping@example.com
# 定义各种告警规则
+hostdown
type = loss
# in percent
pattern ==0%,==0%,==0%, ==U
comment = 对端无响应
+bigloss
type = loss
# in percent
pattern ==0%,==0%,==0%,==0%,>20%,>20%,>20%
comment = 连续3次采样-丢包率超过20%
+lossdetect
type = loss
# in percent
pattern ==0%,==0%,==0%,==0%,>0%,>0%,>0%
comment = 连续3次采样-存在丢包
+someloss
type = loss
# in percent
pattern >0%,*12*,>0%,*12*,>0%
comment = 间断性丢包
+rttdetect
type = rtt
# in milli seconds
pattern <100,<100,<100,<100,<100,<150,>150,>150,>150
comment = 连续3次采样延迟增大-超过150ms
*** Database ***
step = 300
pings = 20
# consfn mrhb steps total
AVERAGE 0.5 1 28800
AVERAGE 0.5 12 9600
MIN 0.5 12 9600
MAX 0.5 12 9600
AVERAGE 0.5 144 2400
MAX 0.5 144 2400
MIN 0.5 144 2400
*** Presentation ***
template = /etc/smokeping/basepage.html
htmltitle = yes
graphborders = no
# If enabled, treat all filter menu queries as literal strings instead of regex
literalsearch = no
+ charts
menu = Charts
title = The most interesting destinations
++ stddev
sorter = StdDev(entries=>4)
title = Top Standard Deviation
menu = Std Deviation
format = Standard Deviation %f
++ max
sorter = Max(entries=>5)
title = Top Max Roundtrip Time
menu = by Max
format = Max Roundtrip Time %f seconds
++ loss
sorter = Loss(entries=>5)
title = Top Packet Loss
menu = Loss
format = Packets Lost %f
++ median
sorter = Median(entries=>5)
title = Top Median Roundtrip Time
menu = by Median
format = Median RTT %f seconds
*** Probes ***
+ FPing
binary = /usr/sbin/fping
+ DNS
binary = /usr/bin/dig
lookup = g.cn
pings = 5
step = 180
*** Slaves ***
secrets=/etc/smokeping/smokeping_secrets
+boomer
display_name=boomer
color=0000ff
+slave2
display_name=another
color=00ff00
*** Targets ***
alerts = someloss
probe = FPing
menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of <b>Example Company</b>. \
Here you will learn all about the latency of our network.
+ Ping
menu = Ping
title = 10.0.0.14 Pings
alerts = hostdown,bigloss,lossdetect,someloss,rttdetect
++ server1
menu = 192.168.1.50
host = 192.168.1.50
++ server2
menu = 192.168.1.51
host = 192.168.1.51
+ DNS
menu = DNS
probe = DNS
alerts = hostdown,bigloss,lossdetect,someloss,rttdetect
++ dns-server
menu = 192.168.1.200
host = 192.168.1.200
# 启动 Caddy 服务
rc-service caddy start
rc-service caddy add
# 启动 SmokePing 服务
rc-service smokeping start
rc-service smokeping add
# 启动 fcgiwrap 服务
rc-service fcgiwrap start
rc-service fcgiwrap add
# 检查 Caddy 状态
rc-service caddy status
# 检查 SmokePing 状态
rc-service smokeping status
# 检查 fcgiwrap 状态
rc-service fcgiwrap status
访问 http://192.168.1.100/smokeping.cgi 验证 SmokePing 是否正常工作。
Gitea 是一个轻量级的自托管 Git 服务,采用 Go 语言编写,是 GitHub 和 GitLab 的轻量替代方案。它提供了完整的代码托管功能,包括 Issues、Pull Requests、Wiki、CI/CD 等,同时保持了极低的资源占用。
| 特性 | Gitea | GitLab | GitHub |
|---|---|---|---|
| 资源占用 | 极低(100MB RAM) | 高(2GB+ RAM) | SaaS |
| 部署复杂度 | 简单 | 复杂 | 无需部署 |
| 数据控制 | 完全自控 | 完全自控 | 依赖第三方 |
| 国内访问 | 可部署内网 | 可部署内网 | 需代理 |
Route-Map 是 FRR (FRRouting) 中强大的路由策略工具,用于控制 OSPF 路由的发布和接收。通过 Route-Map,可以实现:
Route-Map 由一条或多条 sequence 组成,每个 sequence 有:
permit(允许)或 deny(拒绝)Route-Map 按序列号从小到大依次执行:
| 匹配类型 | 说明 | 示例 |
|---|---|---|
ip address | 匹配 IP 地址/前缀 | match ip address prefix-list LIST |
interface | 匹配出接口 | match interface eth0 |
metric | 匹配路由开销 | match metric 100 |
protocol | 匹配路由协议类型 | match protocol ospf |
next-hop | 匹配下一跳地址 | match ip next-hop A.B.C.D |
tag | 匹配路由标签 | match tag 100 |
as-path | 匹配 AS 路径(BGP) | match as-path 100 |
ospf - OSPF 路由static - 静态路由connected - 直连路由kernel - 内核路由rip - RIP 路由bgp - BGP 路由isis - IS-IS 路由pim - PIM 路由router ospf
# 定义前缀列表
ip prefix-list INTERNAL_NETS seq 5 permit 10.0.0.0/8 le 24
ip prefix-list INTERNAL_NETS seq 10 permit 172.16.0.0/12 le 24
ip prefix-list INTERNAL_NETS seq 15 permit 192.168.0.0/16 le 24
ip prefix-list INTERNAL_NETS seq 20 deny any
# 应用到路由重分发
redistribute connected route-map FILTER_CONNECTED
# 定义 route-map
route-map FILTER_CONNECTED permit 10
match ip address prefix-list INTERNAL_NETS
# 定义要过滤的网段
ip prefix-list BLOCK_NETS seq 5 deny 192.168.100.0/24
ip prefix-list BLOCK_NETS seq 10 permit any
# 应用到路由注入
router ospf
default-information originate route-map FILTER_DEFAULT
route-map FILTER_DEFAULT permit 10
match ip address prefix-list BLOCK_NETS
route-map SET_METRIC permit 10
set metric 100
route-map SET_METRIC permit 20
match ip address prefix-list SPECIAL_NETS
set metric 50
# 应用
router ospf
redistribute static route-map SET_METRIC
route-map METRIC_BY_TYPE permit 10
match ip address prefix-list CRITICAL_NETS
set metric 10
route-map METRIC_BY_TYPE permit 20
match ip address prefix-list NORMAL_NETS
set metric 100
# 定义匹配条件
ip prefix-list ISP_ROUTE seq 5 permit 0.0.0.0/0
route-map CONDITIONAL_DEFAULT permit 10
match ip address prefix-list ISP_ROUTE
router ospf
default-information originate route-map CONDITIONAL_DEFAULT always
# 只允许特定 BGP 路由进入 OSPF
ip prefix-list FROM_BGP seq 5 permit 203.0.113.0/24
ip prefix-list FROM_BGP seq 10 permit 198.51.100.0/24
ip prefix-list FROM_BGP seq 15 deny any
route-map BGP_TO_OSPF permit 10
match ip address prefix-list FROM_BGP
set metric 50
set metric-type type-1
router ospf
redistribute bgp route-map BGP_TO_OSPF
# 静态路由重分发
route-map STATIC_TO_OSPF permit 10
match ip address prefix-list STATIC_NETS
set metric 20
# 直连路由重分发
route-map CONNECTED_TO_OSPF permit 10
match interface eth0 eth1
set metric 10
router ospf
redistribute connected route-map CONNECTED_TO_OSPF
redistribute static route-map STATIC_TO_OSPF
# 匹配所有 OSPF 路由
route-map ONLY_OSPF permit 10
match protocol ospf
set metric 50
# 在重分发时应用
router ospf
redistribute connected route-map ONLY_OSPF
# 排除 OSPF 路由,只允许其他协议的路由
route-map EXCLUDE_OSPF permit 10
match protocol static
match protocol connected
match protocol kernel
set metric 20
route-map EXCLUDE_OSPF deny 20
match protocol ospf
# 或者使用更简洁的方式
route-map FILTER_PROTOCOL permit 10
match protocol static
set metric 30
!
route-map FILTER_PROTOCOL permit 20
match protocol connected
set metric 10
!
# 默认拒绝其他协议(包括 ospf)
# 区分 OSPF 内部路由和外部路由
route-map OSPF_INTERNAL permit 10
match protocol ospf
match ip address prefix-list INTERNAL_PREFIX
set metric 10
route-map OSPF_EXTERNAL permit 20
match protocol ospf
set metric 100
router ospf
redistribute ospf route-map OSPF_EXTERNAL
# 区域间路由过滤
router ospf
area 1 filter-list prefix IN_AREA1 in
area 1 filter-list prefix OUT_AREA1 out
ip prefix-list IN_AREA1 seq 5 deny 192.168.10.0/24
ip prefix-list IN_AREA1 seq 10 permit 10.0.0.0/8 le 24
ip prefix-list IN_AREA1 seq 15 permit 172.16.0.0/12 le 24
ip prefix-list IN_AREA1 seq 20 permit 192.168.0.0/16 le 24
# 显示 route-map 配置
show route-map
# 显示前缀列表
show ip prefix-list
# 显示 OSPF 路由表
show ip ospf route
# 显示 OSPF 数据库
show ip ospf database
# 显示 route-map 统计信息
show ip protocols ospf
# 启用 OSPF 调试
debug ospf lsa
debug ospf zebra
# 查看路由重分发情况
show ip ospf redistribute
# 查看各协议路由
show ip route ospf
show ip route static
show ip route connected
show ip route bgp
# 查看 route-map 匹配统计
show ip route-map detail
# 使用描述性的名称
route-map FILTER_EXTERNAL_STATIC permit 10
route-map SET_METRIC_INTERNAL permit 10
route-map BGP_TO_OSPF permit 10
# 使用 10 的倍数,方便插入新规则
route-map EXAMPLE permit 10
route-map EXAMPLE permit 20
route-map EXAMPLE permit 30
# 后续可以在 10 和 20 之间插入
route-map EXAMPLE permit 15
# 总是添加最后的拒绝规则
route-map EXAMPLE permit 10
match ip address prefix-list ALLOW_NETS
!
route-map EXAMPLE deny 20
!
# 隐含的 deny any 在最后
# 临时设置为 permit 观察效果
route-map TEMP_DEBUG permit 100
set metric 999
# 确认无误后调整
no route-map TEMP_DEBUG permit 100
本文记录了将 Netbox 从旧环境迁移到 k3s 集群的过程。
使用 pg_dump 导出 Netbox 数据库,排除变更日志表以减小备份体积:
pg_dump --username netbox --password --host localhost --exclude-table-data=extras_objectchange netbox > netbox.sql
为了避免 Pod 竞争和锁定问题,先删除现有的 Netbox Pod:
kubectl delete po netbox-68cbd8b854-2hvgp
# 进入 PostgreSQL Pod
kubectl exec -it netbox-postgresql-0 -- sed -ibak 's/^\([^#]*\)md5/\1trust/g' /opt/bitnami/postgresql/conf/pg_hba.conf
# 重新加载配置
kubectl exec -it netbox-postgresql-0 -- pg_ctl reload
kubectl exec -it netbox-postgresql-0 -- psql -U postgres
DROP DATABASE netbox;
CREATE DATABASE netbox;
ALTER USER netbox WITH PASSWORD 'balabalabala';
ALTER DATABASE netbox OWNER TO netbox;
-- PostgreSQL 15 及以上版本需要
\connect netbox;
GRANT CREATE ON SCHEMA public TO netbox;
kubectl exec -it netbox-postgresql-0 -- sed -i 's/^\([^#]*\)trust/\1md5/g' /opt/bitnami/postgresql/conf/pg_hba.conf
kubectl exec -it netbox-postgresql-0 -- pg_ctl reload
kubectl exec -it netbox-postgresql-0 -- sh -c "PGPASSWORD=balabalabala psql -U netbox -d netbox < /tmp/netbox.sql"
wget可以通过--content-disposition参数使用HTTP响应头中的Content-Disposition字段来设置下载文件的文件名。
wget [--no-check-certificate] --content-disposition 'url'
Content-Disposition是HTTP响应头中的一个字段,用于指示如何处理响应内容。当服务器希望浏览器下载文件而不是显示时,会使用这个字段。
常见的格式:
Content-Disposition: attachment; filename="example.pdf"
Content-Disposition: attachment; filename*=UTF-8''%E4%BE%8B%E5%AD%90.pdf
--content-disposition: 启用对Content-Disposition头的支持--no-check-certificate: 跳过SSL证书验证(可选,用于自签名证书)当下载链接指向动态生成的文件时,服务器会通过Content-Disposition指定正确的文件名:
wget --content-disposition "https://example.com/download.php?id=123"
对于包含中文字符的文件名,Content-Disposition可能会使用URL编码:
wget --content-disposition "https://example.com/中文文件.pdf"
wget会自动处理URL编码的文件名。
结合其他参数使用:
# 后台下载,使用Content-Disposition文件名
wget -b --content-disposition "https://example.com/file.zip"
# 限制下载速度,使用Content-Disposition文件名
wget --limit-rate=100k --content-disposition "https://example.com/large-file.iso"
Netbox升级到4.4版本后,打开Racks视图,发现页面空白。打开页面控制台发现报错oobErrorNoTarget.查询资料发现,问题在于新引入的"HTMX Navigation"功能。临时方案为:打开用户设置,“HTMX Navigation"选项选择"Disabled”
sed 's/[[:blank:]]\{2,\}/\t/g' config
以下是几个常用的在线文件共享服务,可用于快速分享文件给他人:
以下是几款优秀的在线抠图工具,各有特色,可根据需求选择使用:
https://html.zone/background-remover/
https://www.pickwant.com/removebg
部分工具支持批量上传多张图片同时处理,大大提高工作效率:
HTML Zone Background Remover - 界面简洁,操作简单,适合新手快速上手
0v0 AI BG Remover - 完全免费,效果优秀,性价比最高
Pickwant - AI 算法精准,功能全面,适合专业设计和商业用途
高定抠图 - 中文界面优化,本土化服务,响应速度快
在线抠图工具已经达到了相当高的技术水平,AI 算法的应用让普通人也能轻松完成专业级的抠图工作。根据具体需求选择合适的工具,可以大大提高工作效率和图片质量。建议多尝试几款工具,找到最适合自己使用习惯的解决方案。