livebox:xap_cacti

This is an old revision of the document!


CACTI Monitoring of xAP

cacti is a great monitoring tool wouldn't it be cool if ANY xAP data value could be monitored?

With a xAP caching Lua applet running as a plugboard script on the HAH and one small python script for CACTI to use this indeed is possible.

The first step is to set-up and configure Lua script xapCacheWebserverApplet.lua which will cache an xAP data value and provide a URL for later accessing.

The script is supplied as a sample in the /etc_ro_fs/plugboard/samples directory on the HAH, it's also available as a post on the forum

Here is how to we modify the VFS configuration to capture data we are interested in.

local vfs = {
   filter={
      xap.Filter{["xap-header"] = { source="dbzoo.livebox.CurrentCost:ch.1" } },
      xap.Filter{["xap-header"] = { source="dbzoo.livebox.CurrentCost:temp" } },
      xap.Filter{["xap-header"] = { source="dbzoo.livebox.Controller:1wire.*" } },
   },
   data={}
}

After restarting the plugboad engine we can point our web browser at

http://<HAH-IP>:8080/

and see the xAP frames being cached.

Once some xAP messages have been cached you should see a web page like this:

NOTE: The URLs listed here are not valid hyperlinks.

The installation of CACTI is beyond the scope of this document and I'll assume you already have it setup and running, there are many guides our there to show you how to install this product.

You need to include one custom script that will called by the cacti data poller to reach our to our LUA caching web applet to grab xAP data values.

On my system this script appear on a linux server at: /var/www/cacti/scripts/xapquery.py don't forget to set the permission bits

[root@wombat scripts]# ls -l xapquery.py
-rwxr-xr-x 1 root root 588 Jun 20 16:14 xapquery.py
[root@wombat scripts]#

You'll need to make one modification to this code and update the HARDCODED IP address to point to you HAH system.

#!/usr/bin/python
#
# QUERY the xapCache
#
# Usage:
# ./xapquery.py dbzoo.arduino.temp input.state text
 
import sys
import time
from os import popen
 
def getValue(target,section,key):
        x = popen("wget -qO- http://livebox.local:8080/%s/%s/%s" % (target,section,key))
        ret = x.read()
        x.close()
        if ret:
                return ret
        return "0"
 
if len(sys.argv) < 3:
        out="value:0"
else:
        out="value:%s" % getValue(sys.argv[1], sys.argv[2], sys.argv[3])
 
# Useful for debugging
#f = open("/var/www/cacti/log/xapquery.log","a")
#f.write("%s: %s %s\n" % (time.ctime(), sys.argv, out))
#f.close()
 
print out

We can verify that the script it working correctly and that the LUA xAP caching applet it working by running a simple test. I'm assuming here that you have a 1wire temperature sensor connected. Adjust this test for a suitable endpoint if you don't.
The arguments are <TARGET> <SECTION> <KEY>

[root@wombat scripts]# ./xapquery.py dbzoo.livebox.Controller:1wire.1 input.state text
value:18.3
[root@wombat scripts]#

First we need to register this external script by adding a new Collection Method

Once we have select the ADD hyperlink complete the following form, this sets up the external script and configures 1 output value and 3 input values.

Now we need to create a DATA Template - you can see we will add a xAPQuery item here.

Give the data template a name - I've called my simply xAPQuery and attached the “DATA INPUT METHOD” we created earlier.

Now the template is in PLACE we can create a DATA SOURCE, this is the thing that collects data about some xAP endpoint we define. You can see I've already created some early and they appear as listed items in the table below.

For each xAP data value you want to collect data on repeat this process. You will perform this action for each Filter you created in the xAP LUA data cache.

To create the data source to we use the xAPQuery template we defined earlier.

Want we are going to collect is the outside temperature reading from the 1wire device. Complete the form and press CREATE. Here we supply the xAP TARGET, SECTION and KEY.

One the create button has been pressed we can provide addition data to the xAPQuery script that collect this data.

Now the exciting bit we create graph to plot the information gathered. You can delete and create new graph without affecting the data that is being collected, so feel free to experience in this section on your own. The image below shows the graphs that I have registered.

Use the ADD hyperlink to create a new graph

We don't have any predefined graph template or host we need to attached this data to.

Give your graph a TITLE

Now press ADD so that we can attach the DATA SOURCES to this graph

Now we attach the DATA SOURCE we created early as a graph data item.

Putting it on the Graph Console Tab

That's all there is to it!

  • livebox/xap_cacti.1369652716.txt.gz
  • Last modified: 2013/05/27 11:05
  • by brett