Cacti / plugin_mactrack

Mactrack Plugin for Cacti
GNU General Public License v2.0
12 stars 25 forks source link

Can't save settings on Cacti devices when MacTrack plugin is enabled #87

Closed francistheodorecatte closed 5 years ago

francistheodorecatte commented 6 years ago

Cacti version 1.1.38 MacTrack is the latest GitHub develop release

I can create Cacti devices fine, but if I try to edit them I get a pop-up that says

Action failed Sorry, we could not process your last action. Save Failed due to filed input errors (Check red fields).

...except none of the fields are highlighted, and if I disable the MacTrack plugin, I can save the device settings without any issue.

The Cacti log has a bunch of MacTrack related errors appear whenever I do the save. Here's a snippet from my Cacti log showcasing the errors as they appear: mactrack_errors.txt

It looks like it's only limited to devices that're NOT in the MacTrack database.

xmacan commented 6 years ago

I have the same problem

netniV commented 6 years ago

Chances are you having missing columns and you'll have errors reporting in your cacti.log

xmacan commented 6 years ago

I tried only install and start mactrack and edit any host: 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: device_id in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 182 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 182 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: site_id in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 184 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 184 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: scan_type in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 187 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 187 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: snmp_options in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 188 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 188 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: snmp_retries in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 200 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 200 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: ignorePorts in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 202 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 202 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: user_name in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 204 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 204 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: user_password in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 205 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 205 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: term_type in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 206 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 206 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: private_key_path in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 207 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 207 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace) 2018/09/25 19:31:45 - CMDPHP Form Validation Failed: Variable 'scan_type' does not allow nulls and variable is null 2018/09/25 19:31:45 - CMDPHP Form Validation Failed: Variable 'snmp_retries' does not allow nulls and variable is null 2018/09/25 19:31:45 - MACTRACK ERROR: Cacti Device: (0/331): praha.atelier8000.cz, error on verify: a:27:{s:9:"device_id";N;s:7:"host_id";i:331;s:7:"site_id";N;s:8:"hostname";s:20:"praha.atelier8000.cz";s:11:"device_name";s:21:"A8000 - pha samba BSD";s:5:"notes";s:0:"";s:9:"scan_type";N;s:12:"snmp_options";N;s:15:"snmp_readstring";s:6:"public";s:12:"snmp_version";s:1:"1";s:13:"snmp_username";s:0:"";s:13:"snmp_password";s:0:"";s:18:"snmp_auth_protocol";s:0:"";s:20:"snmp_priv_passphrase";s:0:"";s:18:"snmp_priv_protocol";s:0:"";s:12:"snmp_context";s:0:"";s:14:"snmp_engine_id";s:0:"";s:9:"snmp_port";s:4:"1161";s:12:"snmp_timeout";s:4:"2505";s:12:"snmp_retries";N;s:8:"max_oids";s:2:"40";s:9:"user_name";N;s:13:"user_password";N;s:11:"ignorePorts";N;s:9:"term_type";N;s:16:"private_key_path";N;s:8:"disabled";s:0:"";} 2018/09/25 19:31:45 - ERROR PHP NOTICE in Plugin 'mactrack': Undefined index: device_id in file: /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line: 211 2018/09/25 19:31:45 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 58 form_save)(/host.php: 185 api_device_save)(/lib/api_device.php: 235 api_plugin_hook_function)(/lib/plugins.php: 113 api_plugin_run_plugin_hook_function)(/lib/plugins.php: 214 sync_cacti_to_mactrack)(/plugins/mactrack/mactrack_actions.php: 211 CactiErrorHandler)(/lib/functions.php: 4590 cacti_debug_backtrace)

netniV commented 6 years ago

I have just installed and enabled MacTrack. I then went to a Management -> Device, picked a host, hit save, no errors.

xmacan commented 6 years ago

We have (me + phineasthecat) version 1.1.38. What is your version?

netniV commented 6 years ago

That would be your Cacti Version, have you the latest MacTrack version?

xmacan commented 6 years ago

Mactrack version 4.2 from https://github.com/Cacti/plugin_mactrack

netniV commented 6 years ago

Could you try the latest develop version? I did update some of the code but those updates shouldn't have any reasonable affect on what you experience. It just makes my life that little bit easier not having to switch between the release and development ;-)

xmacan commented 6 years ago

I have last develop version - same result. I cannot save device form

netniV commented 6 years ago

Can you desc the host, and plugin_mactrack* tables?

xmacan commented 6 years ago

| id | mediumint(8) unsigned | NO | PRI | NULL | auto_increment | | poller_id | int(10) unsigned | NO | MUL | 1 | | | site_id | int(10) unsigned | NO | MUL | 1 | | | host_template_id | mediumint(8) unsigned | NO | | 0 | | | description | varchar(150) | NO | | | | | hostname | varchar(100) | YES | MUL | | | | notes | mediumtext | YES | | NULL | | | external_id | varchar(40) | YES | MUL | NULL | | | snmp_community | varchar(100) | YES | | NULL | | | snmp_version | tinyint(1) unsigned | NO | | 1 | | | snmp_username | varchar(50) | YES | | NULL | | | snmp_password | varchar(50) | YES | | NULL | | | snmp_auth_protocol | char(6) | YES | | | | | snmp_priv_passphrase | varchar(200) | YES | | | | | snmp_priv_protocol | char(6) | YES | | | | | snmp_context | varchar(64) | YES | | | | | snmp_engine_id | varchar(64) | YES | | | | | snmp_port | mediumint(5) unsigned | NO | | 161 | | | snmp_timeout | mediumint(8) unsigned | NO | | 500 | | | snmp_sysDescr | varchar(300) | NO | | | | | snmp_sysObjectID | varchar(128) | NO | | | | | snmp_sysUpTimeInstance | int(10) unsigned | NO | | 0 | | | snmp_sysContact | varchar(300) | NO | | | | | snmp_sysName | varchar(300) | NO | | | | | snmp_sysLocation | varchar(300) | NO | | | | | availability_method | smallint(5) unsigned | NO | | 1 | | | ping_method | smallint(5) unsigned | YES | | 0 | | | ping_port | int(12) unsigned | YES | | 0 | | | ping_timeout | int(12) unsigned | YES | | 500 | | | ping_retries | int(12) unsigned | YES | | 2 | | | max_oids | int(12) unsigned | YES | | 10 | | | device_threads | tinyint(2) unsigned | NO | | 1 | | | disabled | char(2) | YES | MUL | | | | thold_send_email | int(10) | NO | | 1 | | | thold_host_email | int(10) | NO | | NULL | | | monitor | char(3) | NO | | on | | | monitor_text | mediumtext | NO | | NULL | | | status | tinyint(2) | NO | MUL | 0 | | | status_event_count | mediumint(8) unsigned | NO | | 0 | | | status_fail_date | timestamp | NO | | 0000-00-00 00:00:00 | | | status_rec_date | timestamp | NO | | 0000-00-00 00:00:00 | | | status_last_error | varchar(255) | YES | | | | | min_time | decimal(10,5) | YES | | 9.99999 | | | max_time | decimal(10,5) | YES | | 0.00000 | | | cur_time | decimal(10,5) | YES | | 0.00000 | | | avg_time | decimal(10,5) | YES | | 0.00000 | | | polling_time | double | YES | | 0 | | | total_polls | int(12) unsigned | YES | | 0 | | | failed_polls | int(12) unsigned | YES | | 0 | | | availability | decimal(8,5) | NO | | 100.00000 | | | last_updated | timestamp | NO | | current_timestamp() | on update current_timestamp() |

xmacan commented 6 years ago

desc_mactrack.txt

netniV commented 6 years ago

OK so I can't replicate this bug. Whenever I do this it works. If I assign the Cacti device to the Mactrack device, it works. If I have mactrack device set to none. It works, rinse repeated, no errors.

netniV commented 6 years ago

Any chance you could try with a test server and a clean install?

xmacan commented 6 years ago

Mactrack only installed and running, no mactrack site or device. Console->devices->pick one->save and mactrack_actions.php line 173: $mt_device = db_fetch_row('SELECT * from mac_track_devices WHERE host_id=' . $device['id']); -> empty array, but next code: -> insert something to array if (!isset($mt_device['snmp_engine_id'])) { $mt_device['snmp_engine_id'] = ''; } -> next line - array exists if (is_array($mt_device)) {

-> working with empty array values (device_id,site_id,user_name,...)

PHP Notice: Undefined index: site_id in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 184, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: scan_type in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 187, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: snmp_options in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 188, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: snmp_retries in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 200, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: ignorePorts in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 202, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: user_name in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 204, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: user_password in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 205, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: term_type in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 206, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: private_key_path in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 207, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467 PHP Notice: Undefined index: device_id in /usr/local/share/cacti/plugins/mactrack/mactrack_actions.php on line 211, referer: https://kaktus.kostax.cz/host.php?action=edit&id=467

xmacan commented 6 years ago

Test server - I can prepare it, maybe today. Which version? 1.1.38?

netniV commented 6 years ago

Up to you. I'm running 1.2 but I can switch back if needed.

chris-y commented 5 years ago

@netniV - I was also having this problem and found a clue in my log that it was to do with the cacti=>mactrack sync.

In Settings, Device Tracking tab, Update Policy for SNMP Options was set to Sync Cacti Device to Device Tracking Device. If I change it to None I can edit devices happily. Change it back and I get the reported error. I didn't try the other option as I'm not sure what it does and don't want to accidentally mess up my devices! If you change this setting hopefully you'll be able to reproduce it.

jpobeda commented 5 years ago

@chris-y good to know, I have that actually set to 'none' It never made sense to me to use it if I was importing cacti devices into mactrack. Something to look at.

@xmacan can you double check your settings?

image

xmacan commented 5 years ago

Checked - Chis-y is right.

jpobeda commented 5 years ago

@phineasthecat can you check yours and see if that fixes it?

cigamit commented 5 years ago

There has been a number updates lately. You might want to consider uninstalling and re-installing MacTrack.