Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed Jan 23, 2019 11:36 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Fri Nov 16, 2018 6:02 am 
Offline

Joined: Fri Nov 16, 2018 5:18 am
Posts: 5
Hi.
After upgrading cacti from 0.8.8h to 1.1.38 (did the upgrade process with the help of this great article - https://www.cacti.net/downloads/docs/html/upgrade.html) the graph tree view is harrassed with this warning message:
Quote:
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in /var/www/cacti/lib/database.php on line 262


I am no good in PHP or actually in programming generally, so even though I looked into the file mentioned above, I was left with the bitter taste of defeat.
The odd thing is, that the message disappears while using other accounts. I tried to use different browsers, clear cache, nothing helped.

Thanks.


Last edited by HSE on Mon Dec 10, 2018 10:26 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Fri Nov 16, 2018 6:26 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 1946
There should be a stacktrace next to that error which shows the heirarchy of calls. Do you have that?

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Mon Nov 19, 2018 5:19 am 
Offline

Joined: Fri Nov 16, 2018 5:18 am
Posts: 5
netniV wrote:
There should be a stacktrace next to that error which shows the heirarchy of calls. Do you have that?


Thank you for your reply.
Is that it?
Quote:
11/19/2018 11:14:44 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_view.php: 191 top_graph_header)(/lib/functions.php: 3573 include)(/include/top_graph_header.php: 88 grow_dhtml_trees)(/lib/html_tree.php: 117 db_fetch_cell)(/lib/database.php: 234 db_fetch_cell_prepared)(/lib/database.php: 262 execute)(CactiErrorHandler)(/lib/functions.php: 4585 cacti_debug_backtrace)
11/19/2018 11:14:44 - ERROR PHP WARNING: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in file: /var/www/cacti/lib/database.php on line: 262


Last edited by HSE on Mon Dec 10, 2018 10:26 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Fri Dec 07, 2018 5:15 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 1946
Code:
$default_tree_id = db_fetch_cell('SELECT graph_tree.id
        FROM graph_tree
        INNER JOIN user_auth_perms ON user_auth_perms.item_id = graph_tree.id
        AND user_auth_perms.type = 2
        AND user_auth_perms.user_id = ?
        WHERE graph_tree.enabled = "on"
        ORDER BY graph_tree.id
        LIMIT 1',
        array($_SESSION['sess_user_id']));

So, this would appear to be the code that is failing. You should not be receiving the above error as the session should be logged in (ses_user_id is the logged in user). If session isn't set, check that the PHP Session module is actually installed/enabled for your web server.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Mon Dec 10, 2018 10:25 am 
Offline

Joined: Fri Nov 16, 2018 5:18 am
Posts: 5
I am running gentoo with PHP 5.6 (which I believe should be supported) and all of the required modules are installed (eg. mysql session sockets xml pcre snmp gd dom)

Not sure if you are familiar with gentoo but this is the PHP package compiled with all the necessary modules:
Code:
# equery u php
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
* Found these USE flags for dev-lang/php-5.6.39:
U I
...
+ + apache2             : Add Apache2 support
+ + gd                  : Adds support for gd (bundled with PHP)
+ + mysql               : Add mySQL Database support
+ + session             : Add persistent session support
+ + snmp                : Add support for the Simple Network Management Protocol if available
+ + sockets             : Add support for tcp/ip sockets
+ + xml                 : Add support for XML files
...

I followed cacti documentation: https://docs.cacti.net/manual:088:1_installation.1_install_unix.1_configure_php

The PHP-5.6 is then linked to apache2:
Code:
# eselect php list apache2
  [1]   php5.6 *


I noticed another error (repeated about two hundred times) every time poller (cmd.php) is called via cron:
Quote:

12/10/2018 15:50:53 - CMDPHP PHP ERROR NOTICE Backtrace: (/clog.php: 39 clog_view_logfile)(/lib/clog_webapi.php: 284 preg_replace_callback)(clog_regex_parser)(/lib/clog_webapi.php: 598 call_user_func_array)(clog_regex_datasource)(/lib/clog_webapi.php: 664 clog_get_datasource_titles)(/lib/clog_webapi.php: 33 get_data_source_title)(/lib/functions.php: 1345 expand_title)(/lib/variables.php: 135 substitute_host_data)(/lib/variables.php: 237 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace)
12/10/2018 15:50:53 - ERROR PHP NOTICE: Undefined index: external_id in file: /var/www/cacti/lib/variables.php on line: 237


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Tue Dec 11, 2018 12:46 pm 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 1946
That error is not actually the poller, but whenever you try to view the logs via Cacti. It is claiming that $external_id is not set, which seems to be causing a problem when attempting to convert one of the matched regex values back to a name. Something isn't quite right with the setup, I'm just can't see yet what it would be.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Wed Dec 12, 2018 7:10 am 
Offline

Joined: Fri Nov 16, 2018 5:18 am
Posts: 5
netniV wrote:
That error is not actually the poller, but whenever you try to view the logs via Cacti. It is claiming that $external_id is not set, which seems to be causing a problem when attempting to convert one of the matched regex values back to a name. Something isn't quite right with the setup, I'm just can't see yet what it would be.


Where can I set this $external_id if it is some part of a variable which I can set?
And can I deliver some more information to you that could help determine the problem?


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Wed Dec 12, 2018 7:49 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 1946
Do me a favour, in MySQL do a "desc host" for me? I suspect you don't have the external_id column.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Thu Dec 13, 2018 10:34 am 
Offline

Joined: Fri Nov 16, 2018 5:18 am
Posts: 5
Code:
MariaDB [cacti]> desc host;
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
| Field                  | Type                  | Null | Key | Default             | Extra                       |
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
| id                     | mediumint(8) unsigned | NO   | PRI | NULL                | auto_increment              |
| poller_id              | int(10) unsigned      | NO   | MUL | 1                   |                             |
| site_id                | int(10) unsigned      | NO   | MUL | 1                   |                             |
| host_template_id       | mediumint(8) unsigned | NO   |     | 0                   |                             |
| description            | varchar(150)          | NO   |     |                     |                             |
| hostname               | varchar(100)          | YES  | MUL |                     |                             |
| notes                  | text                  | YES  |     | NULL                |                             |
| external_id            | varchar(40)           | YES  | MUL | NULL                |                             |
| snmp_community         | varchar(100)          | YES  |     | NULL                |                             |
| snmp_version           | tinyint(1) unsigned   | NO   |     | 1                   |                             |
| snmp_username          | varchar(50)           | YES  |     | NULL                |                             |
| snmp_password          | varchar(50)           | YES  |     | NULL                |                             |
| snmp_auth_protocol     | char(6)               | YES  |     |                     |                             |
| snmp_priv_passphrase   | varchar(200)          | YES  |     |                     |                             |
| snmp_priv_protocol     | char(6)               | YES  |     |                     |                             |
| snmp_context           | varchar(64)           | YES  |     |                     |                             |
| snmp_engine_id         | varchar(64)           | YES  |     |                     |                             |
| snmp_port              | mediumint(5) unsigned | NO   |     | 161                 |                             |
| snmp_timeout           | mediumint(8) unsigned | NO   |     | 500                 |                             |
| snmp_sysDescr          | varchar(300)          | NO   |     |                     |                             |
| snmp_sysObjectID       | varchar(128)          | NO   |     |                     |                             |
| snmp_sysUpTimeInstance | int(10) unsigned      | NO   |     | 0                   |                             |
| snmp_sysContact        | varchar(300)          | NO   |     |                     |                             |
| snmp_sysName           | varchar(300)          | NO   |     |                     |                             |
| snmp_sysLocation       | varchar(300)          | NO   |     |                     |                             |
| availability_method    | smallint(5) unsigned  | NO   |     | 2                   |                             |
| ping_method            | smallint(5) unsigned  | YES  |     | 0                   |                             |
| ping_port              | int(12) unsigned      | YES  |     | 0                   |                             |
| ping_timeout           | int(12) unsigned      | YES  |     | 500                 |                             |
| ping_retries           | int(12) unsigned      | YES  |     | 2                   |                             |
| max_oids               | int(12) unsigned      | YES  |     | 10                  |                             |
| device_threads         | tinyint(2) unsigned   | NO   |     | 1                   |                             |
| disabled               | char(2)               | YES  | MUL |                     |                             |
| thold_send_email       | int(10)               | NO   |     | 1                   |                             |
| thold_host_email       | int(10)               | NO   |     | NULL                |                             |
| status                 | tinyint(2)            | NO   | MUL | 0                   |                             |
| status_event_count     | mediumint(8) unsigned | NO   |     | 0                   |                             |
| status_fail_date       | timestamp             | NO   |     | 0000-00-00 00:00:00 |                             |
| status_rec_date        | timestamp             | NO   |     | 0000-00-00 00:00:00 |                             |
| status_last_error      | varchar(255)          | YES  |     | NULL                |                             |
| min_time               | decimal(10,5)         | YES  |     | 9.99999             |                             |
| max_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| cur_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| avg_time               | decimal(10,5)         | YES  |     | 0.00000             |                             |
| polling_time           | double                | YES  |     | 0                   |                             |
| total_polls            | int(12) unsigned      | YES  |     | 0                   |                             |
| failed_polls           | int(12) unsigned      | YES  |     | 0                   |                             |
| availability           | decimal(8,5)          | NO   |     | 100.00000           |                             |
| last_updated           | timestamp             | NO   |     | CURRENT_TIMESTAMP   | on update CURRENT_TIMESTAMP |
+------------------------+-----------------------+------+-----+---------------------+-----------------------------+
49 rows in set (0.01 sec)


Unfortunately I do...


Top
 Profile  
 
 Post subject: Re: Warning: PDOStatement::execute(): SQLSTATE[HY093]:
PostPosted: Fri Dec 14, 2018 8:07 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 1946
Then something is preventing your from being able to read the data... at least for that host if it's only one host.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 9 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:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group