Cacti / cacti

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

Graphs created with CLI only show NaN values #1318

Closed miguelangelcastellanos closed 6 years ago

miguelangelcastellanos commented 6 years ago

Hello,

I use CLI scripts to automate device, tree and graph creation. They worked fine with 0.8X versions of cacti.

When trying to use the same approach in Fedora 27 Server ( PHP 7.1 + CACTI 1.1.33 + Maria DB 10.2) graphs created using the GUI work fine, but if I create them using the CLI interface, only NaN values appear.

Here is an example of the commands I executed to create graphs:

/usr/bin/php add_device.php --description=cacti --ip=XXX --template=4 --version=1 --community=public --avail=snmp Adding cacti (169.254.6.9) as "Net-SNMP Device" using SNMP v1 with community "public" Success - new device-id: (5) /usr/bin/php poller_reindex_hosts.php --id=5 WARNING: Do not interrupt this script. Reindexing can take quite some time ..... Adding graph Net-SNMP - Load Average /usr/bin/php add_graphs.php --host-id=5 --graph-type=cg --graph-template-id=19 /usr/bin/php /var/www/cacti/cli/add_tree.php --tree-id=3 --type=node --graph-id=34 --parent-node=18 --node-type=graph Added Node node-id: (40)

Adding graphs Net-SNMP - CPU Utilization /usr/bin/php add_graphs.php --host-id=5 --graph-type=cg --graph-template-id=23 /usr/bin/php /var/www/cacti/cli/add_tree.php --tree-id=3 --type=node --graph-id=38 --parent-node=16 --node-type=graph Added Node node-id: (44)

But the resulting graph created this wat only shows NaN values:

image

The same happened to Memory, Disk or network graphs. but if I create the host and graphs manually using the GUI, everything works fine.

The cacti log file gave me no clue, the only weird thing I saw in the log is the following line, which repeats very frequently:

02/07/2018 14:30:02 - PHPSVR WARNING: PHP Script File to be included, does not exist 02/07/2018 14:30:02 - PHPSVR WARNING: Function does not exist INC: '' FUNC: '' PARMS: ''

Thanks a lot for your time and help.

Please let me know if you need any additional information.

Miguel

netniV commented 6 years ago

What are the differences when you do this either way? If you edit the graph, device, data sources for the device that works and the one that doesn't?

cigamit commented 6 years ago

In Cacti 1.x, if you have automation enabled, all Graph Template graphs will be created automatically. However, I do not understand how/why this is happening. The installer uses add_graphs.php and it's working just fine.

cigamit commented 6 years ago

I just tested with the exact two templates on a new install, and I can not reproduce this. Is this a system upgrade, or a new install? If an upgrade, please re-import the Net-SNMP device package using the 'import_package.php' script in the CLI directory and try again.

miguelangelcastellanos commented 6 years ago

Hello,

Thanks for your answers.

Best regards,

Miguel

cigamit commented 6 years ago

When manually creating graphs, the system will ask for the color due to the template setting, but the graph does have a default and the system will use the default when automation is used. So, that is a red herring. Have you imported the package yet and tried again?

miguelangelcastellanos commented 6 years ago

Hello,

Now I understand why you were unable to replicate the problem.

So my conclusions are:

So I guess there is some weird time depending behaviour in the graph creation code.

I hope this information helps to improve cacti.

Thanks a lot for your time and help.

Miguel

cigamit commented 6 years ago

Miguel,

The delay should have nothing to do with it. Once the CLI is returned to the user, all the db changes have been made. So, it has to be something else. Since everything is working for you now, I'll go ahead and close this in any event. Keep us posted if you find anything in the future that needs our attention. You can always open a separate ticket for that.

netniV commented 6 years ago

The only thought I had about this is that there could be a timing issue where the listing of a table for items is getting cross contaminated but if that was the case, we'd have issues with the GUI too.

cigamit commented 6 years ago

Right

michelle181991 commented 6 years ago

_Hi Miguel, may you please specified what directory/file in your statement "I solved the problem by executing a "sleep 30" command between each invocation to addgraphs.php"... I am still a newbie in cacti.. I am also encountering same problem..