0%

问题描述

在Vmware虚拟机上,执行如下Shell代码获取VM类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

function get_VM_infra() {
local infra=$(dmidecode -t system | grep "Manufacturer")
echo "$infra" | grep "VMware" # 判断VM平台类型是否为VMware
if [ $? -eq 0 ]; then
echo "VMware"
else
echo "Other Type"
fi
}

infra=$(get_VM_infra)
echo "infra: $infra"

预期返回"VMware",实际返回"Manufacturer: VMware, Inc.\nVMware",这个返回的结果是错误的

1
2
# infra:  Manufacturer: VMware, Inc.
# VMware

原因分析

阅读全文 »

除了炒股,股票账户还有哪些功能?开股票账户是不是和去赌场赌博是一回事?股票账户有靠谱的赚钱手艺吗?

我的回答是:股票账户当然能赚钱,而且股票账户的功能非常丰富,可以是说现代投资理财必备工具。下面我介绍几个我常用的低风险投资工具,供大家参考:

阅读全文 »

定位步骤

后台查看Microk8s相关进程:

1
2
3
4
5
6
  7281 ?        Ss    27:02 /bin/bash /var/lib/snapd/snap/microk8s/3699/apiservice-kicker
749807 ? S 0:00 \_ sleep 5
7290 ? Ss 0:00 /bin/bash /var/lib/snapd/snap/microk8s/3699/run-cluster-agent-with-args
7362 ? S 2:32 \_ python3 /snap/microk8s/3699/usr/bin/gunicorn3 cluster.agent:app --bind 0.0.0.0:25000 --keyfile /var/snap/microk8s/3699/certs/server.key --certfile /var/snap/microk8s/3699/certs/server.crt --timeout 240
7684 ? S 0:02 \_ python3 /snap/microk8s/3699/usr/bin/gunicorn3 cluster.agent:app --bind 0.0.0.0:25000 --keyfile /var/snap/microk8s/3699/certs/server.key --certfile /var/snap/microk8s/3699/certs/server.crt --timeout 240
7310 ? Ssl 399:16 /snap/microk8s/3699/bin/containerd --config /var/snap/microk8s/3699/args/containerd.toml --root /var/snap/microk8s/common/var/lib/containerd --state /var/snap/microk8s/common/run/containerd --address /var/snap/microk8s/common/run/containerd.sock

和正常环境对比,发现k8s-dqlite, kubelite进程执行异常,如下:

阅读全文 »

代码实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

# 函数:提取 CIDR 的网络地址和子网掩码
function extract_network() {
echo $1 | awk -F '/' '{print $1}'
}

function extract_subnet() {
echo $1 | awk -F '/' '{print $2}'
}

# 函数:将 IP 地址转换为二进制格式
function ip_to_binary() {
local ip=$1
local binary=""
local IFS='.'
local octets=($ip)
for octet in "${octets[@]}"; do
local bin_octet=""
local num=$octet
for (( i=0; i<8; i++ )); do
bin_octet=$((num % 2))$bin_octet
num=$((num / 2))
done
binary+=$bin_octet
done
echo $binary
}
阅读全文 »