Ad Widget

Collapse

1.6.4 IPMI support and nasty bug fix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BrandStorm
    Junior Member
    • May 2009
    • 7

    #1

    1.6.4 IPMI support and nasty bug fix

    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
    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);
    }
    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.
    Attached Files
  • BrandStorm
    Junior Member
    • May 2009
    • 7

    #2
    Hello Alexei and team.
    I've noticed, that only bug fix was included in 1.6.5. The rest of patch was excluded. Is there any reason for this???
    You still prefer to store IPMI address in DNS/IP field instead of dedicated one???

    Comment

    • Coiscacrikila
      Junior Member
      • Aug 2009
      • 1

      #3
      1 6 4 IPMI support and nasty bug fix

      I updated the patch to fix a small bug in VDI_probe and change the "VDI" format string to lower-case when I was at it.
      Also I found out, that this patch allows qemu and KVM to directly access VirtualBox Disk Images natively - i.e. just run the OS within.

      Comment

      • Alexei
        Founder, CEO
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2004
        • 5654

        #4
        Originally posted by BrandStorm
        You still prefer to store IPMI address in DNS/IP field instead of dedicated one???
        IPMI address is kept in a separate database field in pre-1.8. We cannot make this change in 1.6.x.
        Alexei Vladishev
        Creator of Zabbix, Product manager
        New York | Tokyo | Riga
        My Twitter

        Comment

        Working...