PDA

View Full Version : Error in query (Configuration-Graphs)


west
13-09-2007, 04:39
Hi all,

I got an error when I choose Configuration -> Graphs -> Group [all] -> Host [all]. I am using Zabbix 1.4.2 on Ubuntu 7. If I choose a specific host, no errors prompted. Any idea?

Error in query [select distinct g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid left join items i on gi.itemid=i.itemid while (g.graphid div 100000000000000) in (0) and ( i.hostid not in (-1) OR i.hostid is NULL ) order by g.name, g.graphid] [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'while (g.graphid div 100000000000000) in (0) and ( i.hostid not in (-1) OR i.' at line 1]

jacob.hamacher
13-09-2007, 09:39
I experience the same bug over here as well.

I use FreeBSD 6.2 and Zabbix 1.4.2 with mysql 5.0.45. Both are installed from ports.

/jacob

eli.stair
28-09-2007, 02:30
NOTE: this looks like it might be related to another bug in this code:

http://www.zabbix.com/forum/showthread.php?t=7955&highlight=error+query

Running on RHEL5 x86_64, configured as :

./configure --prefix=/usr/local/zabbix --with-ldap --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl

Running mysql 5.0.22 on a separate machine, all rights/perms correct and all other functions seemingly OK (fresh 1.4.2 install, no hosts added yet).

Looks like an incorrectly formed query, that's an easy statement to make since the error gives that much up ;) IANADBA, so... the query is more complex than I can make sense of without lunch, reading, and digging through the tables and source. However, stripping out the section of the query that causes it to choke results in data returning anyhow:

select distinct g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid left join items i on gi.itemid=i.itemid order by g.name, g.graphid;

It appears that this query is formed in graphs.php, line 348, run if hostid>0:

if($_REQUEST["hostid"] > 0)
{
$result = DBselect("select distinct g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
" left join items i on gi.itemid=i.itemid ".
" where i.hostid=".$_REQUEST["hostid"].
" and i.hostid not in (".$denyed_hosts.") ".
' and '.DBin_node('g.graphid').
" and i.hostid is not NULL ".
" order by g.name, g.graphid");
}
else
{
$result = DBselect("select distinct g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
" left join items i on gi.itemid=i.itemid ".
' while '.DBin_node('g.graphid').
" and ( i.hostid not in (".$denyed_hosts.") OR i.hostid is NULL )".
" order by g.name, g.graphid");
}



Hopefully this will be enough to go on for someone else to fix the problem, else I'll have to get back around to digging into it when I get time.

;)

Cheers,

/eli

nelsonab
04-10-2007, 01:55
I just had this problem on a fresh install myself.

I changed the 'while' on line 348 in graphs.php to 'where' and it works for me.

I'm running 1.4.2