Snmp input plugin for multiple device

i am using snmp input plugin to collect metrices from multiple device but now in my network there are more then 30 devices with different community string so configuring snmp input plugin manually is very hard.
So is there any way that i can do it dynamically or write python code and pass the list of agents and community string or some alternative solution to it.

You can indeed do that with python or any templating or configuration management tool. I, for example, use Ansible for this.