[CP] add telemetry in rpm install and systemd deploy
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -293,6 +293,7 @@ tools/rpm/systemd/profile/oceanbase-service.sh
|
|||||||
tools/rpm/systemd/profile/post_install.sh
|
tools/rpm/systemd/profile/post_install.sh
|
||||||
tools/rpm/systemd/profile/pre_uninstall.sh
|
tools/rpm/systemd/profile/pre_uninstall.sh
|
||||||
tools/rpm/systemd/profile/post_uninstall.sh
|
tools/rpm/systemd/profile/post_uninstall.sh
|
||||||
|
tools/rpm/systemd/profile/telemetry.sh
|
||||||
|
|
||||||
############# unittest #############
|
############# unittest #############
|
||||||
unittest/**/test_*
|
unittest/**/test_*
|
||||||
|
@ -195,6 +195,7 @@
|
|||||||
https://github.com/lz4/lz4
|
https://github.com/lz4/lz4
|
||||||
https://www.contributor-covenant.org/*
|
https://www.contributor-covenant.org/*
|
||||||
https://github.com/oceanbase/*
|
https://github.com/oceanbase/*
|
||||||
|
https://openwebapi.oceanbase.com*
|
||||||
**/Doxyfile
|
**/Doxyfile
|
||||||
www.doxygen.org)
|
www.doxygen.org)
|
||||||
https://www.gnu.org/software/libiconv/
|
https://www.gnu.org/software/libiconv/
|
||||||
|
@ -67,6 +67,9 @@ if (OB_BUILD_OPENSOURCE)
|
|||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh.template
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh.template
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh
|
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh
|
||||||
@ONLY)
|
@ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh.template
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh
|
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh
|
||||||
@ -140,6 +143,7 @@ install(FILES
|
|||||||
tools/rpm/systemd/profile/post_install.sh
|
tools/rpm/systemd/profile/post_install.sh
|
||||||
tools/rpm/systemd/profile/post_uninstall.sh
|
tools/rpm/systemd/profile/post_uninstall.sh
|
||||||
tools/rpm/systemd/profile/pre_uninstall.sh
|
tools/rpm/systemd/profile/pre_uninstall.sh
|
||||||
|
tools/rpm/systemd/profile/telemetry.sh
|
||||||
DESTINATION profile
|
DESTINATION profile
|
||||||
COMPONENT server)
|
COMPONENT server)
|
||||||
endif()
|
endif()
|
||||||
|
@ -7,6 +7,7 @@ url="http://$ip:$port"
|
|||||||
unix_socket="/tmp/obshell/$port.sock"
|
unix_socket="/tmp/obshell/$port.sock"
|
||||||
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
|
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
|
||||||
obshell="$prefix/bin/obshell"
|
obshell="$prefix/bin/obshell"
|
||||||
|
report=3
|
||||||
|
|
||||||
function prepare_config_json {
|
function prepare_config_json {
|
||||||
cnf_file='/etc/oceanbase.cnf'
|
cnf_file='/etc/oceanbase.cnf'
|
||||||
@ -190,6 +191,9 @@ function start_observer {
|
|||||||
fi
|
fi
|
||||||
trace=$(echo "$response" | jq -r '.data.id')
|
trace=$(echo "$response" | jq -r '.data.id')
|
||||||
check_trace $trace "start observer" 20 6
|
check_trace $trace "start observer" 20 6
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
/bin/bash $prefix/profile/telemetry.sh $report "12"
|
||||||
|
fi
|
||||||
elif [ "x$identity" = "xSINGLE" ]; then
|
elif [ "x$identity" = "xSINGLE" ]; then
|
||||||
# do config observer first
|
# do config observer first
|
||||||
do_config_observer
|
do_config_observer
|
||||||
@ -202,6 +206,9 @@ function start_observer {
|
|||||||
fi
|
fi
|
||||||
trace=$(echo "$response" | jq -r '.data.id')
|
trace=$(echo "$response" | jq -r '.data.id')
|
||||||
check_trace $trace "start observer" 40 6
|
check_trace $trace "start observer" 40 6
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
/bin/bash $prefix/profile/telemetry.sh $report "11"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# status is UNIDENTIFIED
|
# status is UNIDENTIFIED
|
||||||
echo "The observer has been installed before"
|
echo "The observer has been installed before"
|
||||||
@ -270,6 +277,8 @@ function reload_observer {
|
|||||||
|
|
||||||
if [ "x$1" = "xstart" ]; then
|
if [ "x$1" = "xstart" ]; then
|
||||||
echo "oceanbase service started at ${DATE}"
|
echo "oceanbase service started at ${DATE}"
|
||||||
|
# telemetry
|
||||||
|
/bin/bash $prefix/profile/telemetry.sh $report "10"
|
||||||
if check_daemon_process; then
|
if check_daemon_process; then
|
||||||
echo "The agent service is exist"
|
echo "The agent service is exist"
|
||||||
else
|
else
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
mysqlPort=2881
|
mysqlPort=2881
|
||||||
|
rpcPort=2882
|
||||||
rootPwd=""
|
rootPwd=""
|
||||||
redoDir=/var/lib/oceanbase/redo
|
redoDir=/var/lib/oceanbase/redo
|
||||||
dataDir=/var/lib/oceanbase/data
|
dataDir=/var/lib/oceanbase/data
|
||||||
datafile_size=2G
|
datafile_size=2G
|
||||||
|
datafile_next=2G
|
||||||
|
datafile_maxsize=20G
|
||||||
cpu_count=16
|
cpu_count=16
|
||||||
memory_limit=6G
|
memory_limit=6G
|
||||||
system_memory=1G
|
system_memory=1G
|
||||||
log_disk_size=13G
|
log_disk_size=13G
|
||||||
|
enable_syslog_wf=false
|
||||||
|
enable_syslog_recycle=true
|
||||||
|
max_syslog_file_count=4
|
||||||
|
__min_full_resource_pool_memory=1073741824
|
@ -10,5 +10,5 @@ chmod +x $prefix/profile/oceanbase-service.sh
|
|||||||
cp -f $prefix/profile/oceanbase.cnf /etc/oceanbase.cnf
|
cp -f $prefix/profile/oceanbase.cnf /etc/oceanbase.cnf
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# deploy local observer
|
# telemetry
|
||||||
/bin/bash $prefix/profile/oceanbase-service.sh deploy
|
/bin/bash $prefix/profile/telemetry.sh $1
|
@ -9,3 +9,6 @@ systemctl disable oceanbase
|
|||||||
/bin/bash $prefix/profile/oceanbase-service.sh destroy
|
/bin/bash $prefix/profile/oceanbase-service.sh destroy
|
||||||
rm -f /etc/systemd/system/oceanbase.service /etc/oceanbase.cnf
|
rm -f /etc/systemd/system/oceanbase.service /etc/oceanbase.cnf
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# telemetry
|
||||||
|
/bin/bash $prefix/profile/telemetry.sh $1
|
80
tools/rpm/systemd/profile/telemetry.sh.template
Normal file
80
tools/rpm/systemd/profile/telemetry.sh.template
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
url="https://openwebapi.oceanbase.com/api/web/oceanbase/report"
|
||||||
|
type=@CPACK_PACKAGE_NAME@
|
||||||
|
version=@CPACK_PACKAGE_VERSION@
|
||||||
|
release=@CPACK_RPM_PACKAGE_RELEASE@
|
||||||
|
ip=($hostname -i)
|
||||||
|
hostHash=$(echo -n "$ip" | sha1sum | awk '{print $1}')
|
||||||
|
cnf_file='/etc/oceanbase.cnf'
|
||||||
|
|
||||||
|
step='none'
|
||||||
|
reporter='none'
|
||||||
|
|
||||||
|
jsonData=$(jq -n --arg reporter "$reporter" \
|
||||||
|
--arg type "$type" \
|
||||||
|
--arg step "$step" \
|
||||||
|
--arg version "$version" \
|
||||||
|
--arg release "$revision" \
|
||||||
|
--arg hostHash "$hostHash" '{
|
||||||
|
component: "ocs",
|
||||||
|
content: {
|
||||||
|
reporter: $reporter,
|
||||||
|
type: $type,
|
||||||
|
step: $step,
|
||||||
|
version: $version,
|
||||||
|
release: $release,
|
||||||
|
hostHash: $hostHash,
|
||||||
|
observerConfig: {}
|
||||||
|
}
|
||||||
|
}')
|
||||||
|
|
||||||
|
function add_observer_config {
|
||||||
|
while IFS='=' read -r key value; do
|
||||||
|
key=$(echo "$key" | awk '{$1=$1};1')
|
||||||
|
value=$(echo "$value" | awk '{$1=$1};1')
|
||||||
|
value=$(echo "$value" | sed 's/^"//' | sed 's/"$//')
|
||||||
|
if [[ -n "$key" && ! "$key" =~ ^\; && $key != *"rootPwd"* ]]; then
|
||||||
|
jsonData=$(echo "$jsonData" | jq --arg parent "content" --arg child "observerConfig" --arg key "$key" --arg value "$value" '.[$parent][$child][$key] = $value')
|
||||||
|
fi
|
||||||
|
done < "$cnf_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function Name: do_telemetry
|
||||||
|
# Purpose: prepare the telemetry json data
|
||||||
|
# Arguments: arg1 - 0 means rpm uninstall, 1 means rpm install, 2 means rpm upgrade, 3 means systemd deploy
|
||||||
|
# Arguments: arg2 - systemd step: 10 means only start, 11 means start successfully with bootstrap,
|
||||||
|
# 12 means start successfully without bootstrap
|
||||||
|
# Return Value: None
|
||||||
|
function do_telemetry {
|
||||||
|
# arg1 0 means rpm uninstall, 1 means rpm install, 2 means rpm upgrade, 3 means systemd deploy
|
||||||
|
# arg2 means systemd step
|
||||||
|
if [ "$1" -eq 0 ]; then
|
||||||
|
# rpm uninstall step
|
||||||
|
step="0"
|
||||||
|
reporter="rpm"
|
||||||
|
elif [ "$1" -eq 1 ]; then
|
||||||
|
# rpm install step
|
||||||
|
step="1"
|
||||||
|
reporter="rpm"
|
||||||
|
elif [ "$1" -eq 2 ]; then
|
||||||
|
# rpm upgrade step
|
||||||
|
step="2"
|
||||||
|
reporter="rpm"
|
||||||
|
add_observer_config
|
||||||
|
elif [ "$1" -eq 3 ]; then
|
||||||
|
step="$2"
|
||||||
|
reporter="systemd"
|
||||||
|
add_observer_config
|
||||||
|
fi
|
||||||
|
jsonData=$(echo "$jsonData" | jq --arg parent "content" --arg key "reporter" --arg value "$reporter" '.[$parent][$key] = $value')
|
||||||
|
jsonData=$(echo "$jsonData" | jq --arg parent "content" --arg key "step" --arg value "$step" '.[$parent][$key] = $value')
|
||||||
|
|
||||||
|
nohup curl -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$jsonData" "$url" >/dev/null 2>&1 &
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "$TELEMETRY_MODE" ]] || ( [[ "$TELEMETRY_MODE" =~ ^-?[0-9]+$ ]] && [[ "$TELEMETRY_MODE" -eq 1 ]] ); then
|
||||||
|
do_telemetry $1 "$2"
|
||||||
|
fi
|
Reference in New Issue
Block a user