[init] 修改大量代码
This commit is contained in:
@@ -1,38 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||
. /octopus-agent/shell/lib/wdd-lib-sys.sh
|
||||
. ./wdd-lib-log.sh
|
||||
. ./wdd-lib-sys.sh
|
||||
|
||||
#. .wdd-lib-log.sh
|
||||
#. .wdd-lib-sys.sh
|
||||
|
||||
hostArchVersion=""
|
||||
hostArch=""
|
||||
host_arch_version=""
|
||||
host_arch=""
|
||||
#### CollectSystemInfo ####
|
||||
serverName=""
|
||||
serverIpPbV4=""
|
||||
serverIpInV4=""
|
||||
serverIpPbV6=""
|
||||
serverIpInV6=""
|
||||
server_name=""
|
||||
server_ip_pb_v4=""
|
||||
server_ip_in_v4=""
|
||||
server_ip_pb_v6=""
|
||||
server_ip_in_v6=""
|
||||
location=""
|
||||
provider=""
|
||||
managePort=""
|
||||
cpuBrand=""
|
||||
cpuCore=""
|
||||
memoryTotal=""
|
||||
diskTotal=""
|
||||
diskUsage=""
|
||||
osInfo=""
|
||||
osKernelInfo=""
|
||||
tcpControl=""
|
||||
manage_port=""
|
||||
cpu_brand=""
|
||||
cpu_core=""
|
||||
memory_total=""
|
||||
disk_total=""
|
||||
disk_usage=""
|
||||
os_info=""
|
||||
os_kernel_info=""
|
||||
tcp_control=""
|
||||
virtualization=""
|
||||
ioSpeed=""
|
||||
machineId=""
|
||||
archInfo=""
|
||||
agentVersion=""
|
||||
io_speed=""
|
||||
machine_id=""
|
||||
arch_info=""
|
||||
agent_version=""
|
||||
|
||||
### tmp usage
|
||||
ioavg=""
|
||||
io_avg=""
|
||||
public_ipv4=""
|
||||
inner_ipv4=""
|
||||
public_ipv6=""
|
||||
@@ -41,7 +38,9 @@ country=""
|
||||
region=""
|
||||
city=""
|
||||
org=""
|
||||
managePort=""
|
||||
manage_port=""
|
||||
machine_number=""
|
||||
l_bit=""
|
||||
#### CollectSystemInfo ####
|
||||
|
||||
#######################################
|
||||
@@ -49,7 +48,7 @@ managePort=""
|
||||
# Arguments:
|
||||
# 1
|
||||
#######################################
|
||||
GoIOTest() {
|
||||
io_test() {
|
||||
(LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count=$1 conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
}
|
||||
|
||||
@@ -93,10 +92,12 @@ calc_size() {
|
||||
# Returns:
|
||||
# <unknown> ...
|
||||
#######################################
|
||||
GethostArchInfo() {
|
||||
get_host_arch_info() {
|
||||
FunctionStart "开始获取系统架构信息!"
|
||||
[ -f /etc/redhat-release ] && awk '{print $0}' /etc/redhat-release && return
|
||||
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
|
||||
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
@@ -115,19 +116,19 @@ GethostArchInfo() {
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
StartIOTest() {
|
||||
log "start IO speed test !"
|
||||
start_io_test() {
|
||||
FunctionStart "开始测试IO速度!"
|
||||
freespace=$(df -m . | awk 'NR==2 {print $4}')
|
||||
if [ -z "${freespace}" ]; then
|
||||
freespace=$(df -m . | awk 'NR==3 {print $3}')
|
||||
fi
|
||||
if [ ${freespace} -gt 1024 ]; then
|
||||
writemb=2048
|
||||
io1=$(GoIOTest ${writemb})
|
||||
io1=$(go_iotest ${writemb})
|
||||
log "I/O Speed(1st run) : $io1)"
|
||||
io2=$(GoIOTest ${writemb})
|
||||
io2=$(go_iotest ${writemb})
|
||||
log "I/O Speed(2st run) : $io2)"
|
||||
io3=$(GoIOTest ${writemb})
|
||||
io3=$(go_iotest ${writemb})
|
||||
log "I/O Speed(3st run) : $io3)"
|
||||
ioraw1=$(echo $io1 | awk 'NR==1 {print $1}')
|
||||
[ "$(echo $io1 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$(awk 'BEGIN{print '$ioraw1' * 1024}')
|
||||
@@ -136,42 +137,40 @@ StartIOTest() {
|
||||
ioraw3=$(echo $io3 | awk 'NR==1 {print $1}')
|
||||
[ "$(echo $io3 | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$(awk 'BEGIN{print '$ioraw3' * 1024}')
|
||||
ioall=$(awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}')
|
||||
ioavg=$(awk 'BEGIN{printf "%.1f", '$ioall' / 3}')
|
||||
log "I/O Speed(average) : $ioavg MB/s)"
|
||||
io_avg=$(awk 'BEGIN{printf "%.1f", '$ioall' / 3}')
|
||||
log "I/O Speed(average) : $io_avg MB/s)"
|
||||
else
|
||||
echo " $(_red "Not enough space for I/O Speed test!")"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
GetAgentLatestVersion() {
|
||||
|
||||
ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f3- | cut -d"." -f1
|
||||
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# cpuName
|
||||
# cpu_name
|
||||
# sys_manu
|
||||
# sys_product
|
||||
# sys_ver
|
||||
# virt
|
||||
# virtualx
|
||||
# virtual_x
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
Check_Virtualization() {
|
||||
check_virtualization() {
|
||||
|
||||
log "start to check host virtualization !"
|
||||
FunctionStart "开始收集服务器虚拟化信息!"
|
||||
|
||||
local virtual_x
|
||||
if command_exists "dmesg"; then
|
||||
virtual_x="$(dmesg 2>/dev/null)"
|
||||
fi
|
||||
|
||||
local sys_manu
|
||||
local sys_product
|
||||
local sys_ver
|
||||
|
||||
command_exists "dmesg" && virtualx="$(dmesg 2>/dev/null)"
|
||||
if command_exists "dmidecode"; then
|
||||
sys_manu="$(dmidecode -s system-manufacturer 2>/dev/null)"
|
||||
sys_product="$(dmidecode -s system-product-name 2>/dev/null)"
|
||||
@@ -189,21 +188,21 @@ Check_Virtualization() {
|
||||
virt="LXC"
|
||||
elif [[ -f /proc/user_beancounters ]]; then
|
||||
virt="OpenVZ"
|
||||
elif [[ ${virtualx} == *kvm-clock* ]]; then
|
||||
elif [[ ${virtual_x} == *kvm-clock* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${sys_product} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${cpuName} == *KVM* ]]; then
|
||||
elif [[ ${cpu_name} == *KVM* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${cpuName} == *QEMU* ]]; then
|
||||
elif [[ ${cpu_name} == *QEMU* ]]; then
|
||||
virt="KVM"
|
||||
elif [[ ${virtualx} == *"VMware Virtual Platform"* ]]; then
|
||||
elif [[ ${virtual_x} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ ${sys_product} == *"VMware Virtual Platform"* ]]; then
|
||||
virt="VMware"
|
||||
elif [[ ${virtualx} == *"Parallels Software International"* ]]; then
|
||||
elif [[ ${virtual_x} == *"Parallels Software International"* ]]; then
|
||||
virt="Parallels"
|
||||
elif [[ ${virtualx} == *VirtualBox* ]]; then
|
||||
elif [[ ${virtual_x} == *VirtualBox* ]]; then
|
||||
virt="VirtualBox"
|
||||
elif [[ -e /proc/xen ]]; then
|
||||
if grep -q "control_d" "/proc/xen/capabilities" 2>/dev/null; then
|
||||
@@ -225,14 +224,28 @@ Check_Virtualization() {
|
||||
virt="Dedicated"
|
||||
fi
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
GetManagePort(){
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# manage_port
|
||||
# tmp_manage_ports
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
get_manage_port() {
|
||||
|
||||
tmpManagePorts=$(netstat -ntulp | grep sshd | grep -w tcp | grep -v "127.0.0.1"| awk '{print$4}' | cut -d":" -f2)
|
||||
FunctionStart "开始收集服务器 管理端口 信息!"
|
||||
local tmp_manage_ports
|
||||
tmp_manage_ports=$(netstat -ntulp | grep sshd | grep -w tcp | grep -v "127.0.0.1" | awk '{print$4}' | cut -d":" -f2)
|
||||
|
||||
managePort=$(echo $tmpManagePorts | tr '\n' ' ')
|
||||
manage_port=$(echo "$tmp_manage_ports" | tr '\n' ' ')
|
||||
|
||||
log "manage Port is => $managePort"
|
||||
log "manage Port is => $manage_port"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
|
||||
@@ -247,9 +260,9 @@ GetManagePort(){
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
GetIpv4Info() {
|
||||
get_ipv4_info() {
|
||||
|
||||
log "start to get system public ip info !"
|
||||
FunctionStart "开始收集服务器IP信息!"
|
||||
|
||||
# public ip info
|
||||
org="$(wget -q -T10 -O- ipinfo.io/org)"
|
||||
@@ -259,148 +272,254 @@ GetIpv4Info() {
|
||||
public_ipv4="$(wget -q -T10 -O- ipinfo.io/ip)"
|
||||
public_ipv6="$(curl -q --max-time 5 -6 https://ifconfig.co/ip)"
|
||||
|
||||
if [ -z "$public_ipv4" ] ; then
|
||||
if [ -z "$public_ipv4" ]; then
|
||||
public_ipv4=" "
|
||||
fi
|
||||
|
||||
if [ -z "$public_ipv6" ] ; then
|
||||
if [ -z "$public_ipv6" ]; then
|
||||
public_ipv6=" "
|
||||
fi
|
||||
|
||||
# inner ipinfo
|
||||
export interface_prefix=("[[:space:]]eth[0-9]{1,2}" "[[:space:]]ens[0-9]{1,3}" "[[:space:]]eno[0-9]{1,3}" "[[:space:]]enp[0-9]{1,2}")
|
||||
export real_interface="eth90"
|
||||
local interface_prefix=("[[:space:]]eth[0-9]{1,2}" "[[:space:]]ens[0-9]{1,3}" "[[:space:]]eno[0-9]{1,3}" "[[:space:]]enp[0-9]{1,2}")
|
||||
local real_interface="eth90"
|
||||
|
||||
local interface
|
||||
for interface in "${interface_prefix[@]}"; do
|
||||
echo $(ip link show) | grep -oE ${interface} | head -1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
real_interface=$(echo $(ip link show) | grep -oE ${interface} | head -1 | cut -d" " -f2)
|
||||
if ip link show | grep -oE "${interface}" | head -1; then
|
||||
real_interface=$(ip link show | grep -oE "${interface}" | head -1 | cut -d" " -f2)
|
||||
echo "当前主机的真实内网网卡为 => [$real_interface]"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# 提取IPv4地址(CIDR格式)
|
||||
ipv4_regex="inet[[:space:]](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[0-9]{1,2}"
|
||||
local ipv4_regex="inet[[:space:]](25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[0-9]{1,2}"
|
||||
|
||||
# 提取IPv6地址(CIDR格式)
|
||||
ipv6_regex="inet6[[:space:]]([0-9a-fA-F]{0,4}(:[0-9a-fA-F]{0,4}){1,7})\/[0-9]{1,3}"
|
||||
local ipv6_regex="inet6[[:space:]]([0-9a-fA-F]{0,4}(:[0-9a-fA-F]{0,4}){1,7})\/[0-9]{1,3}"
|
||||
|
||||
# 查找IPv4地址
|
||||
inner_ipv4=$(echo $(ip addr show $real_interface) | grep -oE $ipv4_regex | cut -d" " -f2)
|
||||
inner_ipv4=$(ip addr show "$real_interface" | grep -oE "$ipv4_regex" | cut -d" " -f2)
|
||||
echo "Interface: $real_interface, IPv4 Address: $inner_ipv4"
|
||||
|
||||
# 查找IPv6地址
|
||||
inner_ipv6=$(echo $(ip addr show $real_interface) | grep -oE $ipv6_regex | cut -d" " -f2)
|
||||
inner_ipv6=$(ip addr show "$real_interface" | grep -oE "$ipv6_regex" | cut -d" " -f2)
|
||||
echo "Interface: $real_interface, IPv4 Address: $inner_ipv6"
|
||||
|
||||
FunctionEnd
|
||||
|
||||
}
|
||||
|
||||
log "start to collect system info !"
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# LANG
|
||||
# arch
|
||||
# c_cache
|
||||
# cores
|
||||
# cpu_aes
|
||||
# cpu_name
|
||||
# cpu_virt
|
||||
# disk_total_size
|
||||
# disk_used_size
|
||||
# freq
|
||||
# kern
|
||||
# lbit
|
||||
# load
|
||||
# opsy
|
||||
# swap
|
||||
# tcp_ctrl
|
||||
# tram
|
||||
# unused_ram
|
||||
# unused_swap
|
||||
# up
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
collect_system_info() {
|
||||
FunctionStart "开始收集系统信息!"
|
||||
|
||||
check_sys
|
||||
check_sys
|
||||
|
||||
cpuName=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cores=$(awk -F: '/processor/ {core++} END {print core}' /proc/cpuinfo)
|
||||
freq=$(awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo)
|
||||
ccache=$(awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cpu_aes=$(grep -i 'aes' /proc/cpuinfo)
|
||||
cpu_virt=$(grep -Ei 'vmx|svm' /proc/cpuinfo)
|
||||
tram=$(
|
||||
LANG=C
|
||||
free | awk '/Mem/ {print $2}'
|
||||
)
|
||||
tram=$(calc_size $tram)
|
||||
uram=$(
|
||||
LANG=C
|
||||
free | awk '/Mem/ {print $3}'
|
||||
)
|
||||
uram=$(calc_size $uram)
|
||||
swap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $2}'
|
||||
)
|
||||
swap=$(calc_size $swap)
|
||||
uswap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $3}'
|
||||
)
|
||||
uswap=$(calc_size $uswap)
|
||||
up=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime)
|
||||
if command_exists "w"; then
|
||||
load=$(
|
||||
cpu_name=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cores=$(awk -F: '/processor/ {core++} END {print core}' /proc/cpuinfo)
|
||||
freq=$(awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo)
|
||||
local c_cache
|
||||
local cpu_aes
|
||||
local cpu_virt
|
||||
c_cache=$(awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
cpu_aes=$(grep -i 'aes' /proc/cpuinfo)
|
||||
cpu_virt=$(grep -Ei 'vmx|svm' /proc/cpuinfo)
|
||||
tram=$(
|
||||
LANG=C
|
||||
w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
free | awk '/Mem/ {print $2}'
|
||||
)
|
||||
elif command_exists "uptime"; then
|
||||
load=$(
|
||||
tram=$(calc_size "$tram")
|
||||
local unused_ram
|
||||
unused_ram=$(
|
||||
LANG=C
|
||||
uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
free | awk '/Mem/ {print $3}'
|
||||
)
|
||||
fi
|
||||
opsy=$(GethostArchInfo)
|
||||
arch=$(uname -m)
|
||||
if command_exists "getconf"; then
|
||||
lbit=$(getconf LONG_BIT)
|
||||
else
|
||||
echo ${arch} | grep -q "64" && lbit="64" || lbit="32"
|
||||
fi
|
||||
kern=$(uname -r)
|
||||
disk_total_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }'
|
||||
)
|
||||
disk_total_size=$(calc_size $disk_total_size)
|
||||
disk_used_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $3 }'
|
||||
)
|
||||
disk_used_size=$(calc_size $disk_used_size)
|
||||
tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
|
||||
unused_ram=$(calc_size "$unused_ram")
|
||||
local swap
|
||||
swap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $2}'
|
||||
)
|
||||
swap=$(calc_size "$swap")
|
||||
local unused_swap
|
||||
unused_swap=$(
|
||||
LANG=C
|
||||
free | awk '/Swap/ {print $3}'
|
||||
)
|
||||
unused_swap=$(calc_size "$unused_swap")
|
||||
local up
|
||||
up=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime)
|
||||
local load
|
||||
if command_exists "w"; then
|
||||
load=$(
|
||||
LANG=C
|
||||
w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
)
|
||||
elif command_exists "uptime"; then
|
||||
load=$(
|
||||
LANG=C
|
||||
uptime | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'
|
||||
)
|
||||
fi
|
||||
opsy=$(get_host_arch_info)
|
||||
arch=$(uname -m)
|
||||
local l_bit
|
||||
if command_exists "getconf"; then
|
||||
l_bit=$(getconf LONG_BIT)
|
||||
else
|
||||
echo "${arch}" | grep -q "64" && l_bit="64" || l_bit="32"
|
||||
fi
|
||||
kern=$(uname -r)
|
||||
disk_total_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }'
|
||||
)
|
||||
disk_total_size=$(calc_size "$disk_total_size")
|
||||
disk_used_size=$(
|
||||
LANG=C
|
||||
df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $3 }'
|
||||
)
|
||||
disk_used_size=$(calc_size "$disk_used_size")
|
||||
tcp_ctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
|
||||
|
||||
# todo
|
||||
# StartIOTest
|
||||
local machine_number=""
|
||||
if [[ $(cut -d"-" -f 3 </etc/hostname | grep -c '^[0-9][0-9]') -gt 0 ]]; then
|
||||
machine_number=$(cut -d"-" -f 3 </etc/hostname)
|
||||
else
|
||||
machine_number=99
|
||||
fi
|
||||
|
||||
GetManagePort
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
GetIpv4Info
|
||||
#######################################
|
||||
# description
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
|
||||
Check_Virtualization
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# agent_version
|
||||
# octopus_agent_path
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
get_agent_version() {
|
||||
FunctionStart "获取Agent的版本信息"
|
||||
|
||||
machineNumber=""
|
||||
local file
|
||||
for file in ${octopus_agent_path}; do
|
||||
if grep -q "octopus-agent_" <"${file}"; then
|
||||
agent_version=$(cut -d "_" -f4- <"${file}")
|
||||
log "获取到的Agent版本信息为 => ${agent_version}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $(cat /etc/hostname | cut -d"-" -f 3 | grep -c '^[0-9][0-9]') -gt 0 ]]; then
|
||||
machineNumber=$(cat /etc/hostname | cut -d"-" -f 3)
|
||||
else
|
||||
machineNumber=99
|
||||
fi
|
||||
agentServerInfoFile="/octopus-agent/octopus-agent.conf"
|
||||
FunctionEnd
|
||||
}
|
||||
|
||||
#cat >/etc/environment.d/octopus-agent.conf <<EOF
|
||||
touch $ageagentServerInfoFile
|
||||
cat >"$agentServerInfoFile"<<EOF
|
||||
serverName: ${city}-${hostArch}-${machineNumber}
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
# agent_server_info_file
|
||||
# arch
|
||||
# city
|
||||
# cores
|
||||
# country
|
||||
# cpu_name
|
||||
# disk_total_size
|
||||
# disk_used_size
|
||||
# freq
|
||||
# host_arch
|
||||
# inner_ipv4
|
||||
# inner_ipv6
|
||||
# io_avg
|
||||
# kern
|
||||
# lbit
|
||||
# machine_number
|
||||
# manage_port
|
||||
# opsy
|
||||
# org
|
||||
# public_ipv4
|
||||
# public_ipv6
|
||||
# region
|
||||
# tcp_ctrl
|
||||
# tram
|
||||
# virt
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
main() {
|
||||
# todo
|
||||
# start_iotest
|
||||
|
||||
get_manage_port
|
||||
|
||||
collect_system_info
|
||||
|
||||
get_ipv4_info
|
||||
|
||||
check_virtualization
|
||||
|
||||
get_agent_version
|
||||
|
||||
local agent_server_info_file="/octopus-agent/octopus-agent.conf"
|
||||
touch "$agent_server_info_file"
|
||||
cat >"$agent_server_info_file" <<EOF
|
||||
serverName: ${city}-${host_arch}-${machine_number}
|
||||
serverIpPbV4: $public_ipv4
|
||||
serverIpInV4: $inner_ipv4
|
||||
serverIpPbV6: $public_ipv6
|
||||
serverIpInV6: $inner_ipv6
|
||||
location: "$city $region $country"
|
||||
provider: $org
|
||||
managePort: $managePort
|
||||
managePort: $manage_port
|
||||
cpuCore: "$cores @ $freq MHz"
|
||||
cpuBrand: "$cpuName"
|
||||
cpuBrand: "$cpu_name"
|
||||
memoryTotal: $tram
|
||||
diskTotal: $disk_total_size
|
||||
diskUsage: $disk_used_size
|
||||
archInfo: "$arch ($lbit Bit)"
|
||||
archInfo: "$arch ($l_bit Bit)"
|
||||
osInfo: "$opsy"
|
||||
osKernelInfo: $kern
|
||||
tcpControl: $tcpctrl
|
||||
tcpControl: $tcp_ctrl
|
||||
virtualization: $virt
|
||||
ioSpeed: "$ioavg MB/s"
|
||||
ioSpeed: "$io_avg MB/s"
|
||||
machineId: $(cat /etc/machine-id)
|
||||
agentVersion: $(ls /octopus-agent | grep "octopus-agent_" | cut -d "_" -f4-)
|
||||
agentVersion: ${agent_version}
|
||||
EOF
|
||||
|
||||
log "agent server info has collect complete!"
|
||||
log "file is => $agentServerInfoFile"
|
||||
log "agent server info has collect complete!"
|
||||
log "file is => $agent_server_info_file"
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
Reference in New Issue
Block a user