From 2e87ac9112cad59864508ceaaf45c5173fe12281 Mon Sep 17 00:00:00 2001 From: hadaq Date: Sun, 6 Feb 2022 19:14:31 +0100 Subject: [PATCH] add JSON dump to HPlot --- tools/HPlot.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/HPlot.pm b/tools/HPlot.pm index 8dd5dcc..3a75d0e 100755 --- a/tools/HPlot.pm +++ b/tools/HPlot.pm @@ -5,6 +5,7 @@ use warnings; use strict; use FileHandle; use Storable qw(lock_store lock_retrieve); +use JSON; my $p; my $storefile; @@ -106,7 +107,7 @@ sub PlotInit { if($p->{$name}->{output} == OUT_PNG) { $p->{$name}->{file} or die "No filename specified"; - plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." truecolor font \"monospace,8\""); + plot_write($fh,"set term png size ".$p->{$name}->{sizex}.",".$p->{$name}->{sizey}." truecolor font \"monospace,9\""); plot_write($fh,"set out \"".$p->{$name}->{file}.($p->{$name}->{buffer}?"tmp":"").".png\""); } elsif($p->{$name}->{output} == OUT_SCREEN) { @@ -361,5 +362,22 @@ sub PlotLimitEntries { $p->{$name}{limitentries} = $entries; } +sub PlotJsonDump { + my ($name,$file) = @_; + waitpid($p->{$name}->{pidJSON},0) if $p->{$name}->{pidJSON}; + my $pid = fork; + unless ($pid) { + my $fh; + my $json = new JSON; + $json = $json->utf8; + $json = $json->allow_unknown(); + open($fh, ">", $file); + print $fh $json->encode($p->{$name}); + close $fh; + exit; + } + $p->{$name}->{pidJSON} = $pid; + + } 1; -- 2.43.0