logo NodeSeekbeta

【NodeScriptKit】TrafficCop - 智能流量监控、限制与推送脚本

12345
  • 下面问题已解决


    alpine安装会提示vnstat未安装,然后提示如下

    2025-04-22 06:06:17 vnstat 未安装,将进行安装...
    2025-04-22 06:06:17 正在更新软件包列表...
    /root/TrafficCop/traffic_monitor.sh: line 90: sudo: command not found
    2025-04-22 06:06:17 更新软件包列表失败,请检查网络连接和系统状态。
    

    后面我就手动apk add vnstat安装,但是统计流量好像还是会出问题,不知道怎么解决,日志如下
    我看了traffic_monitor.sh文件,我看还依赖于local packages=("vnstat" "jq" "bc" "iproute2" "cron"), 我都使用apk add手动安装了,除了cron安装失败,但是结果依旧提示如下日志

    bwhus-12:~# bash /root/TrafficCop/tg_notifier.sh
    2025-04-22 06:28:45 文件已迁移到新的工作目录: /root/TrafficCop
    ----------------------------------------------
    2025-04-22 06:28:45 : 版本号:9.5
    pidof: unrecognized option: x
    BusyBox v1.36.1 (2023-10-09 08:04:29 UTC) multi-call binary.
    
    Usage: pidof [-s] [-o PID] [NAME]...
    
    List PIDs of all processes with names that match NAMEs
    
            -s      Show only one PID
            -o PID  Omit given pid
                    Use %PPID to omit pid of pidof's parent
    进入交互模式
    正确的 crontab 项已存在且只有一个,无需修改。
    当前的 crontab 内容:
    # do daily/weekly/monthly maintenance
    # min   hour    day     month   weekday command
    */15    *       *       *       *       run-parts /etc/periodic/15min
    0       *       *       *       *       run-parts /etc/periodic/hourly
    0       2       *       *       *       run-parts /etc/periodic/daily
    0       3       *       *       6       run-parts /etc/periodic/weekly
    0       5       1       *       *       run-parts /etc/periodic/monthly
    
    * * * * * /root/TrafficCop/traffic_monitor.sh --run
    * * * * * /root/TrafficCop/tg_notifier.sh -cron
    当前配置摘要:
    机器名称: 搬瓦工美西
    每日报告时间: 00:00
    Bot Token: 8062825280...
    Chat ID: 5650933694
    脚本正在运行中。按 'q' 退出,按 'c' 检查流量,按 'd' 手动发送每日报告,按 'r' 重新加载配置,按 't' 发送测试消息,按 'm' 修改配置,按 'h' 修改每日报告时间。
    d
    
    2025-04-22 06:28:53 : 开始生成每日报告
    2025-04-22 06:28:53 : DAILY_REPORT_TIME=00:00
    2025-04-22 06:28:53 : BOT_TOKEN=80628... CHAT_ID=***933694
    2025-04-22 06:28:53 : 日志文件路径: /root/TrafficCop/traffic_monitor.log
    grep: unrecognized option: P
    BusyBox v1.36.1 (2023-10-09 08:04:29 UTC) multi-call binary.
    
    Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
    
    Search for PATTERN in FILEs (or stdin)
    
            -H      Add 'filename:' prefix
            -h      Do not add 'filename:' prefix
            -n      Add 'line_no:' prefix
            -l      Show only names of files that match
            -L      Show only names of files that don't match
            -c      Show only count of matching lines
            -o      Show only the matching part of line
            -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
            -v      Select non-matching lines
            -s      Suppress open and read errors
            -r      Recurse
            -R      Recurse and dereference symlinks
            -i      Ignore case
            -w      Match whole words only
            -x      Match whole lines only
            -F      PATTERN is a literal (not regexp)
            -E      PATTERN is an extended regexp
            -m N    Match up to N times per file
            -A N    Print N lines of trailing context
            -B N    Print N lines of leading context
            -C N    Same as '-A N -B N'
            -e PTRN Pattern to match
            -f FILE Read pattern from file
    grep: unrecognized option: P
    BusyBox v1.36.1 (2023-10-09 08:04:29 UTC) multi-call binary.
    
    Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
    
    Search for PATTERN in FILEs (or stdin)
    
            -H      Add 'filename:' prefix
            -h      Do not add 'filename:' prefix
            -n      Add 'line_no:' prefix
            -l      Show only names of files that match
            -L      Show only names of files that don't match
            -c      Show only count of matching lines
            -o      Show only the matching part of line
            -q      Quiet. Return 0 if PATTERN is found, 1 otherwise
            -v      Select non-matching lines
            -s      Suppress open and read errors
            -r      Recurse
            -R      Recurse and dereference symlinks
            -i      Ignore case
            -w      Match whole words only
            -x      Match whole lines only
            -F      PATTERN is a literal (not regexp)
            -E      PATTERN is an extended regexp
            -m N    Match up to N times per file
            -A N    Print N lines of trailing context
            -B N    Print N lines of leading context
            -C N    Same as '-A N -B N'
            -e PTRN Pattern to match
            -f FILE Read pattern from file
    2025-04-22 06:28:53 : 无法从行中提取流量信息
    2025-04-22 06:28:53 : 问题行: 2025-04-22 06:28:01 当前使用流量: 00 GB,限制流量: 0 GB
    脚本正在运行中。按 'q' 退出,按 'c' 检查流量,按 'd' 手动发送每日报告,按 'r' 重新加载配置,按 't' 发送测试消息,按 'm' 修改配置,按 'h' 修改每日报告时间。
    
    
  • @Nstar #11 解决了就好。脚本目前对于除了debian以外的系统的兼容性目前确实测试不足。主要我alpine机器少的可怜,主要都是debian。

  • 支持一个

  • @ud0kXypFw #14 谢谢支持哈,大佬觉得好用的话 到时候可以投一票❤️

  • 这个针不错

  • 能不能加个server酱通知,一定投票

  • @ggchaos #17 大佬有兴趣PR吗🌚我没用过server酱🥲

  • @bacon159 #18 发布于2025/4/23 10:40:55
    @ggchaos #17 大佬有兴趣PR吗🌚我没用过server酱🥲
    就调一个api,easy

  • 插眼

12345

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有72034位seeker

🎉欢迎新用户🎉