mkdir "$dir/gnuplot" unless -e "$dir/gnuplot";
my $png = "$dir/gnuplot/$name"; # FIXME
- open(my $gnuplot, '|-', 'gnuplot') || die "gnuplot: $!";
- open($gnuplot, '>', '/tmp/gnuplot') if $self->param('debug');
-
my @c = @{ $ret->{columns} };
warn "first column not timestamp" unless shift @c eq 'timestamp';
- print $gnuplot qq|
+ my $gnuplot = qq|
set terminal png
set output '$png'
set xdata time
-set timefmt "%Y-%m-%d %H:%M:%S"
-set format x "%H%M%S"
+set timefmt "%Y-%m-%dT%H:%M:%S"
+set format x "%H:%M\\n%d"
-plot '-' using 1:3 title "$c[0]"
+plot '-' using 1:2 title "$c[0]"
|;
foreach my $row ( @{ $ret->{rows} } ) {
- print $gnuplot join("\t", @$row),"\n";
+ my $date = shift @$row;
+ $date =~ s/ /T/g;
+ $date =~ s/\.\d+//;
+ $gnuplot .= join(" ", $date, @$row)."\n";
}
- print $gnuplot "e\n";
- close($gnuplot);
+ $gnuplot .= "e\n";
+
+ open(my $fd, '|-', 'gnuplot') || die "gnuplot: $!";
+ print $fd $gnuplot;
+ close($fd);
- $self->render('gnuplot', sql => $sql, img => "/gnuplot/$name");
+ $self->render('gnuplot', sql => $sql, img => "/gnuplot/$name", gnuplot => $gnuplot);
};
get '/_redis' => sub {
Gnuplot graphs:
<ul>
+<li><a href="/gnuplot?sql=select start,ping_ok,ping_error from poll">poll stats</a>
<li><a href="/gnuplot?sql=select timestamp,rtt from ping where ip << inet '10.17/16' order by timestamp desc limit 1000">ttl from 10.17 network</a>
</ul>
<%= submit_button %>
<% end %>
<img src="<%= $img %>">
+<pre><%= $gnuplot %></pre>
@@ layouts/default.html.ep
<!doctype html><html>