How can I update the SNMP Community String via CLI or SQL?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
Fetid
Posts: 2
Joined: Tue Apr 20, 2021 6:40 pm

How can I update the SNMP Community String via CLI or SQL?

Post by Fetid »

I need to update the SNMP Community String on about 3000+ hosts. So I don't loose any graph data, both the snmp config and cacti device need updated at the same time. I don't see any way of updating a device via the CLI so can someone provide the SQL I would need to use to update the SNMP Community String on a device on cacti version 1.2.16?
User avatar
zuka1337
Posts: 21
Joined: Thu Jan 28, 2021 9:08 am

Re: How can I update the SNMP Community String via CLI or SQL?

Post by zuka1337 »

You can find snmp_community on the host table.
Make sure you only update the ones you need.

Something like this:

UPDATE host SET snmp_community = 'newstring' where snmp_community = 'oldstring';
Github https://github.com/zuka1337
Killspikealt https://github.com/zuka1337/killspikealt "Graphical Interface to Remove Spikes"
Spikepyrrd https://github.com/zuka1337/Spikepyrrd "Python Script to remove spikes from graph"
Fetid
Posts: 2
Joined: Tue Apr 20, 2021 6:40 pm

Re: How can I update the SNMP Community String via CLI or SQL?

Post by Fetid »

na, the snmp_community string exits in three tables. The bit I now realise I missed was updating the poller cache. So the commands to change it on a $HOST are as follows.

UPDATE host SET snmp_community = 'newstring' WHERE description = "$HOST" AND snmp_community = 'oldstring'
UPDATE data_input_data SET value = 'newstring' WHERE value = 'oldstring' AND data_template_data_id IN (SELECT id FROM data_template_data WHERE name_cache LIKE "$HOST %")
UPDATE poller_item SET snmp_community = 'newstring' WHERE snmp_community = 'oldstring' AND hostname LIKE "${HOST}.%"

/bin/php /usr/share/cacti/cli/rebuild_poller_cache.php --host-id=$ID
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: How can I update the SNMP Community String via CLI or SQL?

Post by netniV »

If you are using automation, you should also update your snmp option sets.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest