Cacti / cacti

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

Cacti 1.2.18 Cannot create graphs due to bad data #4377

Closed jdcoats closed 3 years ago

jdcoats commented 3 years ago
2021/08/24 16:03:02 - 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[1723]:CactiErrorHandler())
2021/08/24 16:03:02 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
2021/08/24 16:03:02 - 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[1723]:CactiErrorHandler())
2021/08/24 16:03:02 - ERROR PHP NOTICE: Undefined index: cg in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723

GraphsBadData

jdcoats commented 3 years ago

I presume this is the same as #4250, #4323 & #4352 but not completely resolved?

jdcoats commented 3 years ago

I can reproduce with other datasources/templates also with reference to functions.php on line: 1786 also

2021/08/24 17:04:09 - 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[1723]:test_data_sources(), /lib/functions.php[1727]:test_data_source(), /lib/functions.php[1786]:CactiErrorHandler())
2021/08/24 17:04:09 - ERROR PHP NOTICE: Trying to access array offset on value of type int in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1786
2021/08/24 17:04:09 - 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[1723]:CactiErrorHandler())
2021/08/24 17:04:09 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
2021/08/24 17:04:09 - 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[1723]:CactiErrorHandler())
2021/08/24 17:04:09 - ERROR PHP NOTICE: Undefined index: cg in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
2021/08/24 17:03:56 - AUTOM8 NOTE: Device[AES01], GT[Host MIB - Total App Memory] Graph not added due to invalid data source output.
2021/08/24 17:03:56 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php[76]:host_add_gt(), /host.php[607]:automation_hook_graph_template(), /lib/api_automation.php[2127]:automation_execute_graph_template(), /lib/api_automation.php[2351]:test_data_sources(), /lib/functions.php[1727]:test_data_source(), /lib/functions.php[1786]:CactiErrorHandler())
2021/08/24 17:03:56 - ERROR PHP NOTICE: Trying to access array offset on value of type int in file: /var/www/localhost/htdocs/cacti/lib/functions.php on line: 1786
netniV commented 3 years ago

This may have been fixed already because that line of code in the current lib/functions.php is a blank line. If you save a copy of your lib/functions.php and try the latest one from 1.2.x branch, see if the issue persists?

jdcoats commented 3 years ago

Cacti is up to date as of yesterday :)

2021/08/31 09:16:20 - 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[1723]:CactiErrorHandler())
2021/08/31 09:16:20 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
2021/08/31 09:16:20 - 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[1723]:CactiErrorHandler())
2021/08/31 09:16:20 - ERROR PHP NOTICE: Undefined index: cg in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
underdog-Fu commented 3 years ago

Hi Br I tried to update the latest version , when I create a graph(such as "Net-SNMP - CPU Utilization" ), the feedback is as follows image But,there is no error message in the catic.log best wishes

xmacan commented 3 years ago

Try run snmp command: snmpwalk -v2c -c community host_ip .1.3.6.1.4.1.2021.4.5.0 Will the device respond correctly? Something like: pm@kaktus ~ $ snmpwalk -v2c -c xxxx 192.168.199.251 .1.3.6.1.4.1.2021.4.5.0 UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 99

Or is the answer: CD-SNMP-MIB::ssCpuIdle.0 = No Such Object available on this agent at this OID ?

(you can try OID .1.3.6.1.4.1.2021.11.11.0 for CPU)

In seccond case, your device doesn't support Net-SNMP - CPU Utilization/memory.

underdog-Fu commented 3 years ago

Try run snmp command: snmpwalk -v2c -c community host_ip .1.3.6.1.4.1.2021.4.5.0 Will the device respond correctly? Something like: pm@kaktus ~ $ snmpwalk -v2c -c xxxx 192.168.199.251 .1.3.6.1.4.1.2021.4.5.0 UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 99

Or is the answer: CD-SNMP-MIB::ssCpuIdle.0 = No Such Object available on this agent at this OID ?

(you can try OID .1.3.6.1.4.1.2021.11.11.0 for CPU)

In seccond case, your device doesn't support Net-SNMP - CPU Utilization/memory.

Thank you for your response when I run this command : “ snmpwalk -v2c -c xxxxx 10.167.229.4 . 1.3.6.1.4.1.2021.4.5.0” ,the feedback is as follows: image Not the two results you proposed

netniV commented 3 years ago

I think we can close this then as the message is correct. You can't create graphs for the OID's that are not present.

jdcoats commented 3 years ago

@netniV I'm not clear why you closed this. Creating a graph for boost stats on the local cacti server should work. Should not throw a php error.

2021/09/06 13:59:40 - 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[1723]:CactiErrorHandler())
2021/09/06 13:59:40 - ERROR PHP NOTICE: Trying to access array offset on value of type null in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
2021/09/06 13:59:40 - 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[1723]:CactiErrorHandler())
2021/09/06 13:59:40 - ERROR PHP NOTICE: Undefined index: cg in file: /var/www/localhost/htdocs/cacti/lib/template.php on line: 1723
jdcoats commented 3 years ago

The issue I reported does not come from snmp query output. The data is from mysql queries that work.

from scripts/ss_poller.php functions like

function ss_boost_table() {
        $stats = db_fetch_cell('SELECT DATA_LENGTH+INDEX_LENGTH AS tbl_len
                FROM INFORMATION_SCHEMA.TABLES
                WHERE TABLE_NAME = "poller_output_boost"
                AND TABLE_SCHEMA = SCHEMA()');

        return empty($stats) ? '0' : trim($stats);
}

function ss_boost_records() {
        $stats = db_fetch_cell('SELECT TABLE_ROWS
                FROM INFORMATION_SCHEMA.TABLES
                WHERE TABLE_NAME = "poller_output_boost"
                AND TABLE_SCHEMA = SCHEMA()');

        return empty($stats) ? '0' : trim($stats);
}

function ss_boost_avg_size() {
        $stats = db_fetch_cell('SELECT AVG_ROW_LENGTH
                FROM INFORMATION_SCHEMA.TABLES
                WHERE TABLE_NAME = "poller_output_boost"
                AND TABLE_SCHEMA = SCHEMA()');

        return empty($stats) ? '0' : trim($stats);
}
MariaDB [cacti]> select TABLE_ROWS from information_schema.tables WHERE TABLE_NAME = 'poller_output_boost' AND TABLE_SCHEMA = SCHEMA();
+------------+
| TABLE_ROWS |
+------------+
|    4005458 |
+------------+
1 row in set (0.000 sec)

MariaDB [cacti]> select DATA_LENGTH+INDEX_LENGTH AS tbl_len from information_schema.tables WHERE TABLE_NAME = 'poller_output_boost' AND TABLE_SCHEMA = SCHEMA();
+-----------+
| tbl_len   |
+-----------+
| 387973120 |
+-----------+
1 row in set (0.001 sec)

MariaDB [cacti]> select AVG_ROW_LENGTH from information_schema.tables WHERE TABLE_NAME = 'poller_output_boost' AND TABLE_SCHEMA = SCHEMA();
+----------------+
| AVG_ROW_LENGTH |
+----------------+
|             93 |
+----------------+
1 row in set (0.000 sec)
chrcoluk commented 3 years ago

Hi guys just a "me too" post.

I think this needs to be treated as experimental and in a new version of cacti changed to off by default, it for sure needs to be made optional, instead of havng to hack the source code.

So to be clear.

I dont want checks if oids exist when I make graphs. (they do actually exist so its a false positive, but sometimes i make graphs before adding custom oid's). This should be optional.

Thanks.