Re: Collecting Data in an Output File
From: Errin Larsen (errinlarsen_at_gmail.com)
Date: 08/31/04
- Next message: Wiggins d Anconia: "Re: Questions regarding use: "optional" modules, and "refreshing" modules"
- Previous message: Gavin Henry: "RE: Could this be made shorter and cleaner?"
- In reply to: Chris Devers: "Re: Collecting Data in an Output File"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 14:25:31 -0500 To: cdevers@pobox.com
On Tue, 31 Aug 2004 14:07:14 -0400 (EDT), Chris Devers
<cdevers@pobox.com> wrote:
> On Tue, 31 Aug 2004, Errin Larsen wrote:
>
> > I am collecting temperature data from the CPUs in my system.
<<SNIP>>
> This is nitpicking, but have you considered inverting that? A format
> like this might be easier to work with:
>
> time,cpu1,cpu2,cpu3
> Tue Aug 31 12:00:00 EDT 2004,65,65,64
> Tue Aug 31 13:00:00 EDT 2004,63,64,65
> Tue Aug 31 14:00:00 EDT 2004,62,64,66
> Tue Aug 31 15:00:00 EDT 2004,64,62,64
>
> This way, you can simply append to the file with the timestamp and the
> readings from each of the CPUs you're monitoring, rather than having to
> open the file and append to each line.
>
> The downside is that if you add CPUs, the file falls apart because you
> need to add / change / remove a column. The fix for this is to just have
> one CPU per line, and identify it:
>
> time,cpu,temp
> Tue Aug 31 12:00:00 EDT 2004,cpu1,65
> Tue Aug 31 12:00:00 EDT 2004,cpu2,65
> Tue Aug 31 12:00:00 EDT 2004,cpu3,64
> ...
>
> This is more verbose, obviously, but also more flexible.
The above is good stuff. I'll work on this. There are some problems,
but I'll get to them below.
>
> > How can I read in all the lines into their on arrays and add some data
> > to the end?
>
> For the one I've got above, it would be something like...
>
> while ( <> ) {
> my ($ts, $cpu, $temp) = split("," $_);
> push (@{ $processors{$cpu} }, $temp);
> }
>
> Then to get at the data, do something like
>
> foreach $cpu ( sort keys %processors ) {
> print "$cpu: @{ $processors{ $cpu }}\n"
> }
>
> ...or something like that...
<<SNIP>>
Thanks Chris. This is the sort of thing I was looking for! Now I'll
go play with your suggestions some. The problem I'm gonna have is
that the file format I suggested is really what I need. HOWEVER, I
don't need that format when I'm collecting the data, just when I get
ready to use that data. So I think I'll try collecting it as you
suggest in the 2nd suggestion above, and then work on a script that
will convert THAT file into the format I need. Thanks again!
--Errin
- Next message: Wiggins d Anconia: "Re: Questions regarding use: "optional" modules, and "refreshing" modules"
- Previous message: Gavin Henry: "RE: Could this be made shorter and cleaner?"
- In reply to: Chris Devers: "Re: Collecting Data in an Output File"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|