跳到主要内容

43 篇博文 含有标签「编程」

查看所有标签

sudo apt install rdfind
rdfind -deleteduplicates true /media/faonecze/资料存档/

windows 用 DoubleKiller.exe 还挺方便的

编程阅读需 1 分钟

windows 进程 监控

  • windows wmi-exporter 进程监控
    • 对应的看板 dashboard Id 10467
    • 没有进程数据
      • 服务器管理器找到 WMI exporter
        • 添加参数 --collectors.enabled "[defaults],process,container"
Grafana Status Map Panel not working, shows "Panel plugin not found: flant-statusmap-panel" #197
  • 解决方法
    • Open your Grafana instance and go to the Plugins section in the left-hand -nu.
    • Search for "statusmap" in the search bar.
    • Click on the "Install" button for the "statusmap" plugin.
    • Wait for the installation to complete.\

Grafana + prometheus + node-exporter docker-compose.yml

vim prometheus/docker-compose.yml

version: "3.7"
services:
node_exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
user: "1000"
network_mode: host
# pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'
prometheus:
image: prom/prometheus:latest
container_name: "prometheus"
restart: always
ports:
- "9111:9090"
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
- "./prometheus_data:/prometheus"
grafana:
image: grafana/grafana
container_name: "grafana"
ports:
- "3000:3000"
restart: always
volumes:
- "./grafana_data:/var/lib/grafana"
process-exporter:
image: ncabatoff/process-exporter
command: --procfs /host/proc -config.path /config/process-exporter-config.yml
privileged: true
volumes:
- /proc:/host/proc
- ./process-exporter-config.yml:/config/process-exporter-config.yml
ports:
- "9256:9256"
restart: always

vim prometheus/prometheus.yml - 需要根据自己的 ip 进行修改器

global:
scrape_interval: 15s # 默认抓取周期
external_labels:
monitor: "codelab-monitor"
scrape_configs:
- job_name: "node-exporter" #服务的名称
scrape_interval: 5s
metrics_path: /metrics #获取指标的 url
static_configs:
- targets: ["192.168.31.2:9100"] # 这个为监听指定服务服务的 ip 和 port,需要修改为自己的 ip,貌似云服务必须用公网 ip
- job_name: "process-exporter"
scrape_interval: 5s
metrics_path: /metrics
static_configs:
- targets: ["192.168.31.2:9256"]
- job_name: "windows-laptop"
scrape_interval: 5s
metrics_path: /metrics
static_configs:
- targets: ["192.168.31.3:9182"]
- job_name: "other-node-192.168.31.5-node-exporter"
scrape_interval: 5s
metrics_path: /metrics
static_configs:
- targets: ["192.168.31.5"]

node-exporter linux 服务器状态监控

prometheus 相关

看板 Grafana

  • http://ip:9111/3000

  • 配合 node - 的 Dashborad 编号是 9276

    • Grafana 直接搜索 id 就能找到别人分享的看板。
    • 需要单独配置下 网络 io 图表。
    • 都是可视化的 先再 node-exporter 里找到相关指标,然后可视化点点点就能出现数据。
编程阅读需 2 分钟

配置完后,感觉 gitalk 的 clientID 和 clientSecret 不能直接放项目中,毕竟是开源的。

参考 action 的配置,在项目设置中找到 secert 配置,增加两个环境变量。

.github\workflows\ci.yml下面的 action 配置,增加如下配置:

GITALK_CLIENTID: ${{ secrets.GITALK_CLIENTID }}
GITALK_CLIENTSECRET: ${{ secrets.GITALK_CLIENTSECRET }}

config.js 中使用配置的环境变量名称就好了。

clientID: process.env.GITALK_CLIENTID,
clientSecret: process.env.GITALK_CLIENTSECRET,

本地测试因为填写了 feedback 为博客地址,会导致登陆后默认指向线上博客地址,所以本地测试没有成功。

好了博客评论系统开启了,其实相关评论都到 issus 里去了,还有点不习惯。

具体配置有啥不懂的,可以看看本项目的源码。

编程阅读需 1 分钟

pycharm使用远程环境后

会将远程的python环境download下来

然后放到pycharm的缓存目录下

在远程端口更新某个包后

本地的缓存还是这个包的老版本缓存

在debug打断点的时候会贼难受

目前还没有找到解决方案

记录一下。

参考:

解决方法:

  1. Try Settings | Project ... | Project Interpreter | Gear button | Show all | Show paths for the selected interpreter | Reload list of paths solution 1

  2. Go to External Libraries in the project tree and expand it. Right click on "Remote Libraries", you will see an option to "Synchornize 'number'"(并没有找到这个按钮) solution 2

3."Invalidate Cache/ Restart" under file menu but still the update of remote library.

编程阅读需 1 分钟

  • 在终端输入netstat -ano | findstr 5555获取占用 5555 端口的进程 pid
  • tasklist | findstr pid查看是那个进程占用了
  • 发现是 docker 占用了 关掉退出就好了
  • 可以选择暴力一点的方法 taskkill /pid 1234 /f (/f 指的是强行结束)
  • 利用进程的 PID 结束进程:ntsd -c q -p 1332 (结束 explorer.exe 进程)

参考

编程阅读需 1 分钟

博客想加个 steam 连接,但是没有 logo。找了半天终于找到配置方案,记录一下。

首先要找到一个叫 iconfontCssFile 的配置,知道可以引用在线的 css。

然后进 https://www.iconfont.cn/ 搜 steam 找到自己想要的图片 点击购物车图标添加至购物车。

右上角购物车添加至项目,没有就自己创建一个项目。

添加后就可以在项目中生成在线地址了。

好了,通过 vdooing 的配置已经加上 steam 连接了。

编程阅读需 1 分钟

  • 拿到了 GitHub Copilot 的使用权,真的很香,
  • 为此开始尝试使用 vscode 编程折磨自己。
  • 以前总说小体积 vscode 比不上 IDE pycharm,
  • 确实没有插件啥也不是,有插件了估计比 pycharm 还重。
  • vs code 选插件真的是很痛苦的事情,弄个表做个备份。

  • aw-watcher-vscode - ActivityWatch 监控插件
  • Code Spell Checker - 代码拼写检查
  • Darcula PyCharm Theme Darcula - PyCharm 主题
  • Deploy - 服务器部署
  • Docker - docker 插件
  • Foam for VSCode - 思维导图生成插件
  • GitHub Copilot - github 代码补全插件
  • GitLens — Git supercharged - 查看改动记录 ,文件历史
  • IntelliJ IDEA Keybindings - IntelliJ IDEA 快捷键
  • Jupyter ms-toolsai.jupyter - python jupyter 插件
  • MagicPython - python 调试插件
  • Markdown All in One - markdown 插件
  • Markdown Links - markdown 链接图生成插件
  • Markdown Notes - Markdown 贴条插件
  • Markdown Preview Mermaid Support - markdown Mermaid 图插件
  • markdownlint - markdown 代码检查
  • Marp for VS Code - markdown 转 ppt
  • Mermaid Markdown Syntax Highlighting - markdown Mermaid 语法高亮
  • Note Sync - 把 vscode 当笔记用的时候的同步插件
  • npm - npm 拓展
  • Open Window Tab Context - 右键 tab 再新打开一个窗口
  • Paste Image - markdown 贴图小助手
  • Prettier - Code formatter - 代码格式化
  • Pine Script Syntax Highlighter - pine 脚本语言代码高亮
  • Pylance - python 拓展包
  • Python - python 拓展包
  • Python Docstring Generator - google 风格 python 文档快速生成
  • Remote - Containers - docker 助手
  • Remote - SSH - 远程连接助手
  • Remote - SSH: Editing Configuration Files - 远程连接助手 2
  • Remote - WSL - wsl 远程连接助手
  • Remote Development - 远程部署合集包
  • Vetur - vue 拓展包
  • vscode-pdf - pdf 打开插件
  • vsinder - 交友插件
  • WakaTime - 活动记录统计插件
  • vim - vim 拓展包
  • git graph - git 图表
  • Markdown Mind Map Preview - markdown 转思维导图
  • vscode-office - markdown 所见所得

编程阅读需 2 分钟

  • 证书
  • [[搭建 xray-shadowsock]]
  • 推荐一个新的证书申请 certbot
  • [[certbot 证书]]

ssl

通过 acme.sh 生成证书并自动更新

curl  https://get.acme.sh | sh
apt install socat
/root/.acme.sh/acme.sh --register-account -m my@example.com
/root/.acme.sh/acme.sh --issue -d www.mydomain.com --standalone
/root/.acme.sh/acme.sh --upgrade --auto-upgrade

编写一键更新脚本

需要先关闭 nginx systemctl start nginx

  • 写了个脚本:vim /root/script/acme_job.sh
    • 更新 acme
    • 更新证书
  • 官方说两个月会自动更新。因为 Nginx 占用会失败。
echo "start acme.sh $(date +"%Y-%m-%d %H:%M:%S")"
systemctl stop nginx
/root/.acme.sh/acme.sh --upgrade --auto-upgrade
/root/.acme.sh/acme.sh --renew -d www.mydomain.com --force
/root/.acme.sh/acme.sh --renew -d www.mydomain2.com --force
systemctl start nginx
echo "finish acme.sh $(date +"%Y-%m-%d %H:%M:%S")"
echo "==========================="

设置自动执行时间

设置执行时间:

  • 05:02 执行脚本 (大概率不在这个时间段玩电脑)
  • vim /var/spool/cron/crontabs/root
2 5 * * * /usr/bin/bash /root/script/acme_job.sh > /var/log/acme_job.log
查看自动更新脚本日志
tail /var/log/acme_job.log
tail /var/log/cron.log

认证超时问题

查看日志

查看日志docker logs ss-libev -f --tail 20

2021/09/10 10:08:03 http: TLS handshake error from 192.168.1.1:999: remote error: tls: bad certificate
2021/09/10 10:08:04 http: TLS handshake error from 192.168.1.1:999: remote error: tls: bad certificate
2021/09/10 10:08:05 http: TLS handshake error from 192.168.1.1:999: remote error: tls: bad certificate
2021/09/10 10:08:06 http: TLS handshake error from 192.168.1.1:999: remote error: tls: bad certificate
  • 证书过时了
  • 输入命令更新证书:/root/.acme.sh/acme.sh --upgrade --auto-upgrade
  • 然后报错了:
[Fri 10 Sep 2021 10:11:37 AM CST] Renew: 'www.mydomain.com'
[Fri 10 Sep 2021 10:11:37 AM CST] Using CA: https://acme-v02.api.letsencrypt.org/directory
[Fri 10 Sep 2021 10:11:37 AM CST] Standalone mode.
[Fri 10 Sep 2021 10:11:37 AM CST] LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1481169,fd=8),("nginx",pid=898219,fd=8))
LISTEN 0 511 [::]:80 [::]:* users:(("nginx",pid=1481169,fd=9),("nginx",pid=898219,fd=9))
[Fri 10 Sep 2021 10:11:37 AM CST] tcp port 80 is already used by (("nginx",pid=1481169,fd=8),("nginx",pid=898219,fd=8))
80 [
[Fri 10 Sep 2021 10:11:37 AM CST] Please stop it first
[Fri 10 Sep 2021 10:11:37 AM CST] _on_before_issue.

  • ubuntu 需要 打开 crontab 日志
    • vim /etc/rsyslog.d/50-default.conf
    • 打开文件,在文件中找到 cron.*,把前面的 '#'去掉,保存退出,输入
    • sudo service rsyslog restart
  • 重启系统日志,然后稍微等下应该就能在 /var/log 目录下看到 cron.log,vim cron.log 就可以查看 cron 运行日志了。

acme.sh 报错 can not get domain token

Error, can not get domain token "type":"http-01","url":"https://acme.zerossl.com/v2/DV90/chall/ZlNEi3nO05c_rSrqfaId_A","status":"invalid","error":{
Please add '--debug' or '--log' to check more details.
  • 参考
  • /root/.acme.sh/acme.sh --issue -d www.mydomain.com --standalone --server https://acme-v02.api.letsencrypt.org/directory
编程阅读需 2 分钟

参考

ssl

通过 acme.sh 生成证书并自动更新

curl  https://get.acme.sh | sh
apt install socat
/root/.acme.sh/acme.sh --register-account -m my@example.com
/root/.acme.sh/acme.sh --issue -d www.mydomain.com --standalone
/root/.acme.sh/acme.sh --upgrade --auto-upgrade

配置配置文件

mkdir /etc/shadowsocks-libev

# vim /etc/shadowsocks-libev/config.json
{
"server":"0.0.0.0",
"server_port":9000,
"password":"password",
"timeout":300,
"method":"aes-256-gcm",
"fast_open":true,
"nameserver":"8.8.8.8",
"mode":"tcp_and_udp",
"plugin":"xray-plugin:tls;host=www.mydomain.com",
"plugin_opts":"server"
}

docker 启动 shadowsocks

docker pull teddysun/shadowsocks-libev
docker run -d -p 9000:9000 -p 9000:9000/udp --name ss-libev --restart=always -v /etc/shadowsocks-libev:/etc/shadowsocks-libev -v /root/.acme.sh:/root/.acme.sh teddysun/shadowsocks-libev

客户端配置

  • xray-plugin 下载对应软件
  • 放到 shadowsocks 客户端文件夹里
  • 写入配置
    {
"server": "www.mydomain.com",
"server_port": 9000,
"password": "password",
"method":"aes-256-gcm",
"plugin": "xray-plugin",
"plugin_opts": "tls;host=www.mydomain.com",
"plugin_args": "",
"remarks": "mydomain.com",
"timeout": 5
},
  • 安卓用户点 这里 下载

编程阅读需 1 分钟

  • [[自建 RSS 订阅]]

  • 在博客或者项目底端找到RSS连接,获取URL。

eg. https://anguswg.github.io/AngusWG/rss.xml

rss

  • IFTTT注册账号
  • CREATE NEW 创建一条新规则
  • IF RSS 增加条件 如果rss更新

search rss add RSS URL

  • THEN EMAIL

Trigger email

feedly

这里有另一个订阅方式 feedly 操作上也是获取RSS,贴上去就好了~

Outlook RSS(目前使用中)

outlook自带了一个rss订阅方案

  • 首先会把所有的文章都下载下来。
  • 我每天都会检查邮件,放在outlook反而更方便。
  • 不足是找不到订阅连接,所以都先放到了友情链接

编程阅读需 1 分钟