Skip to content

Instantly share code, notes, and snippets.

@turbulentie
Last active June 5, 2024 04:02
Show Gist options
  • Save turbulentie/a0aa73fb649a5d3790f4605e122b20f1 to your computer and use it in GitHub Desktop.
Save turbulentie/a0aa73fb649a5d3790f4605e122b20f1 to your computer and use it in GitHub Desktop.
ipmitool for cygwin

ipmitool compiling from sources using Cygwin

Table of Contents

Introduction

ipmitool is a utility for managing and configuring devices that support the Intelligent Platform Management Interface. IPMI is an open standard for monitoring, logging, recovery, inventory, and control of hardware that is implemented independent of the main CPU, BIOS, and OS. The service processor (or Baseboard Management Controller, BMC) is the brain behind platform management and its primary purpose is to handle the autonomous sensor monitoring and event logging features. The ipmitool program provides a simple command-line interface to this BMC. It features the ability to read the sensor data repository (SDR) and print sensor values, display the contents of the System Event Log (SEL), print Field Replaceable Unit (FRU) inventory information, read and set LAN configuration parameters, and perform remote chassis power control.

Prerequisites

First, you need to install Cygwin on your Windows machine. You can skip this step if you have Cygwin already installed, if not go to: https://cygwin.com/install.html and follow the procedure. During Cygwin installation make sure what you select packages:

m4 libtool libncurses-devel libreadline-devel libssl-devel dos2unix wget

I recommend to use Cygwin Package Manager called apt-cyg.

Building from sources

ipmitool git sources located here.

Open your Cygwin Terminal and enter the following:

  • git clone https://github.com/ipmitool/ipmitool ~/.src/ipmitool-git
  • cd ~/.src/ipmitool-git
  • dos2unix bootstrap configure.ac csv-revision
  • ./bootstrap && ./configure --prefix=/tmp/ipmitool IANADIR=assignments
  • make
  • make install
  • mv assignments /tmp/ipmitool/bin
  • mv /tmp/ipmitool/sbin/ipmievd.exe /tmp/ipmitool/bin

"--prefix=/tmp/ipmitool" means what all files after cmd make install will be installed to /tmp/ipmitool path "IANADIR=assignments" custom path to enterprise-numbers prevents error:

IANA PEN registry open failed: No such file or directory

Example of successful configure:

$ dos2unix bootstrap configure.ac csv-revision
dos2unix: converting file bootstrap to Unix format...
dos2unix: converting file configure.ac to Unix format...
dos2unix: converting file csv-revision to Unix format...

$ ./bootstrap && ./configure --prefix=/tmp/ipmitool IANADIR=assignments
+ aclocal
+ case `uname` in
++ uname
+ libtoolize --automake --copy
+ autoheader
+ automake --foreign --add-missing --copy
configure.ac:15: installing './compile'
configure.ac:8: installing './config.guess'
configure.ac:8: installing './config.sub'
configure.ac:9: installing './install-sh'
configure.ac:9: installing './missing'
lib/Makefile.am: installing './depcomp'
+ aclocal
+ autoconf
+ automake --foreign
checking build system type... x86_64-pc-cygwin
checking host system type... x86_64-pc-cygwin
checking target system type... x86_64-pc-cygwin

...

ipmitool 1.8.18.232.g11c7605

Interfaces (default=lan)
  lan     : yes
  lanplus : yes
  open    : no
  free    : no
  imb     : no
  bmc     : no
  dbus    : no
  usb     : no
  lipmi   : no
  serial  : yes
  dummy   : no

Extra tools
  ipmievd   : yes
  ipmishell : yes

Check for ipmitool

Our self-compiled binary located at /tmp/ipmitool/bin

$ ls -la /tmp/ipmitool/bin
total 5184
drwxr-xr-x+ 1 USER None       0 Jul 13 14:47 .
drwxr-xr-x+ 1 USER None       0 Jul 13 14:00 ..
drwxr-xr-x+ 1 USER None       0 Jul 13 14:00 assignments
-rwxr-xr-x  1 USER None 1788436 Jul 13 14:00 ipmievd.exe
-rwxr-xr-x  1 USER None 3512691 Jul 13 14:00 ipmitool.exe

Test the ipmitool

$ cd /tmp/ipmitool/bin
$ ./ipmitool.exe -U ADMIN -P ADMIN -H 192.168.0.254 chassis power status
Chassis Power is on

Standalone package of ipmitool

To run *.exe we dont need Cygwin environment and make package which can be runs on another Windows machine without Cygwin. We need to check with ldd which dynamic libraries uses our executable file:

"ldd /path/to/binary" - just example!

$ ldd ./ipmitool.exe
        ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffd27770000)
        KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffd26100000)
        KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7ffd25250000)
        cygcrypto-1.1.dll => /usr/bin/cygcrypto-1.1.dll (0x3e1f20000)
        cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
        cygreadline7.dll => /usr/bin/cygreadline7.dll (0x3c7700000)
        cygz.dll => /usr/bin/cygz.dll (0x3c11d0000)
        cygncursesw-10.dll => /usr/bin/cygncursesw-10.dll (0x3ca9d0000)

As showing above we need to copy 5 *.so files! Oh sorry 5 *.dll files to dir where ipmitool.exe located:

$ cd /usr/bin
cp cygcrypto-1.1.dll cygwin1.dll cygreadline7.dll cygz.dll cygncursesw-10.dll /tmp/ipmitool/bin

Checking again ldd ./ipmitool.exe:

cd /tmp/ipmitool/bin
ldd ./ipmitool.exe
        ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffd27770000)
        KERNEL32.DLL => /cygdrive/c/WINDOWS/System32/KERNEL32.DLL (0x7ffd26100000)
        KERNELBASE.dll => /cygdrive/c/WINDOWS/System32/KERNELBASE.dll (0x7ffd25250000)
        cygreadline7.dll => /tmp/ipmitool/bin/cygreadline7.dll (0x3c7700000)
        cygwin1.dll => /tmp/ipmitool/bin/cygwin1.dll (0x180040000)
        cygwin1.dll => /tmp/ipmitool/bin/cygwin1.dll (0xcd0000)
        cygncursesw-10.dll => /tmp/ipmitool/bin/cygncursesw-10.dll (0x3ca9d0000)
        cygcrypto-1.1.dll => /tmp/ipmitool/bin/cygcrypto-1.1.dll (0x3e1f20000)
        cygz.dll => /tmp/ipmitool/bin/cygz.dll (0x3c11d0000)

And we see changes in output:

...
-        cygncursesw-10.dll => /usr/bin/cygncursesw-10.dll (0x3ca9d0000)
...

...
+        cygncursesw-10.dll => /tmp/ipmitool/bin/cygncursesw-10.dll (0x3ca9d0000)
...

Note: ipmievd.exe uses the same dynamic libraries.

So everything is done. You can pack files and run them on any Windows PC w/o Cygwin:

winterm>ipmitool.exe

console2>ipmitool.exe

Basic ipmitool Commands

Command Description
chassis status Get chassis status and set power state
sel Print event log
sel elist Prints more verbose information
sensor list Print detailed sensor information
sdr Print Sensor Data Repository entries and readings
chassis power on Power on
chassis power off Power off
chassis power reset Toggle power
chassis power soft Graceful shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment