Skip Ribbon Commands
Skip to main content

How to graph TED 5000 data with Cacti

When Google released Google Power a few years ago, I thought it was a cool idea and so I bought a TED 5000 so I could graph my power consumption to help me become more efficient.  Well, like they say, nothing in life is free.  Google shut down the project after a little while and left everyone with no way of graphing the output of the TED 5000's any more.  Well, luckily there's a pretty easy solution to run your own graphing server using Cacti.  Since the TED 5000 web interface allows you to export sensor data as a CSV file, it is very easy to grab this data and graph it with Cacti.  Cacti's native method of grabbing data is SNMP, but the TED 5000 doesn't have an SNMP interface so we need to improvise.  This tutorial will show you how to create a Cacti Script, Data Input Method, Data Template, GPRINT Preset, Graph Template, and Host Template.  This is what my graphs look like, but you can customize them however you like.
 
Power and Cost
Voltage
 
Cacti Script
A single line of code in a shell script can grab the data from the web interface and convert it to the native data format that Cacti expects to see.  The standard Cacti format is Label1:Value1 Label2:Value2.  So create the following shell script in your Cacti scripts directory and make sure you modify the ownership and permissions to make the script executable by the Cacti server.  I use WinSCP because I don't like working in the command line very much.  Name the script TED5000.sh.
 
#!/bin/sh
curl -sm 1 http://$1/history/minutehistory.csv?MTU=$2 | grep -m 1 / | awk -F "," '{print "POWER:"$3" COST:"$4" VOLTAGE:"$5"\r\n"}'
 
Make sure there are only two lines in your script.  The second line starting with the word "curl" is one continuous line.  Once you have the script saved, it's a good idea to test it out.  Use PuTTY to connect to your Cacti server and run the script giving it the IP address of your TED 5000 and the MTU number which will most likely be 0.  You should see something like this:
 
[root@localhost ~]# /var/www/html/scripts/TED5000.sh 192.168.1.5 0
POWER:5.043 COST:0.37 VOLTAGE:117.6
 
Your path to the scripts directory may be different than my path, and the IP address of your TED 5000 is probably different, so adjust accordingly.
 
Data Input Method
The data input method allows you to run the script you just created and use the output as the data to be collected in an RRD file.  Add a new Data Input Method and give it the following parameters:
 
Name: TED 5000
Input Type: Script/Command
Input String: <path_cacti>/scripts/TED5000.sh <hostname> <MTU>
 
Add two Input Fields with the following parameters:
 
Field [Input]: hostname
Friendly Name: IP address of TED 5000
Special Type Code: hostname
 
Field [Input]: MTU
Friendly Name: MTU number, normally 0
 
Add three Output Fields with the following parameters:
 
Field [Output]: COST
Friendly Name: Cost
Update RRD File: Checked
 
Field [Output]: POWER
Friendly Name: Power
Update RRD File: Checked
 
Field [Output]: VOLTAGE
Friendly Name: Voltage
Update RRD File: Checked
 
Data Template
The data template defines which data inputs to pull together into a common data source that can be used to produce graphs.  Add a new Data Template and give it the following parameters:
 
Data Template
Name: TED 5000
Data Source
Name: |host_description| - Power
Data Input Method: TED 5000
Associated RRA's: Select All
Step: 60
Data Source Active: Checked
Data Source Item
Internal Data Source Name: Cost
Maximum Value: 100
Heartbeat: 120
 
Once you click Create, make sure the Output Field matches up with with COST - Cost.  You will need to add two more Date Source Items with the following parameters:
 
Internal Data Source Name: Power
Maximum Value: 100
Heartbeat: 120
Output Field: POWER - Power
 
Internal Data Source Name: Voltage
Maximum Value: 100
Heartbeat: 120
Output Field: VOLTAGE - Voltage
 
In the Custom Data section, check the box for "MTU number, normally 0" fields.  This will allow you to select the MTU when you create the graph.
 
GPRINT Presets
Under Graph Management the option "GPRINT Presets" allow us to define how text is printed on our graphs.  We want to create a preset to allow us to control the number of decimals to be printed in the power graph we are going to build next.  Add two GPRINT Presets with the following parameters:
 
Name: 2 decimals
GPRINT Text: %8.2lf
 
Name: 3 decimals
GPRINT Text: %8.3lf
 
Graph Template
The graph templates allow you to take the data you've collected and turn them into graphs.  You will create two graph templates with the following parameters:
 
Template
Name: TED 5000 Power and Cost
Graph Template
Title: |host_description| - Power and Cost
Vertical Label: Power and Cost
 
Template
Name: TED 5000 Voltage
Graph Template
Title: |host_description| - Voltage
Vertical Label: Voltage
 
Now add the following Graph Template Items to the Power and Cost Template:
 
Data Source: TED 5000 - (Power)
Color: Blue
Graph Item Type: AREA
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: Normal
Text Format: kW
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Power)
Color: None
Graph Item Type: GPRINT
Consolidation Function: LAST
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Current:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Power)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MIN
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Min:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Power)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MAX
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Max:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Power)
Color: None
Graph Item Type: GPRINT
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Average:
Insert Hard Return: Checked
 
Data Source: TED 5000 - (Cost)
Color: Green
Graph Item Type: AREA
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: Normal
Text Format: Cost/hr
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Cost)
Color: None
Graph Item Type: GPRINT
Consolidation Function: LAST
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Current:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Cost)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MIN
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Min:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Cost)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MAX
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Max:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Cost)
Color: None
Graph Item Type: GPRINT
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: 3 decimals
Text Format: Average:
Insert Hard Return: Checked
 
Now add the following Graph Template Items to the Voltage Template:
 
Data Source: TED 5000 - (Voltage)
Color: Red
Graph Item Type: LINE1
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: Normal
Text Format: Voltage
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Voltage)
Color: None
Graph Item Type: GPRINT
Consolidation Function: LAST
CDEF Function: None
GPRINT Type: 2 decimals
Text Format: Current:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Voltage)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MIN
CDEF Function: None
GPRINT Type: 2 decimals
Text Format: Min:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Voltage)
Color: None
Graph Item Type: GPRINT
Consolidation Function: MAX
CDEF Function: None
GPRINT Type: 2 decimals
Text Format: Max:
Insert Hard Return: Unchecked
 
Data Source: TED 5000 - (Voltage)
Color: None
Graph Item Type: GPRINT
Consolidation Function: AVERAGE
CDEF Function: None
GPRINT Type: 2 decimals
Text Format: Average:
Insert Hard Return: Checked
 
Host Template
A host template allows us to pull everything together so when you assign the template to a new device, the graphs are easier to create.  Add a new Host Template with the following parameters:
 
Name: TED 5000
 
Add the two Graph Templates you created earlier to the new Host Template and then you are ready to start graphing data from your TED 5000 again.
 
Create a new device and assign it the "TED 5000" Host Template and select "Ping" and "ICMP Ping" for downed device detection.  And finally, click "Create Graphs for this Host" and select both graphs.  Enter 0 for the MTU.
 
If you have any suggestions on how to improve on this send me an email.