Cacti / cacti

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

Template import may be blocked due to unmet dependency warnings with snmp ports #4378

Closed markrussinovichgithub closed 3 years ago

markrussinovichgithub commented 3 years ago

I'm trying to import (an old) Citrix Netscaler template on a fresh cacti install pulled from https://github.com/Cacti/cacti.git. This template works on a 0.8.8 cacti install. On recent versions it doesn't.

No warnings when doing a dry-run. But when actually installing, the following errors occur (sorry, the UI is in Dutch):

[succesvol] NetScaler - cacheMaxMemoryActiveKB [ongewijzigd]
   + Gevonden afhankelijkheden: (Data invoer methode) Get SNMP Data
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Privacy Protocol (v3)
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Privacy Passphrase (v3)
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Authenticaion Protocol (v3)
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Port
   + Gevonden afhankelijkheden: (Data invoer veld) OID
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Version (1, 2, or 3)
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Password
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Username
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP Community
   + Gevonden afhankelijkheden: (Data invoer veld) SNMP IP Address
   **+ Unmet Dependency: (Data invoer veld)**

(this happens multiple times)

And in logfile: CMDPHP Import Error: Import found an invalid dependency hash of :135a77685aa01abf1f6e752fe1e3c7f2. Please open bug on GitHub.

Here is the template: https://drive.google.com/file/d/1MH3hxS21LLkQe29Ad75pzTylwLCP1PJx/view?usp=sharing

Maybe the template is just too old. But i'd very much like to be able to use it on cacti 1.2 since it works flawlessly on 0.8, even with modern Netscalers V13.

TheWitness commented 3 years ago

I'll be taking a closer look at this to remove the bug of the unmet dependency. Several releases ago we put in some guardrails around the system data input method of "Get SNMP Data", where many templates had redefined the snmp_port multiple times. Unfortunately, by blocking the import of templates that attempted to corrupt the Data Input Method, we did not properly ignore the dependent objects that resulted as a part of the bypassing of the snmp_ports.

What that means is that even though you received dependency issues, the Template itself should have imported just fine none the less.

TheWitness commented 3 years ago

This issue is resolved. Note to fully utilize this fix, you have to update the following three files:

include/global_form.php
lib/html_form.php
lib/import.php
markrussinovichgithub commented 3 years ago

Thanks a lot. Dependency errors are gone now. Still getting an error though: _Sorry, we could not process your last action. SQL Save on table 'graph_templates': Column 'testsource' does not exist, unable to save!

Any thoughts on that?

TheWitness commented 3 years ago

You have to upgrade the schema. Look at install/upgrades/1_2_19.php and execute the column add.

TheWitness commented 3 years ago

You should really just grab the entire 1.2.x branch.

markrussinovichgithub commented 3 years ago

Thanks!! From end user perspective (meaning: running the import from the GUI), it seems to be OK now. However, during the import, a lot of entries in the logfile:

2021-09-27 10:38:09 - CMDPHP Import Error: Import found an invalid dependency hash of :135a77685aa01abf1f6e752fe1e3c7f2. Please open bug on GitHub. 2021-09-27 10:38:09 - 4 Import Error: Failed to insert into data_input_data table followed by a lot of:

2021-09-27 10:38:12 - CMDPHP PHP ERROR WARNING Backtrace: (/templates_import.php[48]:import(), /templates_import.php[127]:import_display_results(), /lib/import.php[2185]:array_search(), CactiErrorHandler())
2021-09-27 10:38:12 - ERROR PHP WARNING: array_search() expects parameter 2 to be array, string given in file: /var/www/html/cacti/lib/import.php on line: 2185

Can i safely ignore that?


Update: After adding some devices: seems like most of the graphs aren't plotted. Troubleshooting the data sources, it looks like 60% of the graphs have issues, e.g.: For attrbitute 'max', issue found 'RRD maximum for Data Source 'cacheBytesServed' should be '0'' After fixing the specific error with the suggestion: /usr/bin/rrdtool tune /var/www/html/cacti/rra/xxxxxxxxx_cachebytesserved_182.rrd --maximum cacheBytesServed:0 The error goes away, but the graph's aren't plotted/filled.