Cacti / cacti

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

Undefined indexes for html_form_template.php and html_form.php #3583

Closed jpobeda closed 4 years ago

jpobeda commented 4 years ago

Describe the bug

When I select to view a graph from an imported template I get a bunch of PHP Notice for different undefined indexes.

Not sure when this started to happen.

I'm putting them as they appear on its respective sections.

Supplemental Graph Template Data Notice: Undefined index: task_item_id in /usr/share/cacti/lib/html_form_template.php on line 180 Notice: Undefined index: task_item_id in /usr/share/cacti/lib/html_form_template.php on line 181

Data Source [prefixes] Notice: Undefined index: value in /usr/share/cacti/lib/html_form.php on line 461 Notice: Undefined index: value in /usr/share/cacti/lib/html_form.php on line 463

The last two repeat on every "Data Source" section.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Management/Devices

  2. Search device with graphs using this template

  3. Click to view

  4. All the errors appear on the form.

Expected behavior

No errors.

Cacti version: 1.2.11

cacti_graph_template_ebgpibgp_monitor.zip

I have attached the template exported in case it needs to be updated?

Let me know if you need additional info.

jpobeda commented 4 years ago

Forgot to add these


29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
--
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[463]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 463
29/May/2020 11:06:55 - CMDPHP PHP ERROR NOTICE Backtrace: (/graphs.php[116]:graph_edit(), /graphs.php[1576]:draw_nontemplated_fields_graph_item(), /lib/html_form_template.php[254]:draw_edit_form(), /lib/html_form.php[114]:draw_edit_control(), /lib/html_form.php[461]:CactiErrorHandler())
29/May/2020 11:06:55 - ERROR PHP NOTICE: Undefined index: value in file: /usr/share/cacti/lib/html_form.php on line: 461
netniV commented 4 years ago

Is this against 1.2.12 or 1.2.11?

netniV commented 4 years ago

Any change of a DB dump to developers@cacti.net so we can verify this?

jpobeda commented 4 years ago

Hi @netniV , this is 1.2.11.

I normally backup the db with the following command, would this do?

mysqldump -R -E --triggers --single-transaction --events --add-drop-table --databases $DBNAME

netniV commented 4 years ago

I do not normally have the extra options but it should be. Maybe without drop tables and database?

jpobeda commented 4 years ago

I'll re send it since I bounced back due to size limit.

TheWitness commented 4 years ago

Any updates on this guys?

TheWitness commented 4 years ago

Just looking at the error, this looks like it might be a plugin error. Basically, a form element has been passed to the form array without a matching 'value' type. It also appears not to follow one of the valid form types, as it's falling into the default: section of the case statement.

TheWitness commented 4 years ago

@jpobeda, that is a Data Query Graph Template. Can you please export the entire Data Query and include the 'resource' files when you upload it too.

TheWitness commented 4 years ago

I did a deep dive on that Data Query from back in the day 2010, and found that the export was damaged. I have an updated copy here. If you've created any graphs from it, you might want to:

  1. Backup the RRDfiles if they have good data
  2. Delete the Graphs
  3. Delete the Graph Template
  4. Re-import the Data Query below
  5. Re-create the graphs
  6. Restore the RRDfiles.
TheWitness commented 4 years ago

I'm not sure there is much more we can do with such an old Data Query but repair it. If this is enough, simply close this ticket. You might want to also update the forum post here:

https://forums.cacti.net/viewtopic.php?t=36770

Note that someone else may have fixed this along the way. Let me remove what I have done and test the more recent Data Query.

jpobeda commented 4 years ago

I sent the database to Mark to reproduce the issue.

That forum thread doesn't seem to contain any valuable info regarding this issue. I've never said it wasn't working. I've been for some time on 1.1.37 and these warnings never showed up so it's coming from one of the two latest updates I've done, either 1.2.10 and 1.2.11.

I'm happy to wait for Mark's comments.

cacti_data_query_ebgpibgp_monitor.zip

netniV commented 4 years ago

Hi JP.

I have your DB loaded and it’s presenting me with an interesting update issue with the installer so I’ve diverted my attention temporarily to that to see why I am suddenly getting it (though I suspect it is Related to the settings table).

Once I know what is going on there, I will swing back around to this one.

TheWitness commented 4 years ago

@jpobeda, I'm cool with that. Very busy anyway. Just trolling this morning.

TheWitness commented 4 years ago

@jpobeda,

Upload a screen shot of the Graph Item Inputs section of this Graph Template will you.

jpobeda commented 4 years ago

image

Do you want each individual item?

TheWitness commented 4 years ago

Nope, this is the exact problem I saw when I imported this Data Query from the original. There are two issues in the attached image, sourced from yours.

image

  1. You cna see that the second and third graphs items and legends have 'No Task', that means that there is no data source associated with them. My guess is that items 5-8 are 'received', then items 9-12 are 'sent'. You will have to fix this in one of two ways.

  2. The second part is that you have multiple entries for all three data sources. You must have only 1.

So, here is what you do.

  1. Edit the first received 'Graph Item Inputs', and check 5-7. Then press save.
  2. Edit the first 'send', and check items 8-12. Then press save.

At this point, you should see the 'No Tasks' changed to the real data source. Then, do the following.

  1. Edit each Graph Item Input, and if that Graph Item Input has no checks, remove it.

After you conduct all these steps, the template should be repaired. My guess is that you must of imported something that reverted the template to it's earlier state. We desperately need a project to certify all of the templates out on the forums and get the uploaded somewhere where the quality can be assured. Hopefully we can pull that off.

jpobeda commented 4 years ago

@TheWitness you seem to be onto something. I'll chuck another update later but yep seems that the whole template got really messed up. Is this something that happens from upgrade to upgrade somehow?

jpobeda commented 4 years ago

Yep, that was it. I first imported the template under 0.8.8h and it's been upgraded all the way and at some point got corrupted some how. Thanks for the help

TheWitness commented 4 years ago

Yep there are a number of jacked templates on the forums. We should delete/republish only the good ones.

jpobeda commented 4 years ago

Is there an https://github.com/Cacti/Community-templates coming soon?