Hi all.
You will find a patch which fix 2 issues:
1. Current IPMI version can work either with IP or DNS name of host, but modern servers use additional IP address (out-of-band address or dedicated port Intel RMM2 for example) and this patch provide an opportunity to config IPMI over specific IP address.
2. I've found rather nasty bug in src/zabbix_server/operations.c
If we use IPMI as remote command (power off, power on etc.) then server crashes with error of freeing memory. It was defined "agent_result" variable, but in case of IPMI actions it's not initialized and after server trying to free undefined variable. To solve this we need to exclude free_result operation. My solution is not eye-candy, but I have not enough time to solve it and create the simplest one.
You will find a patch which fix 2 issues:
1. Current IPMI version can work either with IP or DNS name of host, but modern servers use additional IP address (out-of-band address or dedicated port Intel RMM2 for example) and this patch provide an opportunity to config IPMI over specific IP address.
2. I've found rather nasty bug in src/zabbix_server/operations.c
Code:
static void run_remote_command(char* host_name, char* command)
{
int ret = 9;
AGENT_RESULT agent_result;
DB_ITEM item;
DB_RESULT result;
DB_ROW row;
char *p, *host_esc, key[ITEM_KEY_LEN_MAX];
#ifdef HAVE_OPENIPMI
int val;
char error[MAX_STRING_LEN];
#endif
assert(host_name);
assert(command);
zabbix_log(LOG_LEVEL_DEBUG, "In run_remote_command(hostname:%s,command:%s)",
host_name,
command);
host_esc = DBdyn_escape_string(host_name);
result = DBselect("select distinct host,ip,useip,port,dns,useipmi,ipmi_host,ipmi_port,ipmi_authtype,"
"ipmi_privilege,ipmi_username,ipmi_password from hosts where host='%s'" DB_NODE,
host_esc,
DBnode_local("hostid"));
zbx_free(host_esc);
if (NULL != (row = DBfetch(result)))
{
*key = '\0';
item.key = key;
item.host_name = row[0];
item.host_ip = row[1];
item.useip = atoi(row[2]);
item.port = atoi(row[3]);
item.host_dns = row[4];
item.useipmi = atoi(row[5]);
item.ipmi_ip = row[6];
item.ipmi_port = atoi(row[7]);
item.ipmi_authtype = atoi(row[8]);
item.ipmi_privilege = atoi(row[9]);
item.ipmi_username = row[10];
item.ipmi_password = row[11];
p = command;
while (*p == ' ' && *p != '\0')
p++;
#ifdef HAVE_OPENIPMI
if (0 == strncmp(p, "IPMI", 4))
{
if (SUCCEED == (ret = parse_ipmi_command(p, &item.ipmi_sensor, &val)))
ret = set_ipmi_control_value(&item, val, error, sizeof(error));
ipmif=1;
}
else
{
#endif
zbx_snprintf(key, sizeof(key), "system.run[%s,nowait]", p);
alarm(CONFIG_TIMEOUT);
ret = get_value_agent(&item, &agent_result);
alarm(0);
#ifdef HAVE_OPENIPMI
}
#endif
}
DBfree_result(result);
free_result( &agent_result );
zabbix_log(LOG_LEVEL_DEBUG, "End run_remote_command(result:%d)",
ret);
}
Comment