Migrate from Capsd and Discovery to Provisiond
Since 1.8 OpenNMS has introduced a powerful provisioning system. This tutorial describes how to migrate from an IP Discovery setup to a Provisiond maintained system. Beside the powerful features like policies and very efficient service detectors, Provisiond makes no attempt to merge nodes based on the IP interface table like Capsd did. This was a conscious decision taken because node-merging accidents are often spectacularly damaging.
It is highly recommended you run the migration in a virtual environment first, so you get familar with the process and you can prevent a lot of stress by trying it in a production environment. Backup your database and restore in a dev environment or a the provided Vagrant box. You can turn off Collectd and Pollerd in your dev environment in service-configuration.xml. It is not necessary to have real monitoring behavior for the migration. The database and the RRD files make sense, so you can check if you can browse the RRD data, events, notifications and outages from your nodes.
The migration will move all discovered nodes to a migrate requisition. Already provisioned nodes are not affected by this procedure.
Important: You'll loose RRD data if you run storeByForeignSource, the RRD files are not moved, you have to move the RRD files manually for each node id in the migration.xml to the migrate folder in $OPENNMS_HOME/share/rrd/snmp. We keep the unique OpenNMS Node-ID as foreign-ID so you are able to reuse them.
You need the OpenNMS Inventory Integration Server from GitHub
- Install the OpenNMS Inventory Integration Server (OIIS) to /opt/opennms-pris on your local OpenNMS Server described in the README on GitHub. Please look in the src/examples folder, where you find a init script for CentOS/Debian/Ubuntu.
- Create a JDBC requisition against the local OpenNMS Postgres database
- Stop OpenNMS
- Export your requisition provided from the OIIS in your Provisiond import folder
- Run update SQL statement to set the foreign-ID and Foreign-Source
- Turn off Capsd
- Restart OpenNMS
Create the JDBC source against OpenNMS
The OIIS should be installed to /opt/opennms-pris. We create a new requisition with the name migrate. We will build the following file structure:
[root@localhost opennms-pris]# pwd && tree /opt/opennms-pris . ├── global.properties ├── migrate │ └── requisition.properties └── opennms-pris.jar
The global.properties file sets the OIIS in the background daemon mode and provides the requistion over HTTP.
### start an http server that provides access to requisition files driver = http host = 0.0.0.0 port = 8000
In migrate folder we create a requisition which reads all nodes from OpenNMS and provides the data in the new requisition format. If you have changed the database name or the user and password, you have to change the jdbc.url, jdbc.user and jdbc.password to your environment.
Hint: We select only active nodes and active services. If you want to export also nodes which have the delete flag set or services which are Force Unmanaged, please remove the modify the WHERE statement to your needs. We will move all discovered nodes to the migrate requisition. You will not loose node id related data like events, outages, notifications, alarms and RRD files using this method.
### SOURCE ### ## connect to a database via jdbc source = jdbc.source ## jdbc source paremeter ## jdbc.driver = org.postgresql.Driver jdbc.url = jdbc:postgresql://localhost:5432/opennms jdbc.user = opennms jdbc.password = opennms jdbc.selectStatement = SELECT \ node.nodeid AS Foreign_Id, \ node.nodelabel AS Node_Label, \ ipinterface.ipaddr AS IP_Address, \ ipinterface.issnmpprimary AS If_Type, \ assets.description AS Asset_Description, \ assets.city AS Asset_City, \ assets.state AS Asset_State, \ service.servicename AS Svc, \ categories.categoryname AS Cat \ FROM \ node LEFT OUTER JOIN ipInterface ON node.nodeId=ipInterface.nodeId \ LEFT OUTER JOIN ifServices ON ipInterface.ipAddr=ifServices.ipAddr \ LEFT OUTER JOIN service ON ifServices.serviceId=service.serviceId \ LEFT OUTER JOIN category_node ON node.nodeId=category_node.nodeId \ LEFT OUTER JOIN categories ON category_node.categoryId=categories.categoryId \ LEFT OUTER JOIN assets ON node.nodeId=assets.nodeId \ WHERE \ ifServices.status = 'A' AND \ node.nodetype = 'A' AND \ node.foreignsource is NULL AND \ node.foreignid is NULL; ## mapper ## mapper = echo.mapper
Try to get your nodes as requisition with wget http://localhost:8000/migrate or pointing your Browser to the given URL. You can proceed if you see your nodes with interfaces and services as XML output.
Export the requisition to Provisiond import folder
Important: Stop OpenNMS before you do the next steps
You can save now your requisition in the Provisiond import folder
wget -o $OPENNMS_HOME/etc/imports/migrate.xml http://localhost:8000/migrate
Update nodes with SQL statement
The next step is to set the foreign-ID and foreign-source. For discovered Nodes this entries are empty. Nodes which are already provisioned will be ignored and only all discovered nodes will be moved to the migrate requisition.
update node set foreignsource = 'migrate' WHERE node.nodetype='A' AND node.foreignsource is NULL and node.foreignid is NULL;
update node set foreignid = nodeid WHERE node.nodetype='A' AND node.foreignsource is NULL and node.foreignid is NULL;
Turn off Capsd
Check your service-configuration.xml and deactivate Capsd by commenting the whole service block
Start OpenNMS and check the Requisition named migrate in the WebUI. All nodes defined in the requistion should also be in the database. You can now use detectors and policies to control the monitoring behavior of this nodes.
If you want to move nodes without loosing data from one requisition to another, you have to update the foreignsource field for the node to the requistion you want to move it.
You can stop opennms-pris and you can deinstall it. We need it only the one time to migrate the OpenNMS nodes to the requistion.