Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.65k stars 406 forks source link

Undefined index: id in lib/functions.php #4309

Closed jdcoats closed 3 years ago

jdcoats commented 3 years ago
2021/06/16 14:46:41 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php[116]:host_reload_query(), /host.php[574]:run_data_query(), /lib/data_query.php[390]:automation_execute_data_query(), /lib/api_automation.php[2206]:create_dq_graphs(), /lib/api_automation.php[2618]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
--
2021/06/16 14:46:41 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
netniV commented 3 years ago

Hi @jdcoats,

Just to clarify, which version of lib/functions is this? There have been a few changes recently.

If you don't have the latest version, please update and see if the problem persists.

jdcoats commented 3 years ago

This started yesterday when i grabbed those recent updates you did. :) It happens when creating graphs.

2021/06/17 09:07:29 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php[116]:host_reload_query(), /host.php[574]:run_data_query(), /lib/data_query.php[390]:automation_execute_data_query(), /lib/api_automation.php[2206]:create_dq_graphs(), /lib/api_automation.php[2618]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1950]:CactiErrorHandler())
--
2021/06/17 09:07:29 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1950
netniV commented 3 years ago

If you can replicate it for a specific graph creation, uncomment the line in the dsv_log function, then look for "SCRIPT field" in the logs. That should show what fields it is finding (possible that I have to use a different key within that field structure).

jdcoats commented 3 years ago

its any graph, give me a sec..

jdcoats commented 3 years ago

Here is the whole thing, trying to create a single graph.

2021/06/17 10:49:25 - DSV SNMP_QUERY [updated] host = {"id":"2794","poller_id":"1","site_id":"1","host_template_id":"87","description":"SFTP01","hostname":"10.1.2.45","location":"","notes":"","external_id":"","snmp_community":"mystring","snmp_version":"2","snmp_username":"","snmp_password":"","snmp_auth_protocol":"","snmp_priv_passphrase":"","snmp_priv_protocol":"","snmp_context":"","snmp_engine_id":"","snmp_port":"161","snmp_timeout":"2000","snmp_sysDescr":"","snmp_sysObjectID":"","snmp_sysUpTimeInstance":"555623","snmp_sysContact":"","snmp_sysName":"","snmp_sysLocation":"","availability_method":"1","ping_method":"1","ping_port":"23","ping_timeout":"400","ping_retries":"1","max_oids":"10","bulk_walk_size":"-1","device_threads":"1","deleted":"","disabled":"","monitor":"on","monitor_text":"","monitor_criticality":"0","monitor_warn":"0","monitor_alert":"0","thold_send_email":"0","thold_host_email":"0","thold_failure_count":"0","status":"3","status_event_count":"0","status_fail_date":"0000-00-00 00:00:00","status_rec_date":"0000-00-00 00:00:00","status_last_error":"","min_time":"1.59597","max_time":"345.83151","cur_time":"17.71307","avg_time":"22.00155","polling_time":"0.255","total_polls":"87","failed_polls":"0","availability":"100.00000","last_updated":"2021-06-17 10:49:06"}
--
2021/06/17 10:49:25 - DSV SNMP_QUERY [updated] host_fields = []
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_priv_protocol","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_priv_passphrase","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_auth_protocol","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_port","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_version","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_password","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_username","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_community","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"hostname","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_username","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"snmp_community","value":""}
2021/06/17 10:49:25 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs_new.php[42]:form_save(), /graphs_new.php[150]:html_graph_new_graphs(), /lib/html_graph.php[465]:host_new_graphs_save(), /graphs_new.php[243]:create_save_graph(), /lib/template.php[1752]:test_data_sources(), /lib/functions.php[1599]:test_data_source(), /lib/functions.php[1859]:CactiErrorHandler())
2021/06/17 10:49:25 - ERROR PHP NOTICE: Undefined index: id in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1859
2021/06/17 10:49:25 - DSV SNMP_QUERY field = {"type_code":"hostname","value":""}
2021/06/17 10:49:25 - DSV SNMP_QUERY data_template_data = [{"type_code":"hostname","value":""},{"type_code":"snmp_community","value":""},{"type_code":"snmp_username","value":""},{"type_code":"hostname","value":""},{"type_code":"snmp_community","value":""},{"type_code":"snmp_username","value":""},{"type_code":"snmp_password","value":""},{"type_code":"snmp_version","value":""},{"type_code":"snmp_port","value":""},{"type_code":"snmp_auth_protocol","value":""},{"type_code":"snmp_priv_passphrase","value":""},{"type_code":"snmp_priv_protocol","value":""}]
2021/06/17 10:49:25 - DSV SNMP_QUERY host_fields = []
2021/06/17 10:49:25 - DSV outputs = [{"snmp_field_name":"ifHCInOctets","data_template_rrd_id":"2"},{"snmp_field_name":"ifInOctets","data_template_rrd_id":"2"},{"snmp_field_name":"ifHCOutOctets","data_template_rrd_id":"3"},{"snmp_field_name":"ifOutOctets","data_template_rrd_id":"3"}]
2021/06/17 10:49:25 - DSV outputs_params = ["2"]
2021/06/17 10:49:25 - DSV outputs_sql = SELECT DISTINCT SQL_NO_CACHE sqgr.snmp_field_name, dtr.id as data_template_rrd_id FROM snmp_query_graph_rrd AS sqgr INNER JOIN data_template_rrd AS dtr FORCE INDEX (local_data_id) ON sqgr.data_template_rrd_id = dtr.id WHERE sqgr.data_template_id = ? AND dtr.local_data_id = 0 ORDER BY dtr.id
2021/06/17 10:49:25 - DSV query field = {"index_type":"","index_value":"","output_type":""}
2021/06/17 10:49:25 - DSV host = {"id":"2794","poller_id":"1","site_id":"1","host_template_id":"87","description":"SFTP01","hostname":"10.1.2.45","location":"","notes":"","external_id":"","snmp_community":"mystring","snmp_version":"2","snmp_username":"","snmp_password":"","snmp_auth_protocol":"","snmp_priv_passphrase":"","snmp_priv_protocol":"","snmp_context":"","snmp_engine_id":"","snmp_port":"161","snmp_timeout":"2000","snmp_sysDescr":"","snmp_sysObjectID":"","snmp_sysUpTimeInstance":"555623","snmp_sysContact":"","snmp_sysName":"","snmp_sysLocation":"","availability_method":"1","ping_method":"1","ping_port":"23","ping_timeout":"400","ping_retries":"1","max_oids":"10","bulk_walk_size":"-1","device_threads":"1","deleted":"","disabled":"","monitor":"on","monitor_text":"","monitor_criticality":"0","monitor_warn":"0","monitor_alert":"0","thold_send_email":"0","thold_host_email":"0","thold_failure_count":"0","status":"3","status_event_count":"0","status_fail_date":"0000-00-00 00:00:00","status_rec_date":"0000-00-00 00:00:00","status_last_error":"","min_time":"1.59597","max_time":"345.83151","cur_time":"17.71307","avg_time":"22.00155","polling_time":"0.255","total_polls":"87","failed_polls":"0","availability":"100.00000","last_updated":"2021-06-17 10:49:06"}
2021/06/17 10:49:25 - DSV data_input = {"id":"2","type_id":"3","data_template_data_id":"2","data_template_id":"2","active":"on","rrd_step":"60","name":"Get SNMP Data (Indexed)"}
2021/06/17 10:49:25 - DSV test_data_source = {"data_template_id":"2","host_id":2794,"snmp_query_id":1,"snmp_index":"11","suggested_vals":[]}
netniV commented 3 years ago

OK so I think I can see what the issue is here. It's using a different way of mentioning the fields. Let me see if I can fix that up for you.

netniV commented 3 years ago

Nope, something more simple, I forgot to add the id field to the other SQL queries so they can actually find the field.

netniV commented 3 years ago

See if this helps resolve things.

jdcoats commented 3 years ago

thanks! looks good.