Skip to content

Instantly share code, notes, and snippets.

@bfritz
Last active August 29, 2015 14:18
Show Gist options
  • Save bfritz/af1c97737272df29dceb to your computer and use it in GitHub Desktop.
Save bfritz/af1c97737272df29dceb to your computer and use it in GitHub Desktop.
update IP address for OpenNMS host
$ /etc/init.d/opennms stop
$ grep password /etc/opennms/opennms-datasources.xml
$ psql -h localhost -U opennms
-- -- --
\set AUTOCOMMIT off
\set OLD_IP '\'11.11.11.11\''
\set NEW_IP '\'22.22.22.22\''
\set OLD_HOST '\'11-11-11-11.foo.bar.net\''
\set NEW_HOST '\'22-22-22-22.foo.bar.net\''
\set NODE_ID '(select nodeid from ipinterface where ipaddr = :NEW_IP and iphostname = :NEW_HOST)'
update node
set nodelabel = :NEW_HOST
where nodeid = :NODE_ID
;
update ipinterface
set ipaddr = :NEW_IP, iphostname = :NEW_HOST
where nodeid = :NODE_ID
;
update ifservices
set ipaddr = :NEW_IP
where nodeid = :NODE_ID
;
update pathoutage
set criticalpathip = :NEW_IP
where criticalpathip = :OLD_IP
;
update snmpinterface
set ipaddr = :NEW_IP
where nodeid = :NODE_ID
;
commit;
-- -- --
$ /etc/init.d/opennms start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment