Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat_client 在 Alpine 上运行报错 #18

Closed
ghost opened this issue Apr 14, 2022 · 7 comments
Closed

stat_client 在 Alpine 上运行报错 #18

ghost opened this issue Apr 14, 2022 · 7 comments
Labels
good first issue Good for newcomers

Comments

@ghost
Copy link

ghost commented Apr 14, 2022

尝试在Alpine Linux下运行报错如下:

./stat_client -a "https://host/report" -u user -p pass
[client/src/main.rs:297] &args = Args {
    addr: "https://host/report",
    user: "user",
    pass: "pass",
    vnstat: false,
    disable_tupd: false,
    disable_ping: false,
    ct_addr: "ct.tz.cloudcpp.com:80",
    cm_addr: "cm.tz.cloudcpp.com:80",
    cu_addr: "cu.tz.cloudcpp.com:80",
}
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 2', client/src/status.rs:187:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted

client版本为 1.3.5
相同配置在debian11中正常运行

@zdz
Copy link
Owner

zdz commented Apr 15, 2022

在你的环境(Alpine Linux)试试运行下面的命令,把运行的结果输出粘贴出来看看

df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs

@zdz zdz added the bug Something isn't working label Apr 15, 2022
@ghost
Copy link
Author

ghost commented Apr 15, 2022

在你的环境(Alpine Linux)试试运行下面的命令,把运行的结果输出粘贴出来看看

df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs

远程环境:

# uname -s
Linux 4ac4b485 5.12.2 #1 SMP Thu Feb 10 23:52:09 UTC 2022 x86_64 GNU/Linux
# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
/dev/vdb       ext4      8000    65      7510   1% /
total          -         8000    65      7510   1% -

本地测试环境:

# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
/dev/sde       ext4    257007   734    243149   1% /etc/hosts
total          -       257007   734    243149   1% -

@zdz
Copy link
Owner

zdz commented Apr 15, 2022

你的 alpine 是什么版本?df 命令是什么版本? 默认的 df 版本是 busybox 版本,也可以安装 gnu coreutil 的版本,跑这个 df 命令均不兼容

localhost:~# cat /etc/issue
Welcome to Alpine Linux 3.15
Kernel \r on an \m (\l)

localhost:~# uname -a
Linux localhost 5.15.32-0-lts #1-Alpine SMP Mon, 28 Mar 2022 13:09:00 +0000 x86_64 GNU/Linux

localhost:~# df --version
df: unrecognized option: version
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

localhost:~# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
df: unrecognized option: l
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

localhost:~# apk add coreutils

localhost:~# df --version
df (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

localhost:~# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
df: no file systems processed

@zdz
Copy link
Owner

zdz commented Apr 16, 2022

@ghost
Copy link
Author

ghost commented Apr 17, 2022

你的 alpine 是什么版本?df 命令是什么版本? 默认的 df 版本是 busybox 版本,也可以安装 gnu coreutil 的版本,跑这个 df 命令均不兼容

localhost:~# cat /etc/issue
Welcome to Alpine Linux 3.15
Kernel \r on an \m (\l)

localhost:~# uname -a
Linux localhost 5.15.32-0-lts #1-Alpine SMP Mon, 28 Mar 2022 13:09:00 +0000 x86_64 GNU/Linux

localhost:~# df --version
df: unrecognized option: version
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

localhost:~# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
df: unrecognized option: l
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.

localhost:~# apk add coreutils

localhost:~# df --version
df (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

localhost:~# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
df: no file systems processed

本地是在docker里面跑的,df和alpine版本如下
同样在docker中的Debian11则可以正常运行

235b67cddab1:~# script -a run.log
Script started, output log file is 'run.log'.
235b67cddab1:~# uname -a
Linux 235b67cddab1 5.17.2-1-default #1 SMP PREEMPT Sat Apr 9 06:30:15 UTC 2022 (b49cf22) x86_64 GNU/Linux
235b67cddab1:~# cat /etc/issue
Welcome to Alpine Linux 3.15
Kernel \r on an \m (\l)

235b67cddab1:~# df --version
df (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.
235b67cddab1:~# df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t b
trfs -t fuseblk -t zfs -t simfs -t xfs
Filesystem     Type  1M-blocks  Used Available Use% Mounted on
/dev/nvme0n1p2 btrfs    131072 17074    112852  14% /
/dev/nvme0n1p2 btrfs    131072 17074    112852  14% /etc/hosts
total          -        262144 34148    225703  14% -
235b67cddab1:~# 
Script done.

@zdz
Copy link
Owner

zdz commented Apr 17, 2022

docker 镜像是哪个?提供一下 docker pull xxxx 命令,我把镜像拉下来试试
我拉官方镜像 alpine:3.15,测试没啥问题

[root@racknerd-a6bcd4 ~]# docker pull alpine:3.15
[root@racknerd-a6bcd4 ~]# docker run -it alpine:3.15 sh
/ # cd /tmp

/tmp # apk add unzip wget coreutils
(1/6) Installing libacl (2.2.53-r0)
(2/6) Installing libattr (2.5.1-r1)
(3/6) Installing skalibs (2.11.0.0-r0)
(4/6) Installing s6-ipcserver (2.11.0.0-r0)
(5/6) Installing utmps (0.1.0.3-r0)
Executing utmps-0.1.0.3-r0.pre-install
(6/6) Installing coreutils (9.0-r2)
Executing busybox-1.34.1-r5.trigger
OK: 10 MiB in 24 packages

/tmp # wget https://github.com/zdz/ServerStatus-Rust/releases/download/v1.3.6/ServerStatus-x86_64-unknown-linux-musl.zip
/tmp # unzip ServerStatus-x86_64-unknown-linux-musl.zip
Archive:  ServerStatus-x86_64-unknown-linux-musl.zip
  inflating: stat_server
  inflating: stat_client
  inflating: config.toml
  inflating: stat_server.service
  inflating: stat_client.service

/tmp # ls
ServerStatus-x86_64-unknown-linux-musl.zip  config.toml  stat_client  stat_client.service  stat_server	stat_server.service
/tmp # ./stat_server &
/tmp # run in normal mode, load config from local file
Listening on http://0.0.0.0:8080
Listening on tcp://0.0.0.0:34512

/tmp # df --version
df (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.

/tmp # df -Tlm --total -t ext4 -t ext3 -t ext2 -t reiserfs -t jfs -t ntfs -t fat32 -t btrfs -t fuseblk -t zfs -t simfs -t xfs
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
/dev/vda1      ext4     33230 17217     14308  55% /etc/hosts
total          -        33230 17217     14308  55% -

/tmp # RUST_BACKTRACE=1 RUST_LOG=trace ./stat_client
[client/src/main.rs:297] &args = Args {
    addr: "http://127.0.0.1:8080/report",
    user: "h1",
    pass: "p1",
    vnstat: false,
    disable_tupd: false,
    disable_ping: false,
    ct_addr: "ct.tz.cloudcpp.com:80",
    cm_addr: "cm.tz.cloudcpp.com:80",
    cu_addr: "cu.tz.cloudcpp.com:80",
}
 INFO  stat_client::status > cu.tz.cloudcpp.com:80 => 60.215.138.235:80
 INFO  stat_client::status > ct.tz.cloudcpp.com:80 => 180.76.76.76:80
 INFO  stat_client::status > cm.tz.cloudcpp.com:80 => 211.139.145.129:80
 INFO  stat_client::status > ipv4.google.com:80 => 142.251.33.14:80
 INFO  stat_client::status > Ok(Ok(()))
 INFO  stat_client::status > ipv6.google.com:80 => [2607:f8b0:4023:1004::8a]:80
 INFO  stat_client::status > Err(Os { code: 101, kind: NetworkUnreachable, message: "Network unreachable" })
 TRACE stat_client         > json_str => "{\"network_rx\":0,\"time_189\":0,\"ping_189\":0,\"process\":5,\"ping_10010\":0,\"memory_total\":1881836,\"time_10086\":0,\"memory_used\":620148,\"swap_total\":2097148,\"load_15\":1.64,\"tcp\":4294967295,\"swap_used\":59904,\"online6\":false,\"ping_10086\":0,\"network_tx\":0,\"latest_ts\":1650198118,\"cpu\":8.0,\"vnstat\":false,\"hdd_total\":33230,\"load_5\":1.45,\"hdd_used\":17215,\"time_10010\":0,\"network_out\":38771,\"name\":\"h1\",\"network_in\":7215865,\"uptime\":3007805,\"load_1\":0.96,\"frame\":\"data\",\"thread\":4294967294,\"online4\":true,\"udp\":4294967295}"

@ghost
Copy link
Author

ghost commented Apr 17, 2022

刚刚使用 apk add coreutils 后执行 stat_client 正常运行,应该是依赖问题
因为我看二进制是 statically linked ,下意识认为无需依赖

@zdz zdz added good first issue Good for newcomers and removed bug Something isn't working labels Apr 18, 2022
@zdz zdz closed this as completed Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant