Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When adding devices via command line, bad SNMP versions are not reported #3111

Closed
AlbertYangXY opened this issue Nov 28, 2019 · 3 comments
Closed
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@AlbertYangXY
Copy link

I do it by executing
php add_device.php --description=w02v.game.1311.com --ip=10.117.109.84 --template=9 --avail='ping' --proxy

It returns
Success - new device-id: (0)

The cacti.log is as follows:
2019/11/28 22:19:29 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown column 'net' in 'field list'
2019/11/28 22:19:29 - CMDPHP SQL Backtrace: (/cli/add_device.php[444]:api_device_save(), /lib/api_device.php[719]:sql_save(), /lib/database.php[1394]:_db_replace(), /lib/database.php[1324]:db_execute(), /lib/database.php[191]:db_execute_prepared())
2019/11/28 22:19:29 - DBCALL ERROR: SQL Save Failed for Table 'host'. SQL:'INSERT INTO host (id, host_template_id, poller_id, site_id, external_id, description, hostname, notes, location, snmp_version, snmp_community, snmp_username, snmp_password, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, snmp_engine_id, snmp_port, snmp_timeout, disabled, availability_method, ping_method, ping_port, ping_timeout, ping_retries, max_oids, device_threads, monitor, monitor_text, monitor_criticality, monitor_warn, monitor_alert, alertsms, sms_phone) VALUES (0, 9, 1, 1, '', 'w02v.game.1311.com', '10.117.109.84', '', '', net-snmp, 'cacti', '', '', '', '', '', '', '', 161, 1000, '', 3, 3, 8360, 1000, 3, 100, 1, '', '', 0, 0, 0, '', '') ON DUPLICATE KEY UPDATE host_template_id=VALUES(host_template_id), poller_id=VALUES(poller_id), site_id=VALUES(site_id), external_id=VALUES(external_id), description=VALUES(description), hostname=VALUES(hostname), notes=VALUES(notes), location=VALUES(location), snmp_version=VALUES(snmp_version), snmp_community=VALUES(snmp_community), snmp_username=VALUES(snmp_username), snmp_password=VALUES(snmp_password), snmp_auth_protocol=VALUES(snmp_auth_protocol), snmp_priv_passphrase=VALUES(snmp_priv_passphrase), snmp_priv_protocol=VALUES(snmp_priv_protocol), snmp_context=VALUES(snmp_context), snmp_engine_id=VALUES(snmp_engine_id), snmp_port=VALUES(snmp_port), snmp_timeout=VALUES(snmp_timeout), disabled=VALUES(disabled), availability_method=VALUES(availability_method), ping_method=VALUES(ping_method), ping_port=VALUES(ping_port), ping_timeout=VALUES(ping_timeout), ping_retries=VALUES(ping_retries), max_oids=VALUES(max_oids), device_threads=VALUES(device_threads), monitor=VALUES(monitor), monitor_text=VALUES(monitor_text), monitor_criticality=VALUES(monitor_criticality), monitor_warn=VALUES(monitor_warn), monitor_alert=VALUES(monitor_alert), alertsms=VALUES(alertsms), sms_phone=VALUES(sms_phone)'

My newly deployed machine did not report an error. The machine that reported the error was upgraded from cacti0.8.8a to cacti1.2.7. The database was upgraded from mysql5.1 to mysql5.7, but I copied the mysql table structure of the new machine to the old machine. Still reporting errors

Need your help very much

@cigamit
Copy link
Member

cigamit commented Nov 28, 2019

Well, that is very odd. It's trying to save a text value of 'net-snmp' instead of 1, 2, or 3. Not sure how that is happening. Will have to check it out. Can you please update to the 1.2.x branch and test again?

@cigamit
Copy link
Member

cigamit commented Nov 28, 2019

I used your example, and could not duplicate. Can you please check the value of 'snmp_version' in your Cacti settings table?

SELECT value FROM settings WHERE name='snmp_version';

Should be either 0, 1, 2, or 3. This might be your problem. Seems odd. Maybe one of your plugins is leveraging the 'snmp_version' setting and overloading it with what it's used for in Cacti 1.2.x. Oh, geeze that is what it is. In Cacti 0.8.x, we used snmp_version for 'ucd-snmp' or 'net-snmp'. Wow, a long time ago. I'll make an update to add_devices.php, but just goto Configuration > Settings > Device Defaults and 'save'. Then, for you the problem will be corrected.

@cigamit cigamit added the bug Undesired behaviour label Nov 28, 2019
@cigamit cigamit added this to the v1.2.8 milestone Nov 28, 2019
@cigamit cigamit changed the title Device cannot be created via add_device.php script When updating an old Cacti version, the add_device.php will fail due to a bad snmp-version column. Nov 28, 2019
cigamit added a commit that referenced this issue Nov 28, 2019
When updating an old Cacti version, the add_device.php will fail due to a bad snmp-version column
@cigamit cigamit added the resolved A fixed issue label Nov 28, 2019
@cigamit
Copy link
Member

cigamit commented Nov 28, 2019

Should be resolved in 1.2.8. At least you will get an error.

@cigamit cigamit closed this as completed Nov 28, 2019
@netniV netniV changed the title When updating an old Cacti version, the add_device.php will fail due to a bad snmp-version column. When adding devices via command line, bad SNMP versions are not reported Dec 7, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants