netniV / cacti-netsnmp-memory

This script template is intended to overcome these shortcomings by fetching all of the available memory data from all known sources (including the standard HOST MIB), and then performing basic arithmetic to fill in any gaps in the data.
3 stars 2 forks source link

PHP error: Multiple 'Undefined variable: snmp_' messages #1

Closed Helmut1972 closed 6 years ago

Helmut1972 commented 6 years ago

PHP7 on FreeBSD gives an warning:

2018/01/16 09:50:01 - POLLER: Poller[1] Device[2] DS[24] SERVER: /var/www/cacti/scripts/ss_netsnmp_memory.php ss_netsnmp_memory '192.168.124.35' '2' 'public' '161' '10000' '' '' , output: totalReal:4161028 availReal:115808 totalSwap:2097088 availSwap:1560480 memBuffer:284768 memCached:1405928 usedReal:2354524 usedSwap:536608 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - POLLER: Poller[1] Device[10] RECACHE: Processing 4 items in the auto reindex cache for '192.168.124.252'. 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[30] OID: .1.3.6.1.2.1.1.3.0, output: 125768003 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[25] OID: .1.3.6.1.2.1.1.3.0, output: 125768003 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[24] OID: .1.3.6.1.2.1.1.3.0, output: 125768003 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[9] OID: .1.3.6.1.2.1.1.3.0, output: 125768003 2018/01/16 09:50:01 - POLLER: Poller[1] Device[10] STATUS: Device '192.168.124.252' is UP. 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[8] OID: .1.3.6.1.2.1.1.3.0, output: 125768001 2018/01/16 09:50:01 - PING Device[10] SNMP: Device responded to SNMP 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE DQ[1] OID: .1.3.6.1.2.1.1.3.0, output: 125768001 2018/01/16 09:50:01 - POLLER: Poller[1] Device[34] RECACHE: Processing 6 items in the auto reindex cache for '192.168.124.253'. 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_context in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_priv_passphrase in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR NOTICE Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 78 CactiErrorHandler)(/lib/functions.php: 4434 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP NOTICE: Undefined variable: snmp_auth_protocol in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 78 2018/01/16 09:50:01 - CMDPHP PHP ERROR WARNING Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 47 CactiErrorHandler)(/lib/functions.php: 4429 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP WARNING: Missing argument 11 for ss_netsnmp_memory(), called in /var/www/var/www/cacti/script_server.php on line 223 and defined in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 47 2018/01/16 09:50:01 - CMDPHP PHP ERROR WARNING Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 47 CactiErrorHandler)(/lib/functions.php: 4429 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP WARNING: Missing argument 10 for ss_netsnmp_memory(), called in /var/www/var/www/cacti/script_server.php on line 223 and defined in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 47 2018/01/16 09:50:01 - CMDPHP PHP ERROR WARNING Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 47 CactiErrorHandler)(/lib/functions.php: 4429 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP WARNING: Missing argument 9 for ss_netsnmp_memory(), called in /var/www/var/www/cacti/script_server.php on line 223 and defined in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 47 2018/01/16 09:50:01 - CMDPHP PHP ERROR WARNING Backtrace: (/script_server.php: 223 ss_netsnmp_memory)(/scripts/ss_netsnmp_memory.php: 47 CactiErrorHandler)(/lib/functions.php: 4429 cacti_debug_backtrace) 2018/01/16 09:50:01 - ERROR PHP WARNING: Missing argument 8 for ss_netsnmp_memory(), called in /var/www/var/www/cacti/script_server.php on line 223 and defined in file: /var/www/var/www/cacti/scripts/ss_netsnmp_memory.php on line: 47 2018/01/16 09:50:01 - POLLER: Poller[1] Device[7] DS[118] CMD: perl /var/www/cacti/scripts/ping.pl 'www.google.de', output: 31.292 2018/01/16 09:50:01 - PHPSVR DEBUG: PID[87070] CTR[0] INC: 'ss_netsnmp_memory.php' FUNC: 'ss_netsnmp_memory' PARMS: ''192.168.124.35' '2' 'public' '161' '10000' '' '''

netniV commented 6 years ago

Can you do me a favour and post the output of the Poller Cache for this script? Also, what SNMP settings do you have set against your device? Are you using version 3?

Helmut1972 commented 6 years ago

SNMPv2 and your fix works. Do you still need a poller output?

netniV commented 6 years ago

I would like to see it, to see why that would cause the issue. I am presuming that it was still passing the old type of data but I want to be sure.

Helmut1972 commented 6 years ago

Could you help me with the command line? https://www.cacti.net/downloads/docs/html/check_cacti_poller.html seems outdated.

netniV commented 6 years ago

It's under Console -> Utilities -> System Utilities -> View Poller Cache -> (select the device in the filter). On the left hand side will be the Data Sources, and the right is the Details for the data source.

Helmut1972 commented 6 years ago

Script Server: /var/www/cacti/scripts/ss_netsnmp_memory.php ss_netsnmp_memory '192.168.124.35' '2' 'public' '161' '10000' '' ''

netniV commented 6 years ago

Now that's interesting because there doesn't seem to be enough fields there. So, lets take a look at the template now, can you paste the contents of the input string on the Data Input Method? Also can you let me know Cacti version you are on ?

Helmut1972 commented 6 years ago

Cacti 1.1.30

/scripts/ss_netsnmp_memory.php ss_netsnmp_memory Of course we could change the string and quote all fields but I'd prefer to have the script catch such things. :)
netniV commented 6 years ago

From what I understood, Cacti was doing that anyway. This may be a difference between the Import and the Save routines within Cacti. Just go to the templates, edit the template (you do not have to change anything) and then save. Then go back and check the poller cache again. I am betting it will have updated that command.

Helmut1972 commented 6 years ago

Edited the Data Template, saved, rebuilt the poller cache, looks good now:

Script Server: /var/www/cacti/scripts/ss_netsnmp_memory.php ss_netsnmp_memory '192.168.124.35' '2' 'public' '161' '10000' '' '' '' '' '' ''

netniV commented 6 years ago

That may be one for @cigamit to comment on as to why that would be.

netniV commented 6 years ago

@Helmut1972 is this still an issue for you ?

Helmut1972 commented 6 years ago

Fixed. Thank you!