Cacti

12 replies [Last post]
garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011

Hi all,

thinking out loud here due to the annoyance of pachube/cosm rebranding issues.

I would like to have access to charts or varying time scales via mobile devices, this has apparently been removed from xively as far as I can tell.

from the bit of googling I have done today I was wondering if anyone has any thoughts or ideas on the following? I can't see why this isn't possible.

obtain a raspberry pi and install Cacti. See http://n00blab.com/cacti-pi/

txfer the data to cacti as Brett describes in the cacti section of the wiki.

Publish the required charts as a webpage as described here: http://forums.cacti.net/viewtopic.php?f=21&t=42714

 

I would appreciate people's thoughts on this before I spend my dollar!

cheers

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Garry quite right integration

Garry quite right integration to CACTI was something that I prototyped up quite some time ago.

http://www.dbzoo.com/livebox/xap_cacti

I have a PI but I could never get its ethernet port to work I think its broken and I was burning too much time screwing around with it so I stopped and now its just sitting on my desk as a constant reminder of something I wanted to play with.

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Update

A quick update!

for the price of a raspberry pi this is working great. Up all night setting up but now it's done pachube/cosm/whoever you can kiss my @ss!

Thanks for the work on cacti integration Brett. Sterling work as always. 

Should have done this sooner, Cacti really powerful and iOS apps available to pull graphs easily. 

Sure there are other alternatives but I'm pleased with this one. Plus I now have a pi to play with. iOS airplayer maybe?

 

garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Garry good job.  I must move

Garry good job.  I must move my cacti installation to another box (VM) and get it setup again.  Good thing I wrote some nice notes as I would have forgotten half of those steps involved by now.

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Python script mod

I wanted to plot device state on cacti such that on=1 off=0 in addition to just sensor values.

I have modified the demo python script as follows to do just that.

 

 

#!/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://192.168.0.8:8080/%s/%s/%s" % (target,section,key))
        ret = x.read()
        x.close()
   if ret:
           if ret == "on":
             ret = 1
           elif ret == "off":
             ret = 0
           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

 

Brett (or anyone else who knows python), could you give it a critique and i'll add it to the wiki if all is good.

thanks

Garry

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Gary, I think we can do

Gary, 

I think we can do better.  You didn't handle the case where state=? which is the startup value when we don't know if its on or off yet.  I'm defaulting this to 0 too in my logic in yours you returned the ? value (what does this mean?)
I'm getting rid of the popen() at the same time I never did like that bit of hackiness.

http://www.dbzoo.com/livebox/xap_cacti#customizing_for_xap

I updated the code in the wiki.

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Cheers Brett,I always miss

Cheers Brett,

I always miss something on my first attempt! And after seeing your code wonder why I didn't do it that way myself?! Will try harder next time!

 

Garry 

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
help..

Brett?

Cacti was working fine until I tried to enter the updated xapquery.py from the wiki.

Now I am getting this error when I check that it is working:

------------------------------------------------------------------------------

Traceback (most recent call last):

  File "./xapquery.py", line 24, in <module>

    out="value:%s" % getValue(sys.argv[1], sys.argv[2], sys.argv[3])

  File "./xapquery.py", line 13, in getValue

    f = urllib2.urlopen("http://192.168.1.66:8080/%s/%s/%s" % (target,section,key))

  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen

    return _opener.open(url, data, timeout)

  File "/usr/lib/python2.7/urllib2.py", line 401, in open

    response = self._open(req, data)

  File "/usr/lib/python2.7/urllib2.py", line 419, in _open

    '_open', req)

  File "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain

    result = func(*args)

  File "/usr/lib/python2.7/urllib2.py", line 1211, in http_open

    return self.do_open(httplib.HTTPConnection, req)

  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open

    r = h.getresponse(buffering=True)

  File "/usr/lib/python2.7/httplib.py", line 1034, in getresponse

    response.begin()

  File "/usr/lib/python2.7/httplib.py", line 407, in begin

    version, status, reason = self._read_status()

  File "/usr/lib/python2.7/httplib.py", line 397, in _read_status

    raise BadStatusLine(line)

httplib.BadStatusLine: HTTP/1.0 200/OK

-----------------------------------------------------------------------------------------------
I haven't rebooted the pi 'cos Cacti still seems to be working,  but I didn't take a copy of the original
program so can't return to working program (except state of course).
I have tried a few things but am clearly lost.
Any help much appreciated.
Regards
Kim 
garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Old wiki revisions

Kim,

clicking on recent changes in top right of wiki allows you view previous versions.

heres the link showing old python script till this issue is fixed.

 

Garry

 

http://www.dbzoo.com/livebox/xap_cacti?rev=1369793011

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Its not a cacti python scripting bug.

Kim,  That python code for CACTI is correct.  The bug is in your xapCacheWebserverApplet.lua file.  You are running on old version  You should be running something based on version 1.5


  File "/usr/lib/python2.7/httplib.py", line 397, in _read_status

    raise BadStatusLine(line)

httplib.BadStatusLine: HTTP/1.0 200/OK

Now see change:  http://code.google.com/p/livebox-hah/source/detail?spec=svn445&r=423

The latest is in /etc_ro_fs/plugboard/samples

You can either

  • copy over the new applet and modify the VFS section again
  • or make the same code change in your local copy.

Brett

kim
Offline
Throwleigh, United Kingdom
Joined: 1 Dec 2010
Thank you ...

... for both the replies - all working fine.

My jeenode is monitoring the compost bin temperature - getting down to 44 degree celsius - soon be

time for turning!

Regards
Kim 
garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Awesome

That must be a first, the compost node!

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
What a brilliant idea

Looks like i know where my spare node is going literally in the bin :)

Hardware Info