×
Back to ITRS Internal Only FAQ
Internal documentation only
This page has been marked as draft.
How to bulk change SNMP credentials through the REST API
Steps to bulk change SNMP credentials through the REST API Copied
- Export the values for a specific host. Run the follow command (replacing HOSTNAME, USER and PASSWORD with the correct values. Make sure the user has the correct permissions):
/opt/opsview/coreutils/bin/opsview_rest --username=USER --password=PASSWORD --pretty --data-format=json GET "/rest/config/host?include_encrypted=1&s.name=HOSTNAME" > /tmp/snmp_network_hosts.json
- The export produces the file
/tmp/snmp_network_hosts.json. - Get the encrypted values by running the following command:
sudo -iu opsview /opt/opsview/coreutils/bin/opsview_crypt
- In the file, modify the following fields:
"encrypted_snmpv3_authpassword" : "ENCRYPTED_VALUE",
"encrypted_snmpv3_privpassword" : "ENCRYPTED_VALUE",
"snmpv3_authprotocol" : "sha",
"snmpv3_privprotocol" : "aes128",
"snmpv3_username" : "SNMP_USER",
- Then, proceed to update the configuration using the following command:
/opt/opsview/coreutils/bin/opsview_rest --username=USER --password=PASSWORD --pretty --data-format=json --content-file=/tmp/snmp_network_hosts.json PUT /rest/config/host
- Run the Apply Changes in the UI or send an API request to Opsview to reload its configuration.
opsview_rest --username=admin --password=initial --pretty POST reload
- Test the service check to confirm that the host has the correct SNMPv3 credentials.
Other filter examples:
Alternative filters can be applied to retrieve all hosts within a specific host template or host group. Commands for other filters include:
- Host groups:
/opt/opsview/coreutils/bin/opsview_rest --username=USER --password=PASSWORD --pretty --data-format=json GET "/rest/config/host?include_encrypted=1&s.hostgroup.name=HOST_GROUP" > /tmp/snmp_network_hosts.json
- Host templates:
/opt/opsview/coreutils/bin/opsview_rest --username=USER --password=PASSWORD --pretty --data-format=json GET "/rest/config/host?include_encrypted=1&s.hosttemplates.name=HOST_TEMPLATE" > /tmp/snmp_network_hosts.json
Note: T**est this out with a single host first to ensure you get the expected results.
["Geneos"]
["FAQ"]