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 :
PHP frontend :
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);
Comment