Cactiusers.org


It is currently Thu May 17, 2012 8:49 am




Post new topic Reply to topic  [ 7 posts ] 
 Discovery 0.8.5 fails REPLACE INTO 
Author Message
New User

Joined: Wed Mar 18, 2009 12:30 am
Posts: 10
Post Discovery 0.8.5 fails REPLACE INTO
Cacti 0.8.7d, PIA 2.4, Discovery 0.8.5.

Noticed that every hour (the polling interval for discovery), the following type of errors are logged:
Quote:
CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1136', SQL:"REPLACE INTO plugin_discover_hosts (hostname, ip, hash, community, snmp_version, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, sysName, sysLocation, sysContact, sysDescr, sysUptime, os, snmp, up, time) VALUES ('', '10.10.50.40', '168440360', '', '1', '', '', '', '', '', '', '', '', '', '', '', 0, '', 0, 1,1237353356)'

Manually running that command results in:
ERROR 1136 (21S01): Column count doesn't match value count at row 1
Yet, in the Discovery tab, I see the list of all the switches/routers which have been found, full information filled out. I've tried clearing the discovery cache, but the errors still persist.

What gives?

Also, a future version of discovery going to take into account the global CActi SNMP version/community/etc settings?


Wed Mar 18, 2009 12:38 am
New User

Joined: Thu Mar 19, 2009 12:33 pm
Posts: 3
Post Re: Discovery 0.8.5 fails REPLACE INTO
As the error states, its a sql error. If you notice not all your values are quoted around. That's causing the error.

I'm working on this now to create a patch. Once I have one I'll submit it to the bugtracker with a patch.

Basically the row's time, up, os are not quoted correctly even and that's causing the column count errors your seeing in cacti logs and in the manual running.


Thu Mar 19, 2009 12:39 pm
New User

Joined: Thu Mar 19, 2009 12:33 pm
Posts: 3
Post Re: Discovery 0.8.5 fails REPLACE INTO
Well I'd submit a bug..but apparently the sql table for mantis is dead on here too..

So if you do a patch -p0 < patch findhosts.php. This should take care of the issue. It modifies how things are quoted. It seems to work for me at least.


Erm, might want to hold off on it. It works fine for linux hosts..Not working for windows host currently....(just tested that)

I'll work on it some more and hope to have a better patch ready soon.


Thu Mar 19, 2009 2:14 pm
New User

Joined: Thu Mar 19, 2009 12:33 pm
Posts: 3
Post Re: Discovery 0.8.5 fails REPLACE INTO
okie this one appears to work better (doesn't throw errors on hosts that take the if not the else path now)

Sorry about that. If you grabbed the other one. Just redownload the discovery plugin and cp the findhosts.php and reapply this new patch.

I ran it through all my hosts and didn't get any errors for windows or linux this time.

Attachment:
patch.txt [988 Bytes]
Downloaded 315 times


This second patch adds the description into the description field automatically from your FQDN gathered from the dns lookup. It needs some work as well..as it seems to right now automatically add the host without your input at that point in the submit. I've not worked on it to not do that yet. But I'd rather have everything added for me then having to add the description myself...consider myself lazy =)
Attachment:
dd_description.txt [639 Bytes]
Downloaded 180 times


Thu Mar 19, 2009 3:11 pm
New User

Joined: Tue Apr 14, 2009 2:24 pm
Posts: 1
Post Re: Discovery 0.8.5 fails REPLACE INTO
The problem is in findhosts.php around line 377. There are 2 duplicate lines. Remove one of them.
=====================
db_execute("REPLACE INTO plugin_discover_hosts (hostname, ip, hash, community, snmp_version, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, sysName, sysLocation, sysContact, sysDescr, sysUptime, os, snmp, up, time) VALUES ('"
. sql_sanitize($device['dnsname'])
. "', '$host', '"
. $device['hash'] . "', '"
. sql_sanitize($device['community']) . "', '"
. sql_sanitize($device['snmp_version']) . "', '"
. sql_sanitize($device['snmp_username']) . "', '"
. sql_sanitize($device['snmp_password']) . "', '"
. sql_sanitize($device['snmp_auth_protocol']) . "', '"
. sql_sanitize($device['snmp_priv_passphrase']) . "', '"
. sql_sanitize($device['snmp_priv_protocol']) . "', '"
. sql_sanitize($device['snmp_context']) . "', '"
. sql_sanitize($device['snmp_sysName']) . "', '"
. sql_sanitize($device['snmp_sysName']) . "', '"

. sql_sanitize($device['snmp_sysLocation']) . "', '"
. sql_sanitize($device['snmp_sysContact']) . "', '"
. sql_sanitize($device['snmp_sysDescr']) . "', '"
. sql_sanitize($device['snmp_sysUptime']) . "'"
. ",'0','1','" .time() . "')");
=====================


Tue Apr 14, 2009 2:29 pm
Site Admin

Joined: Thu Nov 11, 2004 11:12 am
Posts: 2007
Post Re: Discovery 0.8.5 fails REPLACE INTO
Fixed the duplicate entry in SVN.
As for the hostname patch, this is left out on purpose, since with Cacti, it is going to automatically add the device without your input if if it added.

Quote:
As the error states, its a sql error. If you notice not all your values are quoted around. That's causing the error.
Integer values do not require quotes around them.


Wed May 20, 2009 11:19 am
New User

Joined: Tue Jun 02, 2009 5:49 pm
Posts: 1
Post Re: Discovery 0.8.5 fails REPLACE INTO
Hi guys,

My findhosts.php keep giving SQL errors:

06/02/2009 07:04:44 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1136', SQL:"REPLACE INTO plugin_discover_hosts (hostname, ip, hash, community, snmp_version, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, sysName, sysLocation, sysContact, sysDescr, sysUptime, os, snmp, up, time) VALUES ('CI-BIBLIO-01', '172.16.51.1', '2886742785', '', '1', '', '', '', '', '', '', '', '', '', '', '0','0','1','1243987484')'
06/02/2009 07:04:45 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1136', SQL:"REPLACE INTO plugin_discover_hosts (hostname, ip, hash, community, snmp_version, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, sysName, sysLocation, sysContact, sysDescr, sysUptime, os, snmp, up, time) VALUES ('CI-BIBLIO-02', '172.16.51.2', '2886742786', '', '1', '', '', '', '', '', '', '', '', '', '', '0','0','1','1243987485')'

Analyzing the findhosts.php I've found another error: after 'snmp_sysUptime', it needs the value of 'os', witch is not delivered at line 392, because there is one missing SQL parameter.

The fix would be the following:

- . sql_sanitize($device['snmp_sysDescr']) . "', "
- . sql_sanitize($device['snmp_sysUptime']) . ", "
- . "'', 0, 1,".time() . ')' );
+ . sql_sanitize($device['snmp_sysDescr']) . "', '"
+ . sql_sanitize($device['snmp_sysUptime']) . "', '"
+ . sql_sanitize($device['os']) . "', "
+ . "'0','1','" .time() . "')");


Tue Jun 02, 2009 6:08 pm
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: