Jump to content

Cacti Graphing - Windows


Physpher

Recommended Posts

Posted

This tutorial is based off of zanderl's script. He wrote it and gave the instructions, but I decided to get a step by step out there for everyone to lessen the headaches.

 

1) You will need to get cacti, for Windows I used BSOD2600's "Cacti for Windows installer". This prepares everything you need for you.

2) You will need to install "Python 2.7.3 for Windows"

3) You will need to copy into notepad or equivalent zanderl's script and save it as a .py extension. (http://forum.universal-devices.com/viewtopic.php?f=48&t=5664)

 

4) Configure cacti for your graphs

a) Data Input Method:

i) Name: Insteon

ii) Input Type: Script/Command

iii) Input String: "python C:\Python27\Lib\cacti.py " (python identifies the script type C:\Python27\Lib\cacti.py is the name and location of the script and will be the input for your data) do not put in quotes

iv) Input Field: device

1) Field [input]: select device from the drop down menu

2) Friendly Name: Insteon Device

v) Output Field: level

1) Field [ouput]: level

2) Friendly Name: Level

B) Data Sources:

i) Selected Data Template: None

ii) Host: None

iii) Name: Name of your device

iv) Data Source Path: Leave blank, cacti will auto populate.

v) Data Input Method: Insteon

vi) Associated RRA's: Select how you like to see your graphs (I select all of them)

vii) Step: Default is 300, I personally like 30

viii) Data Source Active: Check

ix) Internal Data Source Name: I used Bryan_Bath_Fan

x) Min and Max Values: U

xi) Data Source Type: Guage

xii) Heartbeat: 600

xiii) Output field: Select level-level from the drop down

xiv) Insteon Device: "00 00 00 00" (This will be in quotations and instead of all 0's use your insteon id for that device. You will make a new Data Source for every device and this is going to be the input for your script)

c) Graph Management:

i) Selected Graph Template: None

ii) Host: None

iii) Title: Whatever you want your graph title to be

iv) Vertical Label: On Level (all other checks and defaults stay the same)

v) Click save

vi) A new header will now appear called Graph Items. Click add to the right

a) Host: None

B) Data Template: None

c) Data Source: Select your Device you had previously setup

d) Graph Item Type: Line 2

e) Consolidation Function: Average (everything else is default)

vii) Save the new Graph Item and your Graph

d) Graph Trees:

i) Add

a) Name: Insteon

B) Add each graph that you had created for each device.

 

That should be it! Remember to save everything on each page before moving onto the next step. I would also recommend going to System Utilities and selecting Rebuild Poller cache. This will bring you to your Poller Cache Items (after it does its thing) and should look something like this:

 

Bryan Bath Fan Script: python C:\Python27\Lib\cacti.py "17 CE 60 1"

RRD: C:\Apache2\htdocs\cacti\rra\\18.rrd

 

 

 

Maybe if I have time in the near future I can take screen shots of everything so you can pretty much copy and paste.

  • 2 weeks later...
Posted

I have created a visual representation as I know that what I posted earlier was a large wall of text. Hopefully this will help out even more as you can see what to put and where without much reading!

 

My imgur gallery:

http://imgur.com/a/BKzqY

Posted

I have gone through this guide several times and it doesn't work for me. I was able to go through all the setup steps but when I look at the graphs, all I see is a broken image icon. I also don't know how to interpret the debug to tell if I should be seeing anything. Any advice?

Posted

what is are you running?

Is python v2.7 installed?

When you run the script do you get on levels for all devices?

When you run the script with the device id do you get the on level only?

 

It sounds like an issue retrieving data from the script.

 

If you get responses then it is a configuration mismatch somewhere.

 

Sent from my HTC ThunderBolt using Tapatalk 2

  • 7 months later...
Posted

Hi Physpher,

 

I finally remembered to get back to this - it really hasn't been keeping me up at night.

 

I did a lot of playing with this yesterday and if I run the script from a command prompt, I get the full list of devices and states if I don't specify a single device. If I specify a single device, I get the level from that device. I felt like I was making progress and managed to even get a couple of graphs, although blank, from a couple of data sources. It definitely looks like the data is not being brought into Cacti, even though the script is clearly working by itself.

 

I can see my devices in the poller cache and even cleared it at least once when I realized I had a duplicate item. I get a whole log full of these:

12/27/2012 02:40:02 PM - CMDPHP: Poller[0] Host[0] DS[45] WARNING: Result from CMD not valid. Partial Result: U
and I even went so far as to switch the poller to spike, which gives a similar message about no results.

 

Any suggestions on which direction to look?

 

Thanks

Posted

Ha, I am literally trying to configure cacti on my new server.

 

I am glad you didn't lose sleep over it, cause I sure have. :P

 

Going through my own tutorial, I failed to get any results, so I am back at square one trying to remember details which I quite simply forgot. With that said, I am currently using this tutorial http://www.cacti.net/downloads/docs/html/how_to.html#SCRIPT_TO_GRAPH while keeping the script and basic idea the same. I now have a graph, but no data in it. Waiting for cacti to poll to see if this method is more straight forward than my own (admittedly) bad descriptions. I will update when I get the kinks worked out.

 

Edit:

 

Alright. So that link worked much better when coming in with a fresh mind. I honestly don't know where I screwed up earlier on in my walkthrough. Only part that is missing (I didn't look over everything so I could very well be wrong here too) is to add your new graph to the graph tree.

Posted

So I think I found one possible cause for your errors in your logs. When I had a device that had a 0 as in '0A' in its address, I had to remove the leading 0. So 'AB CD 0E 1' should look like 'AB CD E 1'. Another issue I caused is make sure in graph management you create a graph item that has a color defined.

 

Sent from my Samsung Galaxy Note 2 using Tapatalk 2

Posted

Okay, I got this working now, but not in Windows. As I have Google, it was probably easier for me to load Ubuntu onto the computer in the kitchen that I never use to look up recipes while cooking, yada yada...

 

Now I can get the data and started making data sources and graphs, when I noticed my thermostat - main was giving me a reading of '158', which didn't seem right to me.


14 27 30 1
Thermostat - Main
31835
5.3.145.0
true
14 27 30 1
C04














 

I see in the response to the REST/Devices command for the thermostat that the formatted data is there, just like I want it. I decide to copy the cacti.py script and modify the copy to ask for 'formatted' where it references 'value' in the original. I test it from my command line, and it appears to work like I want, see the attachment photo:

 

I added another data input method with the new script, and modified the data source for the thermostat-main to use that new method. No luck, it still shows up as '158'.

 

Any ideas what I am missing here?

 

BTW, thanks for all your help so far on this. I figured out the %20 instead of spaces myself, but windows just doesn't want to play with this. I think it's permissions related, which are actually easier to find solutions for on Ubuntu.

post-2270-140474157683_thumb.png

  • 2 weeks later...
Posted

Sorry for the delayed response! Gotta love having sick babies and then getting side tracked.

 

Unfortunately, I do not have the thermostat (yet), and scripting is not quite my thing, so coming up with a fix without screwing with it myself and through trial and error probably won't work too well. I would like to point out that I actually plan on keeping temps and humidity levels tracked in cacti once I get my thermostat. So once I get it, you can bet I will bust my rear trying to get it to work.

 

I do have a very intelligent engineer at work that I will try to see if he can see what's up with it though!

 

Sent from my SCH-I605 using Tapatalk 2

  • 10 months later...
Posted

I never got this working previously, but started to look at it again after another project needed some graphing. I have a guy at my office who knows Cacti stuff, so he put me onto it. I also have more experience with Linux now. I figured out that in the Data Input Method for the Insteon device, I had the incorrect command "/home/jake/cacti/cacti.py ". I changed it to read "python /home/jake/cacti/cacti.py " and now everything works.

 

getting older would suck if I wasn't obviously becoming a genius.

Posted

That has gotten me in the past. I just recently (last week) dove in and put Linux on my server and in turn decided to redo cacti. I found it fairly easy to set up templates for everything. Adding a new device is as simple as naming and inserting your address for the device. Then creating the graph which I would assume would be the same as your name you just used.

  • 1 month later...
Posted

So I managed to get this working and I admit it was more work than I thought. I have used mrtg/rrd in the past and am fairly familiar with linux.

 

I first followed a ubuntu/cacti guide to make sure I had a working instance of cacti, this is a good recent guide: https://www.digitalocean.com/community/ ... oud-server

 

Then I used the script attached here but modified it so I could pass device names and not addresses. The risk here is that if I rename my device I will loose my graph but I'm ok with that.

 

I also used Cacti Data Templates and Graph Templates to ease adding new devices. I think you would need to be insane to not use templates if you are graphing more than 2 items.

 

With the templates and variables setup all you need to do is copy your quoted device name in the data source once and all your data sources and graphs will auto populate.

 

Here is my modified source and templates:

#!/usr/bin/python

import urllib2
import sys
import xml.etree.ElementTree as ET

username = 'user'
password = 'pass'
host = '192.168.10.1'
url = "http://%s" % host


auth_handler = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth_handler.add_password(None, uri=url,user=username,passwd=password)
handler = urllib2.HTTPBasicAuthHandler(auth_handler)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)


def get_lookup():

   response=urllib2.urlopen('%s/rest/nodes/devices' % url)
   Lookup={}
   mytree = ET.parse(response)

   for elem in mytree.findall('node'):
       Lookup[elem.find('name').text] = [elem.find('address').text,elem.find('property').get('value')]

   return Lookup


def get_values():

   Lookup = get_lookup()

   if len(sys.argv) == 1:
       for k,v in sorted(Lookup.items()):
           print "%-30s: %s" % (k,v)

   else:
       address = Lookup[sys.argv[1]][0]

       response=urllib2.urlopen('%s/rest/nodes/%s' % (url,address.replace(' ','%20')))
       mytree = ET.parse(response)
       elem = mytree.findall('node')[0]
       print elem.find('property').get('value')


get_values()

 

Data Template

p0tsjZS.png

 

Graph Template

E0V4bPV.png

Posted
So I managed to get this working and I admit it was more work than I thought. I have used mrtg/rrd in the past and am fairly familiar with linux.

 

I first followed a ubuntu/cacti guide to make sure I had a working instance of cacti, this is a good recent guide: https://www.digitalocean.com/community/ ... oud-server

 

Then I used the script attached here but modified it so I could pass device names and not addresses. The risk here is that if I rename my device I will loose my graph but I'm ok with that.

 

I also used Cacti Data Templates and Graph Templates to ease adding new devices. I think you would need to be insane to not use templates if you are graphing more than 2 items.

 

With the templates and variables setup all you need to do is copy your quoted device name in the data source once and all your data sources and graphs will auto populate.

 

Here is my modified source and templates:

#!/usr/bin/python

import urllib2
import sys
import xml.etree.ElementTree as ET

username = 'user'
password = 'pass'
host = '192.168.10.1'
url = "http://%s" % host


auth_handler = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth_handler.add_password(None, uri=url,user=username,passwd=password)
handler = urllib2.HTTPBasicAuthHandler(auth_handler)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)


def get_lookup():

   response=urllib2.urlopen('%s/rest/nodes/devices' % url)
   Lookup={}
   mytree = ET.parse(response)

   for elem in mytree.findall('node'):
       Lookup[elem.find('name').text] = [elem.find('address').text,elem.find('property').get('value')]

   return Lookup


def get_values():

   Lookup = get_lookup()

   if len(sys.argv) == 1:
       for k,v in sorted(Lookup.items()):
           print "%-30s: %s" % (k,v)

   else:
       address = Lookup[sys.argv[1]][0]

       response=urllib2.urlopen('%s/rest/nodes/%s' % (url,address.replace(' ','%20')))
       mytree = ET.parse(response)
       elem = mytree.findall('node')[0]
       print elem.find('property').get('value')


get_values()

 

Data Template

p0tsjZS.png

 

Graph Template

E0V4bPV.png

 

I just threw your script on my server and after playing with it (I initially forgot to change the port number) got it working just peachy. In fact, I think I will start using your script so I don't have to pull up mobilinc or a browser to check device addresses. Thanks for sharing!

 

It is a minor brain work out to get it going the first time... and the second. Glad you got it working. I do have one question though, how'd you get your 'host_description' working correctly? I leave mine as 'none', though I do have cacti pinging the ISY to check up/down status. I can work my way around cacti, but I am no pro with it. Thanks in advance!

Posted

I setup a new device under 'Devices' and added all my data sources under that device. I don't think there is any relationship there but it seems cleaner to me. It just gives you the ability to use the variables.

 

You could pass the ip variable from cacti to the python script so you would only need to change it in once place if you updated the ip of your ISY.

 

Devices:

y8Qb4pZ.png

Posted

Thanks again! After playing around and looking at your screenshots, I noticed you are using the 0-255 range. If you set up CDEFs for your graph template you can get the human readable 0-100 range. Here is how mine is set up:

 

Item Item Value

Item #1 Special Data Source: CURRENT_DATA_SOURCE

Item #2 Custom String: 2.55

Item #3 Operator: /

Posted
Thanks again! After playing around and looking at your screenshots, I noticed you are using the 0-255 range. If you set up CDEFs for your graph template you can get the human readable 0-100 range. Here is how mine is set up:

 

Item Item Value

Item #1 Special Data Source: CURRENT_DATA_SOURCE

Item #2 Custom String: 2.55

Item #3 Operator: /

 

I'm not sure it matters if you use 100 or 255 since you are really just graphing on/off. I suppose 255 is closer to '1' than 100 as 255 is 11111111 binary.

 

Thanks

Posted

It doesn't matter in the end, just a nice thing to have in my opinion. I do have a good mixture of ON/OFF and dimming devices though which was my reasoning behind it. Now, just to get a thermostat so I can graph temperatures 8) .

 

j46Xmjr.png

 

Side note, I need to get rid of my HRULE as my graphs will never go over 100. Probably the same with the "Average" field.

  • 3 months later...
Posted
I'm going to have to look at this. Especially with the ability to update ISY variables as well.

 

What are you speaking of? The nest or the cacti graphing?

 

Sent from my Nexus 7 using Tapatalk

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.5k
×
×
  • Create New...