go-ipmi is a pure Golang native IPMI library. It DOES NOT wrap ipmitool.
import (
"fmt"
"github.com/bougou/go-ipmi"
)
func main () {
host := "10.0.0.1"
port := 623
username := "root"
password := "123456"
client , err := ipmi .NewClient (host , port , username , password )
// Supports local mode client when running directly on Linux
// client, err := ipmi.NewOpenClient()
if err != nil {
panic (err )
}
// You can optionally enable debug mode
// client.WithDebug(true)
// You can set the interface to "lan" or "lanplus" for remote client.
// client.WithInterface(ipmi.InterfaceLanplus)
// client.WithInterface(ipmi.InterfaceLan)
// !!! Note !!!
// From v0.6.0, all IPMI command methods of the Client require a context as the first argument.
ctx := context .Background ()
// Connect creates an authenticated session
if err := client .Connect (ctx ); err != nil {
panic (err )
}
// Now you can execute other IPMI commands that require authentication
res , err := client .GetDeviceID (ctx )
if err != nil {
panic (err )
}
fmt .Println (res .Format ())
selEntries , err := client .GetSELEntries (ctx , 0 )
if err != nil {
panic (err )
}
fmt .Println (ipmi .FormatSELs (selEntries , nil ))
}
The goipmi binary provides command usage similar to ipmitool.
The goipmi tool uses the go-ipmi library under the hood.
The purpose of creating the goipmi tool was not to substitute ipmitool.
It was created to verify the correctness of the go-ipmi library.
Functions Comparison with ipmitool
Each command defined in the IPMI specification consists of a pair of request/response messages.
These IPMI commands are implemented as methods of the ipmi.Client struct in this library.
Some ipmitool command line operations are implemented by calling just one IPMI command,
while others are not. For example, ipmitool sdr list involves a loop of GetSDR IPMI commands.
This library also implements some helper methods that are not IPMI commands defined
in the IPMI specification, but are common utilities, like GetSDRs to get all SDRs.
These methods are marked with an asterisk (*) after the method name in the following documentation.
The implementation logic of IPMI commands is largely consistent. See Contributing
More commands are in development...
IPM Device Global Commands
Method
Status
corresponding ipmitool usage
GetDeviceID
✅
mc info
ColdReset
✅
mc reset cold
WarmReset
✅
mc reset warm
GetSelfTestResults
✅
mc selftest, chassis selftest
ManufacturingTestOn
✅
SetACPIPowerState
✅
GetACPIPowerState
✅
GetDeviceGUID
✅
GetNetFnSupport
✅
GetCommandSupport
✅
GetCommandSubfunctionSupport
✅
GetConfigurableCommands
✅
GetConfigurableCommandSubfunctions
✅
SetCommandEnables
✅
GetCommandEnables
✅
SetCommandSubfunctionEnables
✅
GetCommandSubfunctionEnables
✅
GetOEMNetFnIanaSupport
BMC Watchdog Timer Commands
Method
Status
corresponding ipmitool usage
ResetWatchdogTimer
✅
mc watchdog reset
SetWatchdogTimer
✅
GetWatchdogTimer
✅
mc watchdog get
BMC Device and Messaging Commands
Method
Status
corresponding ipmitool usage
SetBMCGlobalEnables
✅
GetBMCGlobalEnables
✅
ClearMessageFlags
✅
GetMessageFlags
✅
EnableMessageChannelReceive
✅
GetMessage
✅
SendMessage
✅
ReadEventMessageBuffer
✅
GetBTInterfaceCapabilities
✅
GetSystemGUID
✅
mc guid
SetSystemInfoParam
✅
SetSystemInfoParamFor (*)
✅
GetSystemInfoParam
✅
GetSystemInfoParamFor (*)
✅
GetSystemInfoParams (*)
✅
GetSystemInfoParamsFor (*)
✅
GetSystemInfo (*)
✅
GetChannelAuthCapabilities
✅
GetSessionChallenge
✅
ActivateSession
✅
SetSessionPrivilegeLevel
✅
CloseSession
✅
GetSessionInfo
✅
session info
GetAuthCode
✅
SetChannelAccess
✅
channel setaccess
GetChannelAccess
✅
channel info/getaccess
GetChannelInfo
✅
channel info
SetUserAccess
✅
GetUserAccess
✅
user summary
GetUsers (*)
✅
user list
SetUsername
✅
user set name
DisableUser (*)
✅
user disable
EnableUser (*)
✅
user enable
GetUsername
✅
SetUserPassword
✅
user set password
TestUserPassword (*)
✅
user test
ActivatePayload
✅
DeactivatePayload
✅
GetPayloadActivationStatus
✅
GetPayloadInstanceInfo
✅
SetUserPayloadAccess
✅
GetUserPayloadAccess
✅
sol payload status
GetChannelPayloadSupport
✅
GetChannelPayloadVersion
✅
GetChannelOEMPayloadInfo
✅
MasterWriteRead
✅
GetChannelCipherSuites
✅
SuspendResumePayloadEncryption
✅
SetChannelSecurityKeys
✅
GetSystemInterfaceCapabilities
✅
Method
Status
corresponding ipmitool usage
GetChassisCapabilities
✅
GetChassisStatus
✅
chassis status, chassis power status
ChassisControl
✅
chassis power on/off/cycle/reset/diag/soft
ChassisReset
✅
ChassisIdentify
✅
chassis identify
SetChassisCapabilities
✅
SetPowerRestorePolicy
✅
chassis policy list/always-on/previous/always-off
GetSystemRestartCause
✅
chassis restart_cause
SetBootParamBootFlags (*)
✅
chassis bootdev
SetBootDevice (*)
✅
chassis bootdev
SetSystemBootOptionsParam
✅
chassis bootparam set
GetSystemBootOptionsParam
✅
chassis bootparam get
GetSystemBootOptionsParamFor (*)
✅
chassis bootparam get
GetSystemBootOptionsParams (*)
✅
chassis bootparam get
GetSystemBootOptionsParamsFor (*)
✅
chassis bootparam get
SetFrontPanelEnables
✅
SetPowerCycleInterval
✅
GetPOHCounter
✅
chassis poh
Method
Status
corresponding ipmitool usage
SetEventReceiver
✅
GetEventReceiver
✅
PlatformEventMessage
✅
PEF and Alerting Commands
Method
Status
corresponding ipmitool usage
GetPEFCapabilities
✅
pef capabilities
ArmPEFPostponeTimer
✅
SetPEFConfigParam
✅
GetPEFConfigParam
✅
GetPEFConfigParamFor (*)
✅
GetPEFConfigParams (*)
✅
GetPEFConfigParamsFor (*)
✅
SetLastProcessedEventId
✅
GetLastProcessedEventId
✅
AlertImmediate
✅
PETAcknowledge
✅
Method
Status
corresponding ipmitool usage
GetDeviceSDRInfo
✅
GetDeviceSDR
✅
ReserveDeviceSDRRepo
✅
GetSensorReadingFactors
✅
SetSensorHysteresis
✅
GetSensorHysteresis
✅
SetSensorThresholds
✅
GetSensorThresholds
✅
SetSensorEventEnable
✅
GetSensorEventEnable
✅
RearmSensorEvents
✅
GetSensorEventStatus
✅
GetSensorReading
✅
SetSensorType
✅
GetSensorType
✅
SetSensorReadingAndEventStatus
✅
GetSensors (*)
✅
sensor list, sdr type
GetSensorByID (*)
✅
GetSensorByName (*)
✅
sensor get
Method
Status
corresponding ipmitool usage
GetFRUInventoryAreaInfo
✅
ReadFRUData
✅
WriteFRUData
✅
GetFRU (*)
✅
fru print
GetFRUs (*)
✅
fru print
Method
Status
corresponding ipmitool usage
GetSDRRepoInfo
✅
sdr info
GetSDRRepoAllocInfo
✅
sdr info
ReserveSDRRepo
GetSDR
✅
GetSDRs (*)
✅
GetSDRBySensorID (*)
✅
GetSDRBySensorName (*)
✅
AddSDR
PartialAddSDR
DeleteSDR
ClearSDRRepo
GetSDRRepoTime
SetSDRRepoTime
EnterSDRRepoUpdateMode
ExitSDRRepoUpdateMode
RunInitializationAgent
Method
Status
corresponding ipmitool usage
GetSELInfo
✅
sel info
GetSELAllocInfo
✅
sel info
ReserveSEL
✅
GetSELEntry
✅
AddSELEntry
✅
PartialAddSELEntry
DeleteSELEntry
✅
ClearSEL
✅
sel clear
GetSELTime
✅
SetSELTime
✅
GetAuxLogStatus
SetAuxLogStatus
GetSELTimeUTCOffset
✅
SetSELTimeUTCOffset
✅
Method
Status
corresponding ipmitool usage
SetLanConfigParam
✅
lan set
SetLanConfigParamFor (*)
✅
lan set
GetLanConfigParam
✅
GetLanConfigParamFor (*)
✅
lan print
GetLanConfigParams (*)
✅
lan print
GetLanConfigParamsFor (*)
✅
lan print
GetLanConfig (*)
✅
lan print
SuspendARPs
✅
GetIPStatistics
✅
Serial/Modem Device Commands
Method
Status
corresponding ipmitool usage
SetSerialConfig
GetSerialConfig
SetSerialMux
GetTapResponseCodes
SetPPPTransmitData
GetPPPTransmitData
SendPPPPacket
GetPPPReceiveData
SerialConnectionActive
Callback
SetUserCallbackOptions
GetUserCallbackOptions
SetSerialRoutingMux
SOLActivating
✅
SetSOLConfigParam
✅
SetSOLConfigParamFor (*)
✅
GetSOLConfigParam
✅
GetSOLConfigParamFor (*)
✅
GetSOLConfigParams (*)
✅
sol info
GetSOLConfigParamsFor (*)
✅
sol info
Command Forwarding Commands
Method
Status
corresponding ipmitool usage
Forwarded
SetForwarded
GetForwarded
EnableForwarded
Bridge Management Commands (ICMB)
Method
Status
corresponding ipmitool usage
GetBridgeState
SetBridgeState
GetICMBAddress
SetICMBAddress
SetBridgeProxyAddress
GetBridgeStatistics
GetICMBCapabilities
ClearBridgeStatistics
GetBridgeProxyAddress
GetICMBConnectorInfo
GetICMBConnectionID
SendICMBConnectionID
Discovery Commands (ICMB)
Method
Status
corresponding ipmitool usage
PrepareForDiscovery
GetAddresses
SetDiscovered
GetChassisDeviceId
SetChassisDeviceId
Method
Status
corresponding ipmitool usage
BridgeRequest
BridgeMessage
Method
Status
corresponding ipmitool usage
GetEventCount
SetEventDestination
SetEventReceptionState
SendICMBEventMessage
GetEventDestination
GetEventReceptionState
Method
Status
corresponding ipmitool usage
ErrorReport
Method
Status
corresponding ipmitool usage
GetDCMICapParam
✅
dcmi discovery
GetDCMICapParamFor (*)
✅
dcmi discovery
GetDCMICapParams (*)
✅
dcmi discovery
GetDCMICapParamsFor (*)
✅
dcmi discovery
GetDCMIPowerReading
✅
dcmi power reading
GetDCMIPowerLimit
✅
dcmi power get_limit
SetDCMIPowerLimit
✅
dcmi power set_limit
ActivateDCMIPowerLimit
✅
dcmi activate/deactivate
GetDCMIAssetTag
✅
dcmi asset_tag
GetDCMIAssetTagFull (*)
✅
dcmi asset_tag
GetDCMISensorInfo
✅
dcmi sensors
SetDCMIAssetTag
✅
dcmi set_asset_tag
GetDCMIMgmtControllerIdentifier
✅
dcmi get_mc_id_string
SetDCMIMgmtControllerIdentifier
✅
dcmi set_mc_id_string
SetDCMIThermalLimit
✅
dcmi thermalpolicy get
GetDCMIThermalLimit
✅
dcmi thermalpolicy set
GetDCMITemperatureReadings
✅
dcmi get_temp_reading
SetDCMIConfigParam
✅
dcmi set_conf_param
GetDCMIConfigParam
✅
dcmi get_conf_param
GetDCMIConfigParamFor (*)
✅
dcmi get_conf_param
GetDCMIConfigParams (*)
✅
dcmi get_conf_param
GetDCMIConfigParamsFor (*)
✅
dcmi get_conf_param