commit 176316efae55a60e2d01e3e84c1d3f64f5e43ee5 Author: leimingsheng Date: Fri May 30 10:35:51 2025 +0800 init repo diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c13d22f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bmctool_output/* +plugin/* \ No newline at end of file diff --git a/bmctool.bat b/bmctool.bat new file mode 100644 index 0000000..2445aa8 --- /dev/null +++ b/bmctool.bat @@ -0,0 +1,230 @@ +@echo off +setlocal enabledelayedexpansion + +:: Script Info +set "ScriptVersion=0.0.1" +set "ScriptName=bmctool" + +set "OUTPUT_DIR=%CD%\bmctool_output" +set "COMMAND=" +set "PLUGIN=" + +:: 检查配置文件 +:CONFIG_CHECK + :: Step1. 导入默认配置 + set "CONF_PATH=%CD%\setting" + for /f "usebackq delims=" %%a in (` + powershell -command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.ip" + `) do set "BMC_IP=%%a" + + for /f "usebackq delims=" %%a in (` + powershell -command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.user" + `) do set "USERNAME=%%a" + + for /f "usebackq delims=" %%a in (` + powershell -command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.pass" + `) do set "PASSWORD=%%a" + + :: Step2. 查询插件脚本是否启用 + :: 如果不存在plugin路径则直接跳过该步骤 + set "PLUGIN_DIR=%CD%\plugin" + if not exist %PLUGIN_DIR% goto :END_CONFIG_CHECK + + for %%f in ("%PLUGIN_DIR%\plugin_*.bat") do ( + set "filename=%%~nf" + + for /f "tokens=2 delims=_" %%a in ("!filename!") do ( + set "plugin_id=%%a" + ) + + :: echo Find plugin : !plugin_id! + for /f "usebackq delims=" %%a in (` + powershell -command "$json = Get-Content '%CONF_PATH%\plugin.json' | ConvertFrom-Json; $json.!plugin_id!" + `) do set "is_enable=%%a" + + if "!is_enable!" == "enable" ( + :: echo !plugin_id! is valid + set "PLUGIN=!plugin_id!" + set "PluginBat=%PLUGIN_DIR%\plugin_!PLUGIN!.bat" + goto :END_CONFIG_CHECK + ) + ) + +:END_CONFIG_CHECK +:: Default Scirpt Varible +:: set "BMC_IP=192.168.100.2" +:: set "USERNAME=ADMIN" +:: set "PASSWORD=ADMIN" + + +:: 解析参数 +:PARSE_ARGS + if "%1"=="" goto :USAGE + if "%1"=="-h" goto :USAGE + if "%1"=="--help" goto :USAGE + +:ARG_LOOP + if "%1"=="" goto :ARGS_PARSED + if "%1"=="-i" ( + set "BMC_IP=%2" + shift + ) else if "%1"=="--ip" ( + set "BMC_IP=%2" + shift + ) else if "%1"=="-u" ( + set "USERNAME=%2" + shift + ) else if "%1"=="--user" ( + set "USERNAME=%2" + shift + ) else if "%1"=="-p" ( + set "PASSWORD=%2" + shift + ) else if "%1"=="--pass" ( + set "PASSWORD=%2" + shift + ) else ( + :: 剩余参数作为命令 + set "COMMAND=%COMMAND%%1" + ) + shift + goto :ARG_LOOP + +:ARGS_PARSED + :: 验证参数 + :: echo BMC IP : %BMC_IP% + :: echo USERNAME: %USERNAME% + :: echo PASSWORD: %PASSWORD% + :: echo Command : %COMMAND% + set "IPMI=ipmitool/ipmitool.exe -I lanplus -H %BMC_IP% -U %USERNAME% -P %PASSWORD%" + +if "%COMMAND%"=="" set "COMMAND=info" + +:: 创建输出目录 +if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%" + +:: 执行命令 +call :EXECUTE_COMMAND +exit /b %ERRORLEVEL% + +:: 命令执行函数 +:EXECUTE_COMMAND + if /i "%COMMAND%"=="info" ( + call :GET_SYSTEM_INFO + ) else if /i "%COMMAND:~0,5%"=="power" ( + call :MANAGE_POWER %COMMAND:~5% + ) else if /i "%COMMAND:~0,3%"=="set" ( + call :SET_CONFIG %COMMAND:~3% + ) else if /i "%COMMAND%" == "sensor" ( + call :GET_SENSOR_ELIST + ) else if /i "%COMMAND%" == "sdr" ( + call :GET_SDR_ELIST + ) else if /i "%COMMAND%" == "fru" ( + call :GET_FRU_INFO + ) else ( + :: 调用插件 + if defined PluginBat ( + call %PluginBat% -i %BMC_IP% -u %USERNAME% -p %PASSWORD% %COMMAND% + + if !errorlevel! == 1 ( + echo Invalid Command ! + exit /b 1 + ) + ) else ( + echo Invalid Command ! + exit /b 1 + ) + ) + exit /b 0 + +:: 获取BMC系统信息 +:GET_SYSTEM_INFO + echo Run Command GET_SYSTEM_INFO + %IPMI% mc info + exit /b 0 + +:: 电源管理 +:MANAGE_POWER + echo Run Command MANAGE_POWER + echo Param: %1 + set "action=%1" + if /i "%action%"=="on" ( + %IPMI% power on + ) else if /i "%action%"=="off" ( + %IPMI% power off + ) else if /i "%action%"=="cycle" ( + %IPMI% power cycle + ) + exit /b 0 + +:: Change defaut settings +:SET_CONFIG + echo Modify local config + set "Param=%1" + if /i "!Param:~0,2!" == "ip" ( + set "ipaddr=!Param:~2!" + echo Change ip to !ipaddr! + powershell -Command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.ip = '!ipaddr!'; $json | ConvertTo-Json | Set-Content '%CONF_PATH%\bmcconf.json'" + ) else if /i "!Param:~0,4!" == "user" ( + set "inputuser=!Param:~4!" + echo Change user to !inputuser! + powershell -Command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.user = '!inputuser!'; $json | ConvertTo-Json | Set-Content '%CONF_PATH%\bmcconf.json'" + ) else if /i "!Param:~0,4!" == "pass" ( + set "inputpass=!Param:~4!" + echo Change password to !inputpass! + powershell -Command "$json = Get-Content '%CONF_PATH%\bmcconf.json' | ConvertFrom-Json; $json.pass = '!inputpass!'; $json | ConvertTo-Json | Set-Content '%CONF_PATH%\bmcconf.json'" + ) else ( + echo Invalid Param ! + exit /b 1 + ) + + echo Modify Done + exit /b 0 + +:GET_SENSOR_ELIST + echo Run Command GET_SENSOR_ELIST + %IPMI% sensor elist + exit /b 0 + +:GET_SDR_ELIST + echo Run Command GET_SDR_ELIST + %IPMI% sdr elist + exit /b 0 + +:GET_FRU_INFO + echo Run Command GET_FRU_INFO + %IPMI% fru + exit /b 0 + +:: Help info +:USAGE + echo %ScriptName% v%ScriptVersion% Usage + echo. + echo Format: %ScriptName% [-i bmcip] [-u username] [-p password] command + echo. + echo Param Details + echo -i, --ip BMC IP Address + echo -u, --user BMC IPMI User Name + echo -p, --pass BMC IPMI User Password + echo -h, --help Show this info + echo. + echo Common Command List + echo info Get BMC System Info + echo power on Set Power on to BMC + echo power off Set Power off to BMC + echo power cycle Set Power cycle to BMC + echo sensor Show the sensor elist + echo sdr Show the sdr elist + echo fru Show the fru info + echo set ip [ip addr] Set ip addr to default config + echo set user [name] Set IPMI user to default config + echo set pass [pw] Set IPMI password to default config + echo. + + :: if enable plugin, show the help info here + if defined PluginBat ( + %PluginBat% --help + ) + exit /b 1 + +endlocal \ No newline at end of file diff --git a/ipmitool/Command Prompt.lnk b/ipmitool/Command Prompt.lnk new file mode 100644 index 0000000..681f53e Binary files /dev/null and b/ipmitool/Command Prompt.lnk differ diff --git a/ipmitool/MemoryAssistant_v110.exe b/ipmitool/MemoryAssistant_v110.exe new file mode 100644 index 0000000..17ea8c3 Binary files /dev/null and b/ipmitool/MemoryAssistant_v110.exe differ diff --git a/ipmitool/Readme.txt b/ipmitool/Readme.txt new file mode 100644 index 0000000..5144644 --- /dev/null +++ b/ipmitool/Readme.txt @@ -0,0 +1,106 @@ +ʹ÷Χ:ǰipmitoolĵʹ +ʱ:2018.2.28 +汾1.8.18 +ipmitool 1.8.18 +ù: +Interfaces + lan : yes + lanplus : yes + open : no + free : no + imb : no + bmc : no + usb : no + lipmi : no + serial : yes + dummy : no + +lanlanplusԽ׶ + +PS C:\Users\Administrator\Desktop\IPMIToolWin1.8.18> .\ipmitool.exe -H $BMCIP -U $bmcuser -P $password -I lanplus -h +ipmitool version 1.8.18 + +usage: ipmitool [options...] + + -h This help + -V Show version information + -v Verbose (can use multiple times) + -c Display output in comma separated format + -d N Specify a /dev/ipmiN device to use (default=0) + -I intf Interface to use + -H hostname Remote host name for LAN interface + -p port Remote RMCP port [default=623] + -U username Remote session username + -f file Read remote session password from file + -z size Change Size of Communication Channel (OEM) + -S sdr Use local file for remote SDR cache + -D tty:b[:s] Specify the serial device, baud rate to use + and, optionally, specify that interface is the system one + -4 Use only IPv4 + -6 Use only IPv6 + -a Prompt for remote password + -Y Prompt for the Kg key for IPMIv2 authentication + -e char Set SOL escape character + -C ciphersuite Cipher suite to be used by lanplus interface + -k key Use Kg key for IPMIv2 authentication + -y hex_key Use hexadecimal-encoded Kg key for IPMIv2 authentication + -L level Remote session privilege level [default=ADMINISTRATOR] + Append a '+' to use name/privilege lookup in RAKP1 + -A authtype Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM + -P password Remote session password + -E Read password from IPMI_PASSWORD environment variable + -K Read kgkey from IPMI_KGKEY environment variable + -m address Set local IPMB address + -b channel Set destination channel for bridged request + -t address Bridge request to remote target address + -B channel Set transit channel for bridged request (dual bridge) + -T address Set transit address for bridge request (dual bridge) + -l lun Set destination lun for raw commands + -o oemtype Setup for OEM (use 'list' to see available OEM types) + -O seloem Use file for OEM SEL event descriptions + -N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface + -R retry Set the number of retries for lan/lanplus interface [default=4] + +Interfaces: + lan IPMI v1.5 LAN Interface [default] + lanplus IPMI v2.0 RMCP+ LAN Interface + serial-terminal Serial Interface, Terminal Mode + serial-basic Serial Interface, Basic Mode + +Commands: + raw Send a RAW IPMI request and print response + i2c Send an I2C Master Write-Read command and print response + spd Print SPD info from remote I2C device + lan Configure LAN Channels + chassis Get chassis status and set power state + power Shortcut to chassis power commands + event Send pre-defined events to MC + mc Management Controller status and global enables + sdr Print Sensor Data Repository entries and readings + sensor Print detailed sensor information + fru Print built-in FRU and scan SDR for FRU locators + gendev Read/Write Device associated with Generic Device locators sdr + sel Print System Event Log (SEL) + pef Configure Platform Event Filtering (PEF) + sol Configure and connect IPMIv2.0 Serial-over-LAN + tsol Configure and connect with Tyan IPMIv1.5 Serial-over-LAN + isol Configure IPMIv1.5 Serial-over-LAN + user Configure Management Controller users + channel Configure Management Controller channels + session Print session information + dcmi Data Center Management Interface + nm Node Manager Interface + sunoem OEM Commands for Sun servers + kontronoem OEM Commands for Kontron devices + picmg Run a PICMG/ATCA extended cmd + fwum Update IPMC using Kontron OEM Firmware Update Manager + firewall Configure Firmware Firewall + delloem OEM Commands for Dell systems + exec Run list of commands from file + set Set runtime variable for shell and exec + hpm Update HPM components using PICMG HPM.1 file + ekanalyzer run FRU-Ekeying analyzer using FRU files + ime Update Intel Manageability Engine Firmware + vita Run a VITA 46.11 extended cmd + lan6 Configure IPv6 LAN Channels + diff --git a/ipmitool/Riserfru.bin b/ipmitool/Riserfru.bin new file mode 100644 index 0000000..6475b4d Binary files /dev/null and b/ipmitool/Riserfru.bin differ diff --git a/ipmitool/cygcrypto-1.0.0.dll b/ipmitool/cygcrypto-1.0.0.dll new file mode 100644 index 0000000..73162e6 Binary files /dev/null and b/ipmitool/cygcrypto-1.0.0.dll differ diff --git a/ipmitool/cyggcc_s-1.dll b/ipmitool/cyggcc_s-1.dll new file mode 100644 index 0000000..c907daf Binary files /dev/null and b/ipmitool/cyggcc_s-1.dll differ diff --git a/ipmitool/cygwin1.dll b/ipmitool/cygwin1.dll new file mode 100644 index 0000000..b609c04 Binary files /dev/null and b/ipmitool/cygwin1.dll differ diff --git a/ipmitool/cygz.dll b/ipmitool/cygz.dll new file mode 100644 index 0000000..074848c Binary files /dev/null and b/ipmitool/cygz.dll differ diff --git a/ipmitool/desktop.ini b/ipmitool/desktop.ini new file mode 100644 index 0000000..00f30c4 --- /dev/null +++ b/ipmitool/desktop.ini @@ -0,0 +1,2 @@ +[LocalizedFileNames] +Command Prompt.lnk=@%SystemRoot%\system32\shell32.dll,-22022 diff --git a/ipmitool/ipmitool.exe b/ipmitool/ipmitool.exe new file mode 100644 index 0000000..eaebddc Binary files /dev/null and b/ipmitool/ipmitool.exe differ diff --git a/ipmitool/ipmitool_serial_log_collecting_commands.txt b/ipmitool/ipmitool_serial_log_collecting_commands.txt new file mode 100644 index 0000000..8de43b9 --- /dev/null +++ b/ipmitool/ipmitool_serial_log_collecting_commands.txt @@ -0,0 +1,14 @@ +0.client端打开debug模式: +ipmitool -I lanplus -H ip -U admin -P admin raw 0x3c 0x04 0x32 2 +1.vim /etc/default/grub +2.编辑GRUB_CMDLINE_LINUX开头的那一行, +删除掉其中的rhgb quiet,引号内增加console=tty0 console=ttyS0,115200 +3.grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg 生成新的grub启动项 +里面的redhat可能是centos,根据OS选择 +4.client端开启sol收集串口日志: +ipmitool -I lanplus -H ip -U admin -P admin sol activate > debug.log +5.测试完成,client端结束收集命令 +先新开一个终端,使用killall -9 ipmitool来结束命令 +然后ipmitool -I lanplus -H ip -U admin -P admin sol deactivate 关闭sol. +6.client端关闭debug模式: +ipmitool -I lanplus -H ip -U admin -P admin raw 0x3c 0x04 0x32 0 \ No newline at end of file diff --git a/ipmitool/null b/ipmitool/null new file mode 100644 index 0000000..8ef54b9 --- /dev/null +++ b/ipmitool/null @@ -0,0 +1,16 @@ + + Ping 127.0.0.1 32 ֽڵ: + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + 127.0.0.1 Ļظ: ֽ=32 ʱ<1ms TTL=128 + +127.0.0.1 Ping ͳϢ: + ݰ: ѷ = 9ѽ = 9ʧ = 0 (0% ʧ) +г̵Ĺʱ(ԺΪλ): + = 0ms = 0msƽ = 0ms diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..f0f8754 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# BMC Tool for windows + +一个用于在windows下执行的bat脚本工具 \ No newline at end of file diff --git a/setting/bmcconf.json b/setting/bmcconf.json new file mode 100644 index 0000000..e4f0616 --- /dev/null +++ b/setting/bmcconf.json @@ -0,0 +1,5 @@ +{ + "ip": "192.168.100.2", + "user": "ADMIN", + "pass": "ADMIN" +} diff --git a/setting/plugin.json b/setting/plugin.json new file mode 100644 index 0000000..cdf6567 --- /dev/null +++ b/setting/plugin.json @@ -0,0 +1,3 @@ +{ + "ZiJin": "disable" +} \ No newline at end of file