Ad Widget

Collapse

Zabbix 1.4.3, Postgres 8.3 : patches

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbarthelemy
    Junior Member
    • Nov 2007
    • 7

    #1

    Zabbix 1.4.3, Postgres 8.3 : patches

    Hi all,

    Having encountered problems with zabbix 1.4.3 and Postgres 8.3, I finally managed to find what was wrong.
    In a few words, Postgres 8.3 is much more strict with comparisons, and does not allow anymore, for exemple, checking if int=varchar, or bigint=text, etc... Instead you need to make explicit casts to convert everything to string/varchar before comparing the values.

    This causes a lot of trouble to zabbix_server (it always crashes) and PHP frontend.

    I already made a post yesterday about this issue, but it has disappeared (?).

    So here are the patches.
    Alexei, is there any chance that these patches get merged in the official Zabbix code? Are you interested if I post patches with the same goal for zabbix 1.4.4 or for current 1.6?

    C source code :
    Code:
    diff -ruB zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/history.c zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/history.c
    --- zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/history.c   2007-12-12 17:42:32.000000000 +0100
    +++ zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/history.c        2007-12-18 11:16:36.000000000 +0100
    @@ -87,7 +87,7 @@
                    ZBX_DM_DELIMITER,
                    nodeid);
    
    -       zbx_snprintf(sql,sizeof(sql),"select id,itemid,clock,timestamp,source,severity,value,length( CAST(value AS varchar) ) from history_log where id>"ZBX_FS_UI64" and "ZBX_COND_NODEID" order by id",
    +       zbx_snprintf(sql,sizeof(sql),"select id,itemid,clock,timestamp,source,severity,value,length(value) from history_log where id>"ZBX_FS_UI64" and "ZBX_COND_NODEID" order by id",
                    sync_lastid,
                    ZBX_NODE("id", nodeid));
    Code:
    diff -ruB zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/nodesender.c zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/nodesender.c
    --- zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/nodesender.c        2007-12-12 17:44:26.000000000 +0100
    +++ zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/nodesender.c     2007-12-18 11:16:36.000000000 +0100
    @@ -125,10 +125,15 @@
                            {
                                    zbx_strlcat(fields,tables[i].fields[j].name,sizeof(fields));
                                    zbx_strlcat(fields,",",sizeof(fields));
    +#if defined(HAVE_POSTGRESQL)
    +                               zbx_strlcat(fields,"length(CAST(",sizeof(fields));
    +                               zbx_strlcat(fields,tables[i].fields[j].name,sizeof(fields));
    +                                zbx_strlcat(fields," AS text)),",sizeof(fields));
    +#else
                                    zbx_strlcat(fields,"length(",sizeof(fields));
                                    zbx_strlcat(fields,tables[i].fields[j].name,sizeof(fields));
    -                               zbx_strlcat(fields,"),",sizeof(fields));
    +                                zbx_strlcat(fields,"),",sizeof(fields));
    +#endif
                            }
                            if(fields[0]!=0)        fields[strlen(fields)-1]=0;

    Code:
    diff -ruB zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/nodewatcher.c zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/nodewatcher.c
    --- zabbix-1.4.3_orig/src/zabbix_server/nodewatcher/nodewatcher.c       2007-12-12 11:00:06.000000000 +0100
    +++ zabbix-1.4.3_patched/src/zabbix_server/nodewatcher/nodewatcher.c    2007-12-18 11:16:36.000000000 +0100
    @@ -120,8 +120,12 @@
                                    }
                                    else
                                    {
    -                                       zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 128, "coalesce(%s,'1234567890')||",
    -                                               tables[i].fields[j].name);
    +       #if defined(HAVE_POSTGRESQL)
    +                                       zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 128, "coalesce(CAST(%s AS varchar),'1234567890')||",
    +       #else
    +                                       zbx_snprintf_alloc(&sql, &sql_allocated, &sql_offset, 128, "coalesce(%s, '1234567890')||",
    +       #endif
    +                                       tables[i].fields[j].name);
                                    }
     #endif
                                    j++;

    PHP frontend :

    Code:
    diff -ruB zabbix-1.4.3_orig/frontends/php/include/hosts.inc.php /data/www/zabbix/include/hosts.inc.php
    --- zabbix-1.4.3_orig/frontends/php/include/hosts.inc.php       2007-12-12 11:00:12.000000000 +0100
    +++ /data/www/zabbix/include/hosts.inc.php      2007-12-18 17:55:03.000000000 +0100
    @@ -454,14 +454,14 @@
    
            // disable actions
                    $db_actions = DBselect("select distinct actionid from conditions ".
    -                       " where conditiontype=".CONDITION_TYPE_HOST." and value=".$hostid);
    +                       " where conditiontype=".CONDITION_TYPE_HOST." and value='".$hostid."'");
                    while($db_action = DBfetch($db_actions))
                    {
                            DBexecute("update actions set status=".ACTION_STATUS_DISABLED.
                                    " where actionid=".$db_action["actionid"]);
                    }
            // delete action conditions
    -               DBexecute('delete from conditions where conditiontype='.CONDITION_TYPE_HOST.' and value='.$hostid);
    +               DBexecute("delete from conditions where conditiontype=".CONDITION_TYPE_HOST." and value='".$hostid."'");
    
            // delete host profile
                    delete_host_profile($hostid);
    Code:
    diff -ruB zabbix-1.4.3_orig/frontends/php/include/triggers.inc.php /data/www/zabbix/include/triggers.inc.php
    --- zabbix-1.4.3_orig/frontends/php/include/triggers.inc.php    2007-12-12 11:00:12.000000000 +0100
    +++ /data/www/zabbix/include/triggers.inc.php   2007-12-18 17:50:37.000000000 +0100
    @@ -1346,14 +1346,14 @@
    
            // disable actions
                    $db_actions = DBselect("select distinct actionid from conditions ".
    -                       " where conditiontype=".CONDITION_TYPE_TRIGGER." and value=".$triggerid);
    +                       " where conditiontype=".CONDITION_TYPE_TRIGGER." and value='".$triggerid."'");
                    while($db_action = DBfetch($db_actions))
                    {
                            DBexecute("update actions set status=".ACTION_STATUS_DISABLED.
                                    " where actionid=".$db_action["actionid"]);
                    }
            // delete action conditions
    -               DBexecute('delete from conditions where conditiontype='.CONDITION_TYPE_TRIGGER.' and value='.$triggerid);
    +               DBexecute("delete from conditions where conditiontype=".CONDITION_TYPE_TRIGGER." and value='".$triggerid."'");
    
                    $trigger = get_trigger_by_triggerid($triggerid);
  • milprog
    Junior Member
    • Jul 2007
    • 27

    #2
    same problem with 1.4.4

    I'm using postgresql 8.3beta2 too in a test environment on centos 5.1 running on a ML110 server; zabbix performs somewhat better than with postgresql 8.2. My database has grown to 14GB within about 60 days now, but it is still quite responsive.
    Today I created RPMs for 1.4.4 and installed them; obviously the patches are still needed. I would much appreciate if you could make them available again for 1.4.4 .

    Perhaps alexej wants to wait until 8.3 is released, but I think this problem will remain the same.

    Regards
    --Marcel

    Comment

    • mbarthelemy
      Junior Member
      • Nov 2007
      • 7

      #3
      same problem with 1.4.4

      Hi Marcel,

      Yes, I will make patches for 1.4.4, probably next week (after christmas).

      Alexei and Zabbix team, could you tell us if you would like to merge these patches? Or would like me to update them for 1.6?

      Comment

      • Aly
        ZABBIX developer
        • May 2007
        • 1126

        #4
        It's up to Alexei to decide, but I think changes will be made as soon as pgsql8.3 will be released(and installed)
        Zabbix | ex GUI developer

        Comment

        Working...