Arduino, read text file into Cacti

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
User avatar
fundutzi
Posts: 13
Joined: Mon Apr 24, 2006 6:39 am
Location: London, UK
Contact:

Arduino, read text file into Cacti

Post by fundutzi »

Dear All,

I am trying to read a text file and have it graphed with Cacti. I am struggling, will much appreciate some help please.

What I did:
I followed this good tutorial.
Read this page, thank you to Gandalf.
Based on the above, I get the tutorial to draw graphs ok.
But, my own customization to read from txt file draw a blank graph.

The source data looks like this:
1_Epoch:1299621037 2_Raw_light:685
1_Epoch:1299621039 2_Raw_light:683
..-> many rows I put two only

The script file to read the above file looks like this:
=> It seems to print the contents in accordance to the manual`s requirement when I run it from console:
***********
#!/usr/bin/perl -w

open (Arduino, "/home/Arduino.txt");

while ($record = <Arduino>) {
print $record;
}

close(Arduino);
***********

I will much appreciate your help here.

Thank you
Regards
User avatar
fundutzi
Posts: 13
Joined: Mon Apr 24, 2006 6:39 am
Location: London, UK
Contact:

Re: Arduino, read text file into Cacti

Post by fundutzi »

A few days later. Now I wonder, did I not ask clear or polite enough?
Regards
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Re: Arduino, read text file into Cacti

Post by rony »

I'm not sure what part you are struggling with.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
fundutzi
Posts: 13
Joined: Mon Apr 24, 2006 6:39 am
Location: London, UK
Contact:

Re: Arduino, read text file into Cacti

Post by fundutzi »

I do not get the data displayed on the graph read from the file in format:

1_Epoch:1299621037 2_Raw_light:685
1_Epoch:1299621039 2_Raw_light:683
..-> many rows I put two only

Do we perhaps know of any existing script that read multi column data from a file and graph it?
I will very much like to follow your pointer and practice on that.

Thank you.
Regards
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Re: Arduino, read text file into Cacti

Post by rony »

So I'm trying to help here, but I need to understand what type of data we are dealing with here so I can make suggestions.

What is this data?
How do you identify what each data point is?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
fundutzi
Posts: 13
Joined: Mon Apr 24, 2006 6:39 am
Location: London, UK
Contact:

Re: Arduino, read text file into Cacti

Post by fundutzi »

The Arduino board have a number of analog and digital in and outputs.

One can connect a great many devices to these pins reading our giving output in analog or digital.

In this case I am trying to graph pressure in my house water mains over time.
-> The first column is time in EPOC the second is pressure in 100kPA.
-> I am hoping to expand this with light and temperature sensors once I get this working.

These values are read from serial RS232 connected to the machine, put in log file.
The perl script then read the data and I hope to put it into RRD with CACTI so I can graph it.
-> The Arduino board will log data to text log on its own in future. Hence my approach to read data from text file.

I spent a full day working through the RRD tutorials by Tobias Oetiker. That is hard.
I thought I rather learn how to use Cacti to do this, this I always knew I had to learn, that day seem to have come now

The least I can do once this all work is to give a howto back here.

Your help is very much appreciated.

Regards
Regards
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Arduino, read text file into Cacti

Post by Howie »

Cacti is expecting one data point (one time)... it looks like your data is a time series, right? One line per timeslot with different readings?

So you'd probably be better off using the rrdtool command-line tool to update the rrd file - that can fill in older data points and multiple times at once, I believe.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Re: Arduino, read text file into Cacti

Post by rony »

Howie is correct, Cacti is expecting one data point, not a log of data with time stamps.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Arduino, read text file into Cacti

Post by Howie »

As long as the Arduino is logging in realtime, then a simple shell script will do what you need for Cacti though:

Code: Select all

#!/bin/sh

/bin/tail -n1 /var/log/yourlogfile | /bin/cut -d" " -f2-
to take the last line, then strip off the timestamp. Then check out the normal 'script query' tutorial.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
fundutzi
Posts: 13
Joined: Mon Apr 24, 2006 6:39 am
Location: London, UK
Contact:

Re: Arduino, read text file into Cacti

Post by fundutzi »

Thank you, I will do this pm and report my progress.
Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest