Fix the issue of obtaining Windows directory permissions, fix the issue of allocating IoTDB memory for configuration, and add the -- help command (#12450)

Co-authored-by: luke.miao <282583553@qq.com>
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
index 0724c9f..f3df96a 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.bat
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.bat
@@ -76,6 +76,10 @@
             )
         )
     )
+    if "%%a"=="--help" (
+           echo Usage: health_check.bat [-ips ^<ip1^> ^<port1^> ^<port2^>,^<ip2^> ^<port3^> ^<port4^>] [-o ^<all/local/remote^>]
+           exit /b 1
+        )
 )
 
 set endpoints=!ips!
@@ -188,8 +192,14 @@
 set datanode_mem=%datanode_mem%
 set confignode_mem=%confignode_mem%
 
-set /A datanode_mem=!datanode_mem! / 1024
-set /A confignode_mem=!confignode_mem! / 1024
+set datanode_mem=%datanode_mem%
+set confignode_mem=%confignode_mem%
+
+for /f %%i in ('powershell.exe -Command "[math]::Round(%datanode_mem% / 1024, 2)"') do set datanode_mem=%%i
+for /f %%i in ('powershell.exe -Command "[math]::Round(%confignode_mem% / 1024, 2)"') do set confignode_mem=%%i
+
+echo datanode_mem=%datanode_mem%
+echo confignode_mem=%confignode_mem%
 echo Check: Installation Environment(Memory)
 echo Requirement: Allocate sufficient memory for IoTDB
 
@@ -291,7 +301,6 @@
     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 (
@@ -309,19 +318,20 @@
                     )
                 ) 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
-                                )
+                    if EXIST "%%c\tempfile.txt" (
+                        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
+
+                    ) else (
+                        if defined operation_dirs (
+                             set operation_dirs=!operation_dirs!,%%c lacks write permission
+                        ) else (
+                             set operation_dirs=%%c lacks write permission
+                        )
                     )
                 )
         )
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
index e23c0d7..19739024 100644
--- a/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.sh
+++ b/iotdb-core/node-commons/src/assembly/resources/sbin/health_check.sh
@@ -25,6 +25,11 @@
 if [ -z "${IOTDB_HOME}" ]; then
     export IOTDB_HOME="`dirname "$0"`/.."
 fi
+ulimit_value=""
+
+system_settings_pre_check(){
+  ulimit_value=$(ulimit -n)
+}
 
 source "${IOTDB_HOME}/sbin/iotdb-common.sh"
 
@@ -44,6 +49,10 @@
             shift
             operate=$1
             ;;
+        --help)
+            echo "${HELP}"
+            exit 1
+            ;;
         *)
             echo "Unrecognized options:$1"
             echo "${HELP}"
@@ -322,16 +331,16 @@
 
   total_memory=$(free -h | awk '/Mem:/ {print $2}')
   confignode_memory=$(echo "scale=2; $memory_size_in_mb / 1024" | bc)
-
+  confignode_memory_formatted=$(printf "%.2f" "$confignode_memory")
   source "${IOTDB_HOME}/conf/datanode-env.sh" >/dev/null 2>&1
   datanode_memory=$(echo "scale=2; $memory_size_in_mb / 1024" | bc)
-
+  datanode_memory_formatted=$(printf "%.2f" "$datanode_memory")
   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"
+    echo "Result: Total Memory ${total_memory}, ${confignode_memory_formatted} G allocated to IoTDB ConfigNode, ${datanode_memory_formatted} G allocated to IoTDB DataNode"
   elif [ -n "$confignode_memory" ]; then
-    echo "Result: Total Memory ${total_memory}, ${confignode_memory} G allocated to IoTDB ConfigNode"
+    echo "Result: Total Memory ${total_memory}, ${confignode_memory_formatted} G allocated to IoTDB ConfigNode"
   elif [ -n "$datanode_memory" ]; then
-    echo "Result: Total Memory ${total_memory}, ${datanode_memory} G allocated to IoTDB DataNode"
+    echo "Result: Total Memory ${total_memory}, ${datanode_memory_formatted} G allocated to IoTDB DataNode"
   else
     echo "Result: Total Memory ${total_memory}."
   fi
@@ -343,7 +352,7 @@
   echo "Requirement: >= 65535"
 
   # Get the maximum open file limit for the current user
-  ulimit_value=$(ulimit -n)
+
   echo "Result: $ulimit_value"
 
   echo ""
@@ -360,6 +369,7 @@
 
 if [ -n "$operate" ]; then
     if [ "$operate" == "local" ]; then
+        system_settings_pre_check
         local_jdk_check
         local_mem_check
         local_dirs_check
@@ -368,6 +378,7 @@
     elif [ "$operate" == "remote" ]; then
         remote_ports_check
     elif  [ "$operate" == "all" ]; then
+        system_settings_pre_check
         local_jdk_check
         local_mem_check
         local_dirs_check