No, the problem isn’t buffering, it’s actually the opposite, when adamon starts up
it writes the header, then does its processing, when the 5*1 seconds are over
the actual output is written.
Possible workaround:
adamon db=14 int=1 loops=5 >adamon.txt; cat adamon.txt | while read line; do echo `date '+%H:%M:%S'` "$line"; done
Oh no! Not again. We went to 6.1.10 only half a year ago. The last relevant bug was fixed on 2011-10-24.
But back on topic: I want to run adamon half a day and log the information automatically into a file. So in reality it will be interval=10 loops=4320.
And then the next problem is:
10sec * 4320 loops doesn’t make 12h exactly. Yesterday’s example:
I think adamon needs a small amount of runtime for maesurement between the loops. So it’s not enough to write a script which adds the interval to a time variable for each line.
But maybe I got a solution… let me try something out.
I think my script works! 8)
Here’s the regarding code snippet (in perl). OK. It’s weird, but it’s working. Of course you can write it as a bash-script, too.
#!/usr/bin/perl
use strict;
my $opt_i=10; # interval in seconds
my $firststat=1;
my $timenow = my $timeflush = my $timeoldflush = time();
while (<>) { # read adamon-output from STDIN
print if (/%ADAMON/);
if (/^[0-9 ]{43}([0-9 ]{3}%| - )[0-9 ]{7} /) { # stat line
if ($firststat) {$firststat=0; next}; # skip 1st line
if ($timeflush + 1 < time()) { # time ajustment
$timeoldflush=$timeflush;
$timeflush=time();
}
if ($timenow < $timeoldflush) {
$timenow = $timeoldflush + $opt_i;
} else {
$timenow+=$opt_i;
}
my @timevals=(localtime $timenow)[0..5]; # convert unix-time
$timevals[5]+=1900; $timevals[4]+=1;
printf("%04d-%02d-%02d %02d:%02d:%02d %s",reverse (@timevals), $_);
}
}