This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3f3b4f78185 feature add health_check (#12325)
3f3b4f78185 is described below
commit 3f3b4f78185ccf4b163d603e7a4a317ef1aa0d89
Author: CloudWise-Lukemiao <[email protected]>
AuthorDate: Fri Apr 12 19:05:36 2024 +0800
feature add health_check (#12325)
---
.../src/assembly/resources/sbin/health_check.bat | 641 +++++++++++++++++++++
.../src/assembly/resources/sbin/health_check.sh | 388 +++++++++++++
2 files changed, 1029 insertions(+)
diff --git
a/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.bat
b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.bat
new file mode 100644
index 00000000000..0724c9f2ff3
--- /dev/null
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.bat
@@ -0,0 +1,641 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM
+
+@echo off
+setlocal enabledelayedexpansion
+
+:: Initialize the variable to hold the final ips string
+set "ips="
+set "ip="
+set "unreachable="
+set "allips="
+set "operate="
+set "newoperating="
+set "operating="
+:: Loop through all arguments passed to the script
+for %%a in (%*) do (
+ :: Check if the current argument is -ips, if so, skip it
+ if "%%a"=="-ips" (
+ set "processing=1"
+ ) else if defined processing (
+ :: Check if the argument contains only digits (port)
+ if "%%a"=="-o" (
+ set "operating=1"
+ ) else if defined operating (
+ set "operate=%%a"
+ set "operating="
+ ) else (
+ set "isPort=1"
+ for /F "delims=0123456789" %%i in ("%%a") do (
+ if not "%%i"=="" (
+ set "isPort=0"
+ set "ip=%%a"
+ )
+ )
+ :: Append IP and port to the ips string
+ if !isPort! equ 1 (
+ set "ips=!ips!,!ip!:%%a"
+ )
+ )
+ )
+
+ if "%%a"=="-o" (
+ set "newoperating=1"
+ ) else if defined newoperating (
+ set "operate=%%a"
+ set "newoperating="
+ if "%%a"=="-ips" (
+ set "newprocessing=1"
+ ) else if defined newprocessing (
+ set "isPort=1"
+ for /F "delims=0123456789" %%i in ("%%a") do (
+ if not "%%i"=="" (
+ set "isPort=0"
+ set "ip=%%a"
+ )
+ )
+ :: Append IP and port to the ips string
+ if !isPort! equ 1 (
+ set "ips=!ips!,!ip!:%%a"
+ )
+ )
+ )
+)
+
+set endpoints=!ips!
+set "preip="
+set "iplist="
+set "allpreip="
+
+PATH %PATH%;%JAVA_HOME%\bin\
+set "FULL_VERSION="
+set "MAJOR_VERSION="
+set "MINOR_VERSION="
+
+
+for /f tokens^=2-5^ delims^=.-_+^" %%j in ('java -fullversion 2^>^&1') do (
+ set "FULL_VERSION=%%j-%%k-%%l-%%m"
+ IF "%%j" == "1" (
+ set "MAJOR_VERSION=%%k"
+ set "MINOR_VERSION=%%l"
+ ) else (
+ set "MAJOR_VERSION=%%j"
+ set "MINOR_VERSION=%%k"
+ )
+)
+
+set JAVA_VERSION=%MAJOR_VERSION%
+
+if "%OS%" == "Windows_NT" setlocal
+
+pushd %~dp0..
+if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%cd%
+popd
+
+pushd %~dp0..
+if NOT DEFINED CONFIGNODE_HOME set CONFIGNODE_HOME=%cd%
+popd
+
+pushd %~dp0..
+if NOT DEFINED DATANODE_HOME set DATANODE_HOME=%cd%
+popd
+
+if defined operate (
+ if !operate! == all (
+ if not defined ips (
+ echo ips is requred
+ exit /b 1
+ )
+ call :local_jdk_check
+ call :local_mem_check
+ call :local_dirs_check
+ call :local_ports_check
+ call :remote_ports_check
+ call :system_settings_check
+ ) else if !operate! == local (
+ call :local_jdk_check
+ call :local_mem_check
+ call :local_dirs_check
+ call :local_ports_check
+ call :system_settings_check
+ ) else if !operate! == remote (
+ if not defined ips (
+ echo ips is requred
+ exit /b 1
+ )
+ call :remote_ports_check
+ )
+) else (
+ if not defined ips (
+ echo ips is requred
+ exit /b 1
+ )
+ call :local_jdk_check
+ call :local_mem_check
+ call :local_dirs_check
+ call :local_ports_check
+ call :remote_ports_check
+ call :system_settings_check
+)
+
+
+exit /b
+
+
+:local_jdk_check
+echo Check: Installation Environment(JDK)
+echo Requirement: JDK Version ^>=1.8
+echo Result: JDK Version %JAVA_VERSION%
+exit /b
+
+
+:local_mem_check
+@setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
+SET IOTDB_CONF=%IOTDB_HOME%\conf
+IF EXIST "%IOTDB_CONF%\datanode-env.bat" (
+ CALL "%IOTDB_CONF%\datanode-env.bat" > nul 2>&1
+) ELSE (
+ echo Can't find datanode-env.bat
+)
+
+set datanode_mem= %memory_size_in_mb%
+
+
+IF EXIST "%IOTDB_CONF%\confignode-env.bat" (
+ CALL "%IOTDB_CONF%\confignode-env.bat" > nul 2>&1
+) ELSE (
+ echo Can't find datanode-env.bat
+ )
+
+set confignode_mem= %memory_size_in_mb%
+
+set datanode_mem=%datanode_mem%
+set confignode_mem=%confignode_mem%
+
+set /A datanode_mem=!datanode_mem! / 1024
+set /A confignode_mem=!confignode_mem! / 1024
+echo Check: Installation Environment(Memory)
+echo Requirement: Allocate sufficient memory for IoTDB
+
+set "totalMemory="
+
+for /F "skip=1" %%i in ('wmic os get TotalVisibleMemorySize') do (
+ if not defined totalMemory (
+ set "totalMemory=%%i"
+ )
+
+)
+
+set /A totalMemory=!totalMemory!
+set /A totalMemory=totalMemory / 1024 / 1024
+if "%confignode_mem%" == "" (
+ if "%datanode_mem%" == "" (
+ echo Result: Total Memory %totalMemory% GB
+ ) else (
+ echo Result: Total Memory %totalMemory% GB, %datanode_mem%GB allocated
to IoTDB DataNode
+ )
+) else (
+ if "%datanode_mem%" == "" (
+ echo Result: Total Memory %totalMemory% GB, %confignode_mem%GB
allocated to IoTDB ConfigNode
+ ) else (
+ echo Result: Total Memory %totalMemory% GB, %confignode_mem%GB
allocated to IoTDB ConfigNode, %datanode_mem% GB allocated to IoTDB DataNode
+
+ )
+)
+endlocal
+exit /b
+
+:local_dirs_check
+
+setlocal enabledelayedexpansion
+set "properties_file=%IOTDB_HOME%\conf\iotdb-datanode.properties"
+for /f "usebackq tokens=1,* delims==" %%a in ("%properties_file%") do (
+ if "%%a"=="dn_data_dirs" (
+ set "dn_data_dirs=%%b"
+ ) else if "%%a"=="dn_consensus_dir" (
+ set "dn_consensus_dir=%%b"
+ ) else if "%%a"=="dn_system_dir" (
+ set "dn_system_dir=%%b"
+ ) else if "%%a"=="dn_wal_dirs" (
+ set "dn_wal_dirs=%%b"
+ ) else if "%%a"=="cn_system_dir" (
+ set "cn_system_dir=%%b"
+ ) else if "%%a"=="cn_consensus_dir" (
+ set "cn_consensus_dir=%%b"
+ ) else if "%%a"=="pipe_lib_dir" (
+ set "pipe_lib_dir=%%b"
+ ) else if "%%a"=="udf_lib_dir" (
+ set "udf_lib_dir=%%b"
+ ) else if "%%a"=="trigger_lib_dir" (
+ set "trigger_lib_dir=%%b"
+ )
+)
+
+IF "%dn_data_dirs%"=="" (
+ set "dn_data_dirs=%IOTDB_HOME%\data\datanode\data"
+)
+IF "%dn_consensus_dir%"=="" (
+ set "dn_consensus_dir=%IOTDB_HOME%\data\datanode\consensus"
+)
+
+IF "%dn_system_dir%"=="" (
+ set "dn_system_dir=%IOTDB_HOME%\data\datanode\system"
+)
+
+IF "%dn_wal_dirs%"=="" (
+ set "dn_wal_dirs=%IOTDB_HOME%\data\datanode\wal"
+)
+
+IF "%cn_system_dir%"=="" (
+ set "cn_system_dir=%IOTDB_HOME%\data\confignode\system"
+)
+
+IF "%cn_consensus_dir%"=="" (
+ set "cn_consensus_dir=%IOTDB_HOME%\data\confignode\consensus"
+)
+
+IF "%pipe_lib_dir%"=="" (
+ set "pipe_lib_dir=%IOTDB_HOME%\ext\pipe"
+)
+
+IF "%udf_lib_dir%"=="" (
+ set "udf_lib_dir=%IOTDB_HOME%\ext\udf"
+)
+
+IF "%trigger_lib_dir%"=="" (
+ set "trigger_lib_dir=%IOTDB_HOME%\ext\trigger"
+)
+
+set
"dirs=%dn_data_dirs%,%dn_consensus_dir%,%dn_system_dir%,%dn_wal_dirs%,%cn_system_dir%,%cn_consensus_dir%,%pipe_lib_dir%,%udf_lib_dir%,%trigger_lib_dir%"
+
+set "spacedirs=%dn_data_dirs% %dn_consensus_dir% %dn_system_dir% %dn_wal_dirs%
%cn_system_dir% %cn_consensus_dir% %pipe_lib_dir% %udf_lib_dir%
%trigger_lib_dir%"
+
+for %%a in (%spacedirs%) do (
+ set "string=%%a"
+ for %%b in ("!string:;=" "!") do (
+ set "subString=%%~b"
+ for %%c in ("!subString:,=" "!") do (
+
+ if not exist "%%c\" (
+ mkdir "%%c" > nul 2>&1
+ if errorlevel 1 (
+ if defined operation_dirs (
+ set operation_dirs=!operation_dirs!,%%c lacks
write permission
+ ) else (
+ set operation_dirs=%%c lacks write permission
+ )
+ ) else (
+ if defined operation_dirs (
+ set operation_dirs=!operation_dirs!,%%c has write
permission
+ ) else (
+ set operation_dirs=%%c has write permission
+ )
+ )
+ ) else (
+ echo test > "%%c\tempfile.txt"
+ if errorlevel 1 (
+ if defined operation_dirs (
+ set operation_dirs=!operation_dirs!,%%c
lacks write permission
+ ) else (
+ set operation_dirs=%%c lacks write
permission
+ )
+ ) else (
+ if defined operation_dirs (
+ set operation_dirs=!operation_dirs!,%%c
has write permission
+ ) else (
+ set operation_dirs=%%c has write permission
+ )
+ del "%%c\tempfile.txt" >nul 2>&1
+ )
+ )
+ )
+ )
+)
+
+echo Check: Installation Environment(Directory Access)
+echo Requirement: IoTDB needs %dirs% write permission
+
+if defined operation_dirs (
+ echo Result:
+ for %%s in ("%operation_dirs:,=" "%") do (
+ echo %%~s
+ )
+) else (
+ echo Directory not found
+)
+exit /b
+
+:local_ports_check
+IF EXIST "%IOTDB_CONF%\iotdb-datanode.properties" (
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_rpc_port"
+ %IOTDB_CONF%\iotdb-datanode.properties') do (
+ set dn_rpc_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_internal_port"
+ %IOTDB_CONF%\iotdb-datanode.properties') do (
+ set dn_internal_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_mpp_data_exchange_port"
+ %IOTDB_CONF%\iotdb-datanode.properties') do (
+ set dn_mpp_data_exchange_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_schema_region_consensus_port"
+ %IOTDB_CONF%\iotdb-datanode.properties') do (
+ set dn_schema_region_consensus_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_data_region_consensus_port"
+ %IOTDB_CONF%\iotdb-datanode.properties') do (
+ set dn_data_region_consensus_port=%%i
+ )
+) ELSE IF EXIST "%IOTDB_HOME%\conf\iotdb-datanode.properties" (
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_rpc_port"
+ %IOTDB_HOME%\conf\iotdb-datanode.properties') do (
+ set dn_rpc_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^dn_internal_port"
+ %IOTDB_HOME%\conf\iotdb-datanode.properties') do (
+ set dn_internal_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_mpp_data_exchange_port"
+ %IOTDB_HOME%\conf\iotdb-datanode.properties') do (
+ set dn_mpp_data_exchange_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_schema_region_consensus_port"
+ %IOTDB_HOME%\conf\iotdb-datanode.properties') do (
+ set dn_schema_region_consensus_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i
"^dn_data_region_consensus_port"
+ %IOTDB_HOME%\conf\iotdb-datanode.properties') do (
+ set dn_data_region_consensus_port=%%i
+ )
+) ELSE (
+ set dn_rpc_port=6667
+ set dn_internal_port=10730
+ set dn_mpp_data_exchange_port=10740
+ set dn_schema_region_consensus_port=10750
+ set dn_data_region_consensus_port=10760
+)
+
+IF EXIST "%IOTDB_CONF%\iotdb-confignode.properties" (
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_internal_port"
+ %IOTDB_CONF%\iotdb-confignode.properties') do (
+ set cn_internal_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_consensus_port"
+ %IOTDB_CONF%\iotdb-confignode.properties') do (
+ set cn_consensus_port=%%i
+ )
+) ELSE IF EXIST "%IOTDB_HOME%\conf\iotdb-confignode.properties" (
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_internal_port"
+ %IOTDB_HOME%\conf\iotdb-confignode.properties') do (
+ set cn_internal_port=%%i
+ )
+ for /f "eol=# tokens=2 delims==" %%i in ('findstr /i "^cn_consensus_port"
+ %IOTDB_HOME%\conf\iotdb-confignode.properties') do (
+ set cn_consensus_port=%%i
+ )
+) ELSE (
+ set cn_internal_port=10710
+ set cn_consensus_port=10720
+)
+
+set "local_ports="
+set "local_other_occupied_ports="
+set "local_iotdb_occupied_ports="
+set "local_free_ports="
+set "operation_dirs="
+set dn_rpc_port_occupied=0
+set dn_internal_port_occupied=0
+set dn_mpp_data_exchange_port_occupied=0
+set dn_schema_region_consensus_port_occupied=0
+set dn_data_region_consensus_port_occupied=0
+set cn_internal_port_occupied=0
+set cn_consensus_port_occupied=0
+set local_ports=%dn_rpc_port% %dn_internal_port% %dn_mpp_data_exchange_port%
%dn_schema_region_consensus_port% %dn_data_region_consensus_port%
%cn_consensus_port% %cn_internal_port%
+for /f "tokens=1,3,7 delims=: " %%i in ('netstat /ano') do (
+ if %%i==TCP (
+ if %%j==%dn_rpc_port% (
+ if !dn_rpc_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%dn_rpc_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%dn_rpc_port%
!local_other_occupied_ports!
+ )
+ set dn_rpc_port_occupied=1
+ )
+ ) else if %%j==%dn_internal_port% (
+ if !dn_internal_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%dn_internal_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%dn_internal_port%
!local_other_occupied_ports!
+ )
+ set dn_internal_port_occupied=1
+ )
+ ) else if %%j==%dn_mpp_data_exchange_port% (
+ if !dn_mpp_data_exchange_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%dn_mpp_data_exchange_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%dn_mpp_data_exchange_port%
!local_other_occupied_ports!
+ )
+ set dn_mpp_data_exchange_port_occupied=1
+ )
+ ) else if %%j==%dn_schema_region_consensus_port% (
+ if !dn_schema_region_consensus_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%dn_schema_region_consensus_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%dn_schema_region_consensus_port%
!local_other_occupied_ports!
+ )
+ set dn_schema_region_consensus_port_occupied=1
+ )
+ ) else if %%j==%dn_data_region_consensus_port% (
+ if !dn_data_region_consensus_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%dn_data_region_consensus_port%
!local_iotdb_occupied_ports!
+
+ ) else (
+ set local_other_occupied_ports=%dn_data_region_consensus_port%
!local_other_occupied_ports!
+ )
+ set dn_data_region_consensus_port_occupied=1
+ )
+ ) else if %%j==%cn_internal_port% (
+ if !cn_internal_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%cn_internal_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%cn_internal_port%
!local_other_occupied_ports!
+ )
+ set cn_internal_port_occupied=1
+ )
+ ) else if %%j==%cn_consensus_port% (
+ if !cn_consensus_port_occupied!==0 (
+ set spid=%%k
+ call :checkIfIOTDBProcess !spid! is_iotdb
+ if !is_iotdb!==1 (
+ set local_iotdb_occupied_ports=%cn_consensus_port%
!local_iotdb_occupied_ports!
+ ) else (
+ set local_other_occupied_ports=%cn_consensus_port%
!local_other_occupied_ports!
+ )
+ set cn_consensus_port_occupied=1
+ )
+ )
+ )
+)
+
+if !dn_rpc_port_occupied!==0 (
+ set local_free_ports=%dn_rpc_port% !local_free_ports!
+)
+if !dn_internal_port_occupied!==0 (
+ set local_free_ports=%dn_internal_port% !local_free_ports!
+)
+if !dn_mpp_data_exchange_port_occupied!==0 (
+ set local_free_ports=%dn_mpp_data_exchange_port% !local_free_ports!
+)
+if !dn_schema_region_consensus_port_occupied!==0 (
+ set local_free_ports=%dn_schema_region_consensus_port% !local_free_ports!
+)
+if !dn_data_region_consensus_port_occupied!==0 (
+ set local_free_ports=%dn_data_region_consensus_port% !local_free_ports!
+)
+if !cn_internal_port_occupied!==0 (
+ set local_free_ports=%cn_internal_port% !local_free_ports!
+)
+if !cn_consensus_port_occupied!==0 (
+ set local_free_ports=%cn_consensus_port% !local_free_ports!
+)
+
+echo Check: Network(Local Port)
+echo Requirement: Port !local_ports! is not occupied
+echo Result:
+
+if defined local_other_occupied_ports (
+ echo Port !local_other_occupied_ports! occupied by other programs
+)
+
+if defined local_iotdb_occupied_ports (
+ echo Port !local_iotdb_occupied_ports! is occupied by IoTDB
+)
+
+if defined local_free_ports (
+ echo Port !local_free_ports! is free
+)
+exit /b
+
+:remote_ports_check
+for %%e in ("%endpoints:,=" "%") do (
+ set counter=0
+ for /f "tokens=1,2 delims=:" %%i in ("%%~e") do (
+ set "ip=%%i"
+ set "port=%%j"
+ if "!allpreip!" == "!ip!" (
+ set "iplist=!iplist! !port!"
+ ) else (
+ set allpreip=!ip!
+ if !counter! EQU 0 (
+ set /a counter+=1
+ if defined iplist (
+ set "iplist=!iplist!,!ip!:!port!"
+ ) else (
+ set "iplist=!ip!:!port!"
+ )
+ ) else (
+ set "iplist=!iplist!,!ip!:!port!"
+ )
+ )
+
+ for /f %%r in ('powershell -command "Test-NetConnection -ComputerName
!ip! -Port !port! -InformationLevel Quiet"') do (
+ set "result=%%r"
+ )
+ if /i "!result!" EQU "TRUE" (
+@REM echo Info: The !port! port on !ip! is reachable.
+ ) else (
+@REM echo Error: The !port! port on !ip! is unreachable.
+ if "!preip!" == "!ip!" (
+ set "unreachable=!unreachable!-!port!"
+ ) else (
+ set preip=!ip!
+ if "!unreachable!" == "" (
+ set "unreachable=IP:!ip!,Ports:!port!"
+ ) else (
+ set "unreachable=!unreachable!##IP:!ip!,Ports:!port!"
+ )
+ )
+ )
+ )
+)
+
+setlocal enabledelayedexpansion
+echo Check: Network(Remote Port Connectivity)
+echo Requirement: !iplist! need to be accessible
+echo Result:
+if defined unreachable (
+ echo The following server ports are not sure, please double check:
+ for %%a in ("%unreachable:##=" "%") do (
+ set "segment=%%~a"
+ set "segment=!segment:-= !"
+ echo !segment!
+ )
+ ) else (
+ echo All ports are accessible
+ )
+endlocal
+exit /b
+
+:system_settings_check
+echo Check: System Settings(Swap)
+echo Requirement: disabled
+for /f "skip=1" %%s in ('wmic pagefile list /format:list') do (
+ for /f "tokens=1,2 delims==" %%a in ("%%s") do (
+ if /i "%%a"=="AllocatedBaseSize" (
+ if "%%b"=="0" (
+ echo Result: disabled
+ ) else (
+ echo Result: enabled
+ )
+ )
+ )
+)
+exit /b
+
+:checkIfIOTDBProcess
+setlocal
+
+set "pid_to_check=%~1"
+set "is_iotdb=0"
+
+for /f "usebackq tokens=*" %%i in (`wmic process where
"ProcessId=%pid_to_check%" get CommandLine /format:list ^| findstr
/c:"CommandLine="`) do (
+ set command_line=%%i
+)
+echo %command_line% | findstr /i /c:"iotdb" >nul && set is_iotdb=1
+endlocal & set "is_iotdb=%is_iotdb%"
+exit /b
\ No newline at end of file
diff --git
a/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.sh
b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.sh
new file mode 100644
index 00000000000..e23c0d76c09
--- /dev/null
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.sh
@@ -0,0 +1,388 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+DATANODE="iotdb-datanode"
+CONFIGNODE="iotdb-confignode"
+
+if [ -z "${IOTDB_HOME}" ]; then
+ export IOTDB_HOME="`dirname "$0"`/.."
+fi
+
+source "${IOTDB_HOME}/sbin/iotdb-common.sh"
+
+HELP="Usage: $0 [-ips <ip1> <port1> <port2>,<ip2> <port3> <port4>] [-o
<all/local/remote>]"
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -ips)
+ shift
+ ips=$1
+ while [[ $# -gt 1 ]] && ! [[ ${2:0:1} == "-" ]]; do
+ shift
+ ips+="-${1}"
+ done
+ ;;
+ -o)
+ shift
+ operate=$1
+ ;;
+ *)
+ echo "Unrecognized options:$1"
+ echo "${HELP}"
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+ips="${ips//-/ }"
+ip_list=$ips
+
+
+if [ -z "$ip_list" ] ; then
+ if [ "$operate" = all ]; then
+ echo "Error: -ips is a required option."
+ exit 1
+ fi
+ if [ "$operate" = remote ]; then
+ echo "Error: -ips is a required option."
+ exit 1
+ fi
+ if [ -n "$operate" ]; then
+ :
+ else
+ echo "Error: -ips is a required option."
+ exit 1
+ fi
+fi
+
+if [ -n "$JAVA_HOME" ]; then
+ for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
+ if [ -x "$java" ]; then
+ JAVA="$java"
+ break
+ fi
+ done
+else
+ JAVA=java
+fi
+
+# Convert comma-separated lists to arrays
+IFS=',' read -ra ips <<< "$ip_list"
+
+# Check accessibility for each IP address and port combination
+for ip in "${ips[@]}"; do
+ IFS=' ' read -ra parts <<< "$ip"
+ ip="${parts[0]}"
+ ports="${parts[@]:1}"
+ for port in $ports; do
+ formatted_ips+=" $ip $port,"
+ done
+done
+formatted_ips=${formatted_ips%,}
+
+IFS=',' read -ra ips_ports <<< "$formatted_ips"
+
+unreachable_combinations=()
+listening_ports=()
+iotdb_listening_ports=()
+unlistening_ports=()
+ip_port_list=""
+
+remote_ports_check() {
+ #Check if the port of the remote server is reachable...
+
+ for ip in "${ips[@]}"; do
+ IFS=' ' read -ra parts <<< "$ip"
+ host="${parts[0]}"
+ ports="${parts[@]:1}"
+ unreachable_ports=""
+ all_ports=""
+ for port in $ports; do
+ nc -z -v -w 5 "$host" "$port" >/dev/null 2>&1
+ result=$?
+ all_ports+="$port "
+ if [ $result -eq 0 ]; then
+ :
+ else
+ nc_output=$(nc -zvw3 "$host" "$port" 2>&1)
+ if echo "$nc_output" | grep -q "Connection refused"; then
+ :
+ elif echo "$nc_output" | grep -q "timed out"; then
+ unreachable_ports+="$port "
+ else
+ echo "$nc_output"
+ unreachable_ports+="$port "
+ fi
+ fi
+ done
+ if [ -n "$unreachable_ports" ]; then
+ unreachable_combinations+=("IP: $host, Ports: $unreachable_ports")
+ fi
+ if [ -n "$ip_port_list" ]; then
+ ip_port_list="$ip_port_list,$host:$all_ports"
+ else
+ ip_port_list="$host:$all_ports"
+ fi
+ done
+ echo ""
+ echo "Check: Network(Remote Port Connectivity)"
+ echo "Requirement:" "$ip_port_list" "need to be accessible"
+ echo "Result: "
+ # Print the final conclusion of unreachable IP and port combinations
+ if [ ${#unreachable_combinations[@]} -gt 0 ]; then
+ echo "The following server ports are inaccessible:"
+ printf "%s\n" "${unreachable_combinations[@]}"
+ else
+ echo "All ports are accessible"
+ fi
+}
+
+# Function to get port value from properties file
+get_properties_value() {
+ local file_name=$1
+ local property_name=$2
+ local default_value=$3
+ local property_value=$(sed "/^${property_name}=/!d;s/.*=//"
"${IOTDB_HOME}/conf/${file_name}.properties")
+ if [ -z "$property_value" ]; then
+ property_value="$default_value"
+ fi
+ echo "$property_value"
+}
+
+local_ports_check() {
+ #Check if the local port is available....
+ dn_rpc_port=$(get_properties_value $DATANODE "dn_rpc_port" "6667")
+ dn_internal_port=$(get_properties_value $DATANODE "dn_internal_port" "10730")
+ dn_mpp_data_exchange_port=$(get_properties_value $DATANODE
"dn_mpp_data_exchange_port" "10740")
+ dn_schema_region_consensus_port=$(get_properties_value $DATANODE
"dn_schema_region_consensus_port" "10750")
+ dn_data_region_consensus_port=$(get_properties_value $DATANODE
"dn_data_region_consensus_port" "10760")
+
+ cn_internal_port=$(get_properties_value $CONFIGNODE "cn_internal_port"
"10710")
+ cn_consensus_port=$(get_properties_value $CONFIGNODE "cn_consensus_port"
"10720")
+
+ local_ports+=("$dn_rpc_port")
+ local_ports+=("$dn_internal_port")
+ local_ports+=("$dn_mpp_data_exchange_port")
+ local_ports+=("$dn_schema_region_consensus_port")
+ local_ports+=("$dn_data_region_consensus_port")
+ local_ports+=("$cn_internal_port")
+ local_ports+=("$cn_consensus_port")
+
+ for port in "${local_ports[@]}"; do
+ # Check if lsof command is available
+ if command -v lsof >/dev/null 2>&1; then
+ listening=$(lsof -i :$port -sTCP:LISTEN -P -n | grep LISTEN)
+ if [ -n "$listening" ]; then
+ process_command=$(echo "$listening" | awk '{print $2}')
+ iotdb_check=$(ps -p "$process_command" -o args= | grep "iotdb")
+ if [ -n "$iotdb_check" ]; then
+ iotdb_listening_ports+=("$port ")
+ else
+ listening_ports+=("$port ")
+ fi
+ else
+ unlistening_ports+=("$port ")
+ fi
+ elif command -v netstat >/dev/null 2>&1; then
+ listening=$(netstat -tln | awk '{print $4}' | grep ":$port$")
+ if [ -n "$listening" ]; then
+ process_command=$(echo "$listening" | awk '{print $2}')
+ iotdb_check=$(ps -p "$process_command" -o args= | grep "iotdb")
+ if [ -n "$iotdb_check" ]; then
+ iotdb_listening_ports+=("$port ")
+ else
+ listening_ports+=("$port ")
+ fi
+ else
+ unlistening_ports+=("$port ")
+ fi
+ else
+ echo "Error: Unable to detect port occupation. Please install 'lsof'
or 'netstat' command."
+ exit 1
+ fi
+ done
+ echo "Check: Network(Local Port)"
+ echo "Requirement: Port" "${local_ports[@]}" "is not occupied"
+ echo "Result: "
+ # Print the occupied ports
+ if [ ${#listening_ports[@]} -gt 0 ]; then
+ echo "Port" "${listening_ports[@]}" "occupied by other programs"
+ fi
+
+ if [ ${#iotdb_listening_ports[@]} -gt 0 ]; then
+ echo "Port" "${iotdb_listening_ports[@]}" "is occupied by IoTDB"
+ fi
+
+ if [ ${#unlistening_ports[@]} -gt 0 ]; then
+ echo "Port" "${unlistening_ports[@]}" "is free"
+ fi
+}
+
+local_dirs_check() {
+ # Check directory operation permissions...
+ dn_data_dirs=$(get_properties_value "iotdb-datanode" "dn_data_dirs"
"data/datanode/data")
+ dn_consensus_dir=$(get_properties_value "iotdb-datanode" "dn_consensus_dir"
"data/datanode/consensus")
+ dn_system_dir=$(get_properties_value "iotdb-datanode" "dn_consensus_dir"
"data/datanode/system")
+ dn_wal_dirs=$(get_properties_value "iotdb-datanode" "dn_wal_dirs"
"data/datanode/wal")
+
+ cn_system_dir=$(get_properties_value "iotdb-confignode" "cn_system_dir"
"data/confignode/system")
+ cn_consensus_dir=$(get_properties_value "iotdb-confignode"
"cn_consensus_dir" "data/confignode/consensus")
+
+ pipe_lib_dir=$(get_properties_value "iotdb-common" "pipe_lib_dir" "ext/pipe")
+ udf_lib_dir=$(get_properties_value "iotdb-common" "udf_lib_dir" "ext/udf")
+ trigger_lib_dir=$(get_properties_value "iotdb-common" "trigger_lib_dir"
"ext/trigger")
+
+
node_dirs_list=("$dn_data_dirs","$dn_consensus_dir","$dn_system_dir","$dn_wal_dirs","$cn_system_dir","$cn_consensus_dir","$pipe_lib_dir","$udf_lib_dir","$trigger_lib_dir")
+
+ # Check if the directories exist and are writable or readable
+ for node_dirs in "${node_dirs_list[@]}"; do
+ IFS=';' read -ra directory <<< "$node_dirs"
+ for subdirectory in "${directory[@]}"; do
+ IFS=',' read -ra directory <<< "$subdirectory"
+ for directory in "${directory[@]}"; do
+ if [[ "$directory" == /* ]]; then
+ full_directory="$directory"
+ else
+ full_directory="$IOTDB_HOME/$directory"
+ fi
+ if [ -d "$full_directory" ]; then
+ if [ -w "$full_directory" ] && [ -r "$full_directory" ]; then
+ operate_dirs+="$directory has write permission,"
+ else
+ operate_dirs+="$directory lacks write permission,"
+ fi
+ else
+ parent_directory="$full_directory"
+ while [ ! -w "$parent_directory" ] && [ "$parent_directory" != "/" ];
do
+ parent_directory=$(dirname "$parent_directory")
+ if [ -d "$parent_directory" ]; then
+ break
+ fi
+ done
+
+ if [ ! -w "$parent_directory" ] || [ ! -r "$parent_directory" ]; then
+ operate_dirs+="$directory lacks write permission,"
+ else
+ operate_dirs+="$directory has write permission,"
+ fi
+ fi
+ done
+ done
+ done
+ echo ""
+ echo "Check: Installation Environment(Directory Access)"
+ echo "Requirement: IoTDB needs" "${node_dirs_list[@]}" "write permission."
+
+ if [ -n "$operate_dirs" ]; then
+ echo "Result: "
+ echo "$operate_dirs" | tr ',' '\n'
+ else
+ echo "Result: Directory not found"
+ fi
+}
+
+local_jdk_check() {
+ echo "Check: Installation Environment(JDK)"
+ echo "Requirement: JDK Version >=1.8"
+
+ if [ -z $JAVA ] ; then
+ echo "Result: Unable to find java executable. Check JAVA_HOME and PATH
environment variables. "
+ else
+ # JDK Version
+ jdk_version=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
+ echo "Result: JDK Version $jdk_version"
+ fi
+}
+
+local_mem_check() {
+ echo ""
+ echo "Check: Installation Environment(Memory)"
+ echo "Requirement: Allocate sufficient memory for IoTDB"
+ # Mem info
+ source "${IOTDB_HOME}/conf/confignode-env.sh" >/dev/null 2>&1
+
+ total_memory=$(free -h | awk '/Mem:/ {print $2}')
+ confignode_memory=$(echo "scale=2; $memory_size_in_mb / 1024" | bc)
+
+ source "${IOTDB_HOME}/conf/datanode-env.sh" >/dev/null 2>&1
+ datanode_memory=$(echo "scale=2; $memory_size_in_mb / 1024" | bc)
+
+ if [ -n "$confignode_memory" ] && [ -n "$datanode_memory" ]; then
+ echo "Result: Total Memory ${total_memory}, ${confignode_memory} G
allocated to IoTDB ConfigNode, ${datanode_memory} G allocated to IoTDB DataNode"
+ elif [ -n "$confignode_memory" ]; then
+ echo "Result: Total Memory ${total_memory}, ${confignode_memory} G
allocated to IoTDB ConfigNode"
+ elif [ -n "$datanode_memory" ]; then
+ echo "Result: Total Memory ${total_memory}, ${datanode_memory} G allocated
to IoTDB DataNode"
+ else
+ echo "Result: Total Memory ${total_memory}."
+ fi
+}
+
+system_settings_check() {
+ echo ""
+ echo "Check: System Settings(Maximum Open Files Number)"
+ echo "Requirement: >= 65535"
+
+ # Get the maximum open file limit for the current user
+ ulimit_value=$(ulimit -n)
+ echo "Result: $ulimit_value"
+
+ echo ""
+ echo "Check: System Settings(Swap)"
+ echo "Requirement: disabled"
+ #Check if Swap is enabled
+ swap_status=$(swapon --show)
+ if [ -n "$swap_status" ]; then
+ echo "Result: enabled."
+ else
+ echo "Result: disabled."
+ fi
+}
+
+if [ -n "$operate" ]; then
+ if [ "$operate" == "local" ]; then
+ local_jdk_check
+ local_mem_check
+ local_dirs_check
+ local_ports_check
+ system_settings_check
+ elif [ "$operate" == "remote" ]; then
+ remote_ports_check
+ elif [ "$operate" == "all" ]; then
+ local_jdk_check
+ local_mem_check
+ local_dirs_check
+ local_ports_check
+ remote_ports_check
+ system_settings_check
+ else
+ echo "The parameter - o only has the value local/remote/all (default)"
+ exit 1
+ fi
+else
+ local_jdk_check
+ local_mem_check
+ local_dirs_check
+ local_ports_check
+ remote_ports_check
+ system_settings_check
+fi