ipmitool usage

Simply put, ipmitool is a tool used to send IPMI commands. There is a copy in /home/daq/bin and in /home/msdim/ipmi/ipmitool-1.8.11/src on cms1.

For our uses, the syntax for use is as follows:

./ipmitool -H < ip address > -P < password > -T < transit address for bridge > -B < transit channel for bridge > \
-t < target address > -b < target channel > < ipmitool command > < net function > < IPMI command > < data >

In general, use:

./ipmitool -H < ip address > -P "" -T 0x82 -B 0 -t 0x14 -b 7 raw 0x30 < IPMI cmd > 0 0 < register >

By default, the MCH is set up for double-bridged commands. If it is set up for single-bridge, then the command is:

./ipmitool -H < ip address > -P "" -t 0x14 raw 0x30 < IPMI cmd > 0 0 < register >
To check/set for single-bridged commands, see DTCDebugLog: 2010-03-29.

For < IPMI cmd >, use 0x1 for read and 0x2 for write. The registers are 8-bit and ipmitool will print the result of a read command as follows:

00 2a
Disregard the 00; the 2a would be the value of the register.

< ip address > of MCH in BU EDF:

 192.168.1.41 
(Current as of June 10, 2013).

ipmitool code

ipmitool is open-source. Taking /home/msdim/ipmi/ipmitool-1.8.11 as the top level directory:

• The header files are located in include/ipmitool/

• Most of the associated C files are located in lib/

• ipmitool is located in src/

• The interface code for communicating via LAN, BMC, etc is in src/plugins/ (only LAN is used)

All of the information about communicating with some address through some interface is contained in the structure "struct ipmi_intf" (ipmi interface), which is defined in ipmi_intf.h and requires the library libintf.a (the library is in src/plugins/.libs). The intf library has functionalitly to connect in several different ways, which are listed in src/plugins; we use the lan interface. To load a selected interface, use the following code:

struct ipmi_intf *intf;
intf = ipmi_intf_load(strdup("lan"));

The method ipmi_intf_load returns a pointer to a structure which contains pointers to specialized functions such as open and sendrecv. These functions have the same names and parameter list among all of the interfaces; since ipmitool is written in C, there are not any classes or possibility of overloading functions, so ipmi_intf_load simply loads the proper interface library and uses its functions.

All of the necessary addresses and attributes are sored in (or referenced by) variables in the ipmi_intf structure. These variables are set by a series of functions, the most important of which are:

  ipmi_intf_session_set_hostname(intf, ip_address);
  ipmi_intf_session_set_password(intf, "");
  ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN);
  ipmi_intf_session_set_lookupbit(intf, 0x10);
  ipmi_intf_session_set_cipher_suite_id(intf, 3);

there are also variables that are set one at a time:

    intf->target_addr = (uint8_t)strtol(TARGET_ADDR, NULL, 0);
    intf->transit_addr    = (uint8_t)strtol(TRANSIT_ADDR, NULL, 0);
    intf->transit_channel = (uint8_t)strtol(TRANSIT_CHANNEL, NULL, 0);
    intf->target_channel  = (uint8_t)strtol(TARGET_CHANNEL, NULL, 0);

Finally, to make contact with the address, use "intf->open(intf)" which will return a negative integer if a connection cannot be esablished. Examples of everything explained so far may be found in lib/ipmi_main.c in the ipmi_main function or in src/dtcreg/dtcreg.cc (from the dtcreg library) in the dtc_open function.

The functions required for sending a raw IPMI command (0x1 for read, 0x2 for write, etc) are defined in lib/ipmi_raw.c. The most basic function is ipmi_raw_main, which accepts a pointer to the interface (ipmi_intf *), and a C style argc and **argv. The function parses argv for a set of tags defined for ipmitool and prints to standard output the result (if the read command is passed). Therefore, it is useful to ignore this function and create one based on its code.

-- MichaelDimitriyev - 16 Jun 2010

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 10 Jun 2013 - DavidZou
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback