Cacti and Openhab integration using REST API and curl

This tutorial shows how to fetch data from Openhab REST API and feed it as input into a Cacti graph. The data is fetched with curl. Openhab monitors temperatures with two Proove wireless temperature sensors via Tellstick duo.

The reason for doing this is that in Openhab 1.X the graphs are not as good as in Cacti and it also allows to share graphs to other sites see the example here.

Please excuse the example names in screenshots as they are in Finnish.

Prerequisites

    • Raspberry Pi running Raspbian

    • Cacti installation

    • Openhab installation with a few items as data sources

Create Cacti Input Method

    • In Cacti console, go to Data Input Methods and click on Add

    • Enter a name and choose Input type to Script/Command

    • in Input string add this command replacing the IP address and items name with your own

      • /usr/bin/curl http://192.168.1.45:8080/rest/items/Proove2_temp/state

    • In the Output fields click on Add

    • Then add a descriptive name for the Field [output] and a friendly name

    • Check the box "update RRD file"

The end result should look something like this

Create a Cacti datasource

In Cacti go to Data templates and click on Add

    • Give it a descriptive name and choose the Data input method you just created

    • In the Output filed choose the output field you created

Create a graph template

In Cacti go to Graph templates and click on Add

    • Create Items where the data source is the Data source you created. In this graph I'm using two data sources and showing them in the same graph.

Create the Device in Cacti

Finally to tie everything together create device with this Graph template

Example graphs

Enjoy the new graph and maybe even upload it to dropbox using this guide?