Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
@REM

@echo off
@REM set cmd format
powershell -NoProfile -Command "$v=(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').CurrentMajorVersionNumber; if($v -gt 6) { cmd /c 'chcp 65001' }"


@REM You can put your env variable here
@REM set JAVA_HOME=%JAVA_HOME%
Expand Down
7 changes: 4 additions & 3 deletions iotdb-client/cli/src/assembly/resources/tools/backup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ 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
)
REM Ensure compatibility by avoiding wmic and using PowerShell if needed
REM No wmic usage detected in this script

for /f "delims=" %%i in ('powershell -NoProfile -Command "$v=$host.Version.Major; if($v -lt 3) {Get-WmiObject Win32_Process -Filter \"ProcessId='%pid_to_check%'\"} else {Get-CimInstance Win32_Process -Filter \"ProcessId='%pid_to_check%'\"}; $process.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if %JMX_LOCAL% == "false" (

set CONFIGNODE_JMX_OPTS=%CONFIGNODE_JMX_OPTS% -Diotdb.jmx.local=%JMX_LOCAL%

for /f %%b in ('wmic cpu get numberofcores ^| findstr "[0-9]"') do (
set system_cpu_cores=%%b
REM Replace wmic with PowerShell for CPU core count
for /f %%b in ('powershell -NoProfile -Command "$v=$host.Version.Major; if($v -lt 3) {(Get-WmiObject Win32_Processor).NumberOfCores} else {(Get-CimInstance -ClassName Win32_Processor).NumberOfCores}"') do (
set system_cpu_cores=%%b
)

if %system_cpu_cores% LSS 1 set system_cpu_cores=1

for /f %%b in ('wmic ComputerSystem get TotalPhysicalMemory ^| findstr "[0-9]"') do (
set system_memory=%%b
REM Replace wmic with PowerShell for total physical memory
for /f %%b in ('powershell -NoProfile -Command "$v=$host.Version.Major; $mem=if($v -lt 3){(Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory} else{(Get-CimInstance -ClassName Win32_ComputerSystem).TotalPhysicalMemory}; [math]::Round($mem/1048576)"') do (
set system_memory_in_mb=%%b
)

echo wsh.echo FormatNumber(cdbl(%system_memory%)/(1024*1024), 0) > "%CONFIGNODE_HOME%\sbin\tmp.vbs"
for /f "tokens=*" %%a in ('cscript //nologo "%CONFIGNODE_HOME%\sbin\tmp.vbs"') do set system_memory_in_mb=%%a
del "%CONFIGNODE_HOME%\sbin\tmp.vbs"
REM Remove VBScript usage for memory calculation
set system_memory_in_mb=%system_memory_in_mb:,=%

@REM suggest using memory, system memory 3 / 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@echo off
@REM set cmd format
chcp 65001
powershell -NoProfile -Command "$v=(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').CurrentMajorVersionNumber; if($v -gt 6) { cmd /c 'chcp 65001' }"

title IoTDB ConfigNode

Expand Down
14 changes: 7 additions & 7 deletions iotdb-core/datanode/src/assembly/resources/conf/datanode-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ if %JMX_LOCAL% == "false" (

set IOTDB_JMX_OPTS=%IOTDB_JMX_OPTS% -Diotdb.jmx.local=%JMX_LOCAL%

for /f %%b in ('wmic cpu get numberofcores ^| findstr "[0-9]"') do (
set system_cpu_cores=%%b
REM Replace wmic with PowerShell for CPU core count
for /f %%b in ('powershell -NoProfile -Command "$v=$host.Version.Major; if($v -lt 3) {(Get-WmiObject Win32_Processor).NumberOfCores} else {(Get-CimInstance -ClassName Win32_Processor).NumberOfCores}"') do (
set system_cpu_cores=%%b
)

if %system_cpu_cores% LSS 1 set system_cpu_cores=1

for /f %%b in ('wmic ComputerSystem get TotalPhysicalMemory ^| findstr "[0-9]"') do (
set system_memory=%%b
REM Replace wmic with PowerShell for total physical memory
for /f %%b in ('powershell -NoProfile -Command "$v=$host.Version.Major; $mem=if($v -lt 3){(Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory} else{(Get-CimInstance -ClassName Win32_ComputerSystem).TotalPhysicalMemory}; [math]::Round($mem/1048576)"') do (
set system_memory_in_mb=%%b
)

echo wsh.echo FormatNumber(cdbl(%system_memory%)/(1024*1024), 0) > "%IOTDB_HOME%\sbin\tmp.vbs"
for /f "tokens=*" %%a in ('cscript //nologo "%IOTDB_HOME%\sbin\tmp.vbs"') do set system_memory_in_mb=%%a
del "%IOTDB_HOME%\sbin\tmp.vbs"
REM Remove VBScript usage for memory calculation
set system_memory_in_mb=%system_memory_in_mb:,=%

set /a suggest_=%system_memory_in_mb%/2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@echo off
@REM set cmd format
chcp 65001
powershell -NoProfile -Command "$v=(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').CurrentMajorVersionNumber; if($v -gt 6) { cmd /c 'chcp 65001' }"

title IoTDB DataNode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ 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"
)

REM Replace wmic with PowerShell for total visible memory size
for /f %%i in ('powershell -NoProfile -Command "$v=$host.Version.Major; $mem=if($v -lt 3){(Get-WmiObject Win32_OperatingSystem).TotalVisibleMemorySize} else{(Get-CimInstance -ClassName Win32_OperatingSystem).TotalVisibleMemorySize}; [math]::Round($mem/1024)"') do (
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
Expand Down Expand Up @@ -616,19 +614,15 @@ endlocal
exit /b

:system_settings_check
setlocal enabledelayedexpansion
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
)
)
)
)

set "check_swap_ps_cmd=$v=$host.Version.Major; if($v -lt 3) { $sys=Get-WmiObject Win32_ComputerSystem; if($sys.AutomaticManagedPagefile) { 'Enabled' } else { $page=Get-WmiObject Win32_PageFileSetting -EA 0; if(!$page) { 'Disabled' } else { $page | %% { if($_.InitialSize -ne 0 -or $_.MaximumSize -ne 0) { 'Enabled'; exit } } 'Disabled' } } } else { $sys=Get-CimInstance Win32_ComputerSystem; if($sys.AutomaticManagedPagefile) { 'Enabled' } else { $page=Get-CimInstance Win32_PageFileSetting -EA 0; if(!$page) { 'Disabled' } else { $page | %% { if($_.InitialSize -ne 0 -or $_.MaximumSize -ne 0) { 'Enabled'; exit } } 'Disabled' } } }"
for /f "delims=" %%a in ('powershell -NoProfile -Command "%check_swap_ps_cmd%"') do set "result=%%a"

echo Result: !result!
endlocal
exit /b

:checkIfIOTDBProcess
Expand All @@ -637,9 +631,8 @@ 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
)
for /f "delims=" %%i in ('powershell -NoProfile -Command "$v=$host.Version.Major; if($v -lt 3) { (Get-WmiObject Win32_Process -Filter \"ProcessId='%pid_to_check%'\").CommandLine } else { (Get-CimInstance Win32_Process -Filter \"ProcessId='%pid_to_check%'\").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
Loading