From 84906ba869f1d3e212c039b81607bb20eaf44439 Mon Sep 17 00:00:00 2001 From: "hadaq@countinghouse" Date: Fri, 4 Jul 2014 16:33:58 +0200 Subject: [PATCH] Added automatic storage of plot histograms for long-running HPlot diagrams. --- hmon/HPlot.pm | 24 ++++++++- hmon/QA.pm | 2 +- hmon/doc/server-icinga.htt | 2 +- hmon/hmon_busynew.pl | 2 + hmon/hmon_rate2.pl | 4 +- hmon/hmon_starthist.pl | 86 +++++++++++++++--------------- hmon/hmon_startmon.pl | 0 hmon/hmon_trgsource.pl | 26 ++++----- hmon/permanent/hmon_mdchv.pl | 3 ++ hmon/permanent/hmon_mdcpressure.pl | 5 ++ hmon/permanent/hmon_pionlv.pl | 2 + hmon/permanent/hmon_pionsupply.pl | 2 + hmon/permanent/hmon_richhv.pl | 2 + hmon/permanent/hmon_vertexplots.pl | 15 ++++-- 14 files changed, 108 insertions(+), 67 deletions(-) mode change 100755 => 100644 hmon/hmon_startmon.pl diff --git a/hmon/HPlot.pm b/hmon/HPlot.pm index 0c3d79c..a4c55ff 100755 --- a/hmon/HPlot.pm +++ b/hmon/HPlot.pm @@ -4,8 +4,10 @@ use Data::Dumper; use warnings; use strict; use FileHandle; +use Storable qw(lock_store lock_retrieve); my $p; +my $storefile; use constant {TYPE_HISTORY => 1, TYPE_BARGRAPH => 2, TYPE_HEATMAP => 3}; @@ -40,11 +42,11 @@ sub PlotInit { my $name = $c->{name}; my $fn = "gnuplot"; - my $fh = new FileHandle ("|$fn") or die "error: no gnuplot"; + #my $fh = new FileHandle ("|$fn") or die "error: no gnuplot"; + open my $fh, "|$fn" or die "error: no gnuplot"; $fh->autoflush(1); - $p->{$name} = $c; $p->{$name}->{fh} = $fh; $p->{$name}->{run} = 0; @@ -58,12 +60,25 @@ sub PlotInit { $p->{$name}->{output} or die "No destination specified"; $p->{$name}->{colors} = $p->{$name}->{colors} || \@color; $p->{$name}->{showvalues} = $p->{$name}->{showvalues} || 0; + $p->{$name}->{storable} = $p->{$name}->{storable} || 0; + + my $filename = $p->{$name}->{file}; + $filename =~ s%/%%; + $storefile->{$name} = "/dev/shm/".$name.'-'.$p->{$name}->{curves}.'-'.$p->{$name}->{entries}.'-'.$filename.'.store'; + foreach my $i (0..($c->{entries}-1)) { for my $j (0..($c->{curves}-1)) { push(@{$p->{$name}->{value}->[$j]},0) ; } } + + if($p->{$name}->{storable}) { + if (-e $storefile->{$name}) { + $p->{$name}->{value} = lock_retrieve($storefile->{$name}); + } + } + if($p->{$name}->{output} == OUT_PNG) { $p->{$name}->{file} or die "No filename specified"; @@ -233,6 +248,11 @@ sub PlotDraw { $p->{$name}->{run}++; + + + if($p->{$name}->{storable}) { + lock_store($p->{$name}->{value},$storefile->{$name}); + } } diff --git a/hmon/QA.pm b/hmon/QA.pm index d523caf..5852b8d 100644 --- a/hmon/QA.pm +++ b/hmon/QA.pm @@ -34,7 +34,7 @@ our $entries->{'cats'} = ["main", # Order of entries in each cat $entries->{'main'} = ['time', 'rate','onlineqa','up']; $entries->{'daq'} = ['trbnet', 'timeouts', 'busy','readout']; -$entries->{'trg'} = ['spill', 'source','pt1rate', 'start']; #, 'accepted' +$entries->{'trg'} = ['spill', 'accepted', 'source','pt1rate', 'start']; #, $entries->{'rate'} = ['pt1','start','hodo','pion1','pion2']; $entries->{'server'} = ['fill', 'cpu', 'icinga', 'etrax', 'pwrsup']; $entries->{'eb'} = ['run', 'rate','bytes', 'lostevt', 'errbits']; diff --git a/hmon/doc/server-icinga.htt b/hmon/doc/server-icinga.htt index ca22f67..72ae5de 100644 --- a/hmon/doc/server-icinga.htt +++ b/hmon/doc/server-icinga.htt @@ -9,6 +9,6 @@ This field shows if the Icinga Server is up and checks its status. In case of an error (red field), please take a look to the Icinga tactical overview. An eMail is automatically sent to a DAQ-expert, who should know how to proceed. - +

A DAQ restart will not change the situation.

An overview of the different servers and services monitored is given in the HADES Wiki. diff --git a/hmon/hmon_busynew.pl b/hmon/hmon_busynew.pl index aad7af1..4677182 100755 --- a/hmon/hmon_busynew.pl +++ b/hmon/hmon_busynew.pl @@ -38,6 +38,7 @@ $plot->{xscale} = 8; $plot->{ymin} = -1; $plot->{ymax} = 101; $plot->{buffer} = 1; +$plot->{storable} = 1; HPlot::PlotInit($plot); my $plot2 = (); @@ -65,6 +66,7 @@ $plot2->{bartitle}->[7] = "St2"; $plot2->{bartitle}->[8] = "St3"; $plot2->{bartitle}->[9] = "Pi"; $plot2->{buffer} = 1; +$plot2->{storable} = 0; HPlot::PlotInit($plot2); my $str = Hmon::MakeTitle(12,9,"Busy Times",0); diff --git a/hmon/hmon_rate2.pl b/hmon/hmon_rate2.pl index 3673031..a24f31c 100755 --- a/hmon/hmon_rate2.pl +++ b/hmon/hmon_rate2.pl @@ -136,8 +136,8 @@ while (1) { $state, 'Start Rate', $shorttext, $longtext); $state = QA::OK; - $shorttext = QA::SciNotation(($store{0xa03c}-220)/(($store{0xa037}-780)||1)); - $longtext = sprintf("Trigger Rate from PT1/TOF vs. Hodoscope: %.2f",($store{0xa03c}-220)/(($store{0xa037}-780)||1)); + $shorttext = QA::SciNotation(($store{0xa03c}-8)/(($store{0xa037}-2100)||1)); + $longtext = sprintf("Trigger Rate from PT1/TOF vs. Hodoscope: %.2f",($store{0xa03c}-8)/(($store{0xa037}-2100)||1)); QA::WriteQALog($fqa, "trg", "pt1rate", 10, $state, 'Hodo/PT1', $shorttext, $longtext); diff --git a/hmon/hmon_starthist.pl b/hmon/hmon_starthist.pl index 9e7fc0f..3556c37 100755 --- a/hmon/hmon_starthist.pl +++ b/hmon/hmon_starthist.pl @@ -22,49 +22,49 @@ if($plots) { $str .= Hmon::MakeFooter(); Hmon::WriteFile("HodoFineHist",$str); - - while(1) { - my $binning = trb_register_read(3,0xa0c8) or sleep 5 and next; - my $offset = trb_register_read(3,0xa0c6) or sleep 5 and next; - my $select = trb_register_read(3,0xa0da) or sleep 5 and next; - -# print $binning->{3}."\n"; - $binning = $binning->{3}*100E-9; -# print $binning."\n"; - $binning = QA::SciNotation($binning); -# print $binning."\n"; - $offset = QA::SciNotation($offset->{3}*100E-9); - my $selx = "err"; - my $sely = "err"; - $selx = "X 0-7" if ($select->{3} & 0x3) == 0; - $selx = "X 4-11" if ($select->{3} & 0x3) == 1; - $selx = "X 8-15" if ($select->{3} & 0x3) == 2; - $sely = "Y 0-7" if ($select->{3} & 0xC) == 0; - $sely = "Y 4-11" if ($select->{3} & 0xC) == 4; - $sely = "Y 8-15" if ($select->{3} & 0xC) == 8; - - - - $str = Hmon::MakeTitle(10,16,"Start Histogram",0); - $str .= qq@ - Offset: @.$offset.qq@s - Binning: @.$binning.qq@s - Inputs: $selx, $sely -
- - @; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("Starthist",$str); - - $str = Hmon::MakeTitle(10,16,"Start Histogram",0); - $str .= qq@ - Offset: @.$offset.qq@s - Binning: @.$binning.qq@s - Inputs: $selx, $sely -
- - @; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("StarthistStacked",$str); - - sleep(5); - } +# +# while(1) { +# my $binning = trb_register_read(3,0xa0c8) or sleep 5 and next; +# my $offset = trb_register_read(3,0xa0c6) or sleep 5 and next; +# my $select = trb_register_read(3,0xa0da) or sleep 5 and next; +# +# # print $binning->{3}."\n"; +# $binning = $binning->{3}*100E-9; +# # print $binning."\n"; +# $binning = QA::SciNotation($binning); +# # print $binning."\n"; +# $offset = QA::SciNotation($offset->{3}*100E-9); +# my $selx = "err"; +# my $sely = "err"; +# $selx = "X 0-7" if ($select->{3} & 0x3) == 0; +# $selx = "X 4-11" if ($select->{3} & 0x3) == 1; +# $selx = "X 8-15" if ($select->{3} & 0x3) == 2; +# $sely = "Y 0-7" if ($select->{3} & 0xC) == 0; +# $sely = "Y 4-11" if ($select->{3} & 0xC) == 4; +# $sely = "Y 8-15" if ($select->{3} & 0xC) == 8; +# +# +# +# $str = Hmon::MakeTitle(10,16,"Start Histogram",0); +# $str .= qq@ +# Offset: @.$offset.qq@s - Binning: @.$binning.qq@s - Inputs: $selx, $sely +#
+# +# @; +# $str .= Hmon::MakeFooter(); +# Hmon::WriteFile("Starthist",$str); +# +# $str = Hmon::MakeTitle(10,16,"Start Histogram",0); +# $str .= qq@ +# Offset: @.$offset.qq@s - Binning: @.$binning.qq@s - Inputs: $selx, $sely +#
+# +# @; +# $str .= Hmon::MakeFooter(); +# Hmon::WriteFile("StarthistStacked",$str); +# +# sleep(5); +# } } else { qx(./hmon_hadplot_old.sh -d 3000 \\ diff --git a/hmon/hmon_startmon.pl b/hmon/hmon_startmon.pl old mode 100755 new mode 100644 diff --git a/hmon/hmon_trgsource.pl b/hmon/hmon_trgsource.pl index dfc297c..030a273 100755 --- a/hmon/hmon_trgsource.pl +++ b/hmon/hmon_trgsource.pl @@ -60,20 +60,20 @@ my $str = Hmon::MakeTitle(8,5,"Start Counts per Spill (millions)",0); my $plot2 = (); -$plot2->{name} = "Pt3AcceptRatio"; -$plot2->{file} = "files/Pt3AcceptRatio"; +$plot2->{name} = "Pt1AcceptRatio"; +$plot2->{file} = "files/Pt1AcceptRatio"; $plot2->{entries} = 40; $plot2->{type} = HPlot::TYPE_HISTORY; $plot2->{output} = HPlot::OUT_PNG; $plot2->{titles}->[0] = ""; $plot2->{xlabel} = "Spill Number"; -$plot2->{ylabel} = "accepted PT3 Ratio"; +$plot2->{ylabel} = "accepted PT1 Ratio"; $plot2->{sizex} = 630; $plot2->{sizey} = 220; $plot2->{nokey} = 1; HPlot::PlotInit($plot2); - $str = Hmon::MakeTitle(8,5,"PT3 accepted over total PT3 per spill (%)",0); - $str .= qq@@; + $str = Hmon::MakeTitle(8,5,"PT1 accepted over total PT1 per spill (%)",0); + $str .= qq@@; $str .= Hmon::MakeFooter(); Hmon::WriteFile("Pt3AcceptRatio",$str); @@ -207,17 +207,17 @@ my $longmsgcheck = $longmsg; $accpt3sum = 0; } else { - $pt3sum += $rStat->{3}->[0x4c] || 0; - $accpt3sum += $rStat->{3}->[0x39] || 0; #was 0x5D + $pt3sum += $rStat->{3}->[0x4a] || 0; + $accpt3sum += $rStat->{3}->[0x37] || 0; #was 0x5D } - $accmsg = sprintf("%i%% / %i%%", $rStat->{3}->[0x4c]/($rStat->{3}->[0x39]||1)*100, $lastaccpt3 || 0); + $accmsg = sprintf("%i%% / %i%%", $rStat->{3}->[0x4a]/($rStat->{3}->[0x37]||1)*100, $lastaccpt3 || 0); my $qastateacc = QA::OK; QA::WriteQALog($fqa, "trg", "source", 10, $qastate, "Trigger Source", $msg, $longmsg); - QA::WriteQALog($fqa, "trg", "accepted", 10, $qastateacc, "Accept. PT3", $accmsg, $acclmsg); + QA::WriteQALog($fqa, "trg", "accepted", 10, $qastateacc, "Accept. PT1", $accmsg, $acclmsg); my $qastatept = QA::OK; - my $ptoverStattart = $rStat->{3}->[0x26]/($rStat->{3}->[0x2c] || 1)*100; + my $ptoverStattart = $rStat->{3}->[0x24]/($rStat->{3}->[0x2c] || 1)*100; if ($ptoverStattart > 100) {$ptoverStattart = 100;} ###################################### ## QA check for PT3/Start rate @@ -226,10 +226,10 @@ my $longmsgcheck = $longmsg; } ###################################### my $ptmsg = ""; - $ptmsg = sprintf("%s/s / %1.2f%%",QA::SciNotation($rStat->{3}->[0x26]),$ptoverStattart) if $ptoverStattart<=10; + $ptmsg = sprintf("%s/s / %1.2f%%",QA::SciNotation($rStat->{3}->[0x24]),$ptoverStattart) if $ptoverStattart<=10; $ptmsg = sprintf("%i/s / %1.1f%%",$rStat->{3}->[0x26],$ptoverStattart) if $ptoverStattart> 10; - my $ptlongmsg = sprintf("PT3 counts per second: %i - PT3 / Start: %1.2f%%", $rStat->{3}->[0x26], $ptoverStattart); - QA::WriteQALog($fqa, "trg", "ptrate", 10, $qastatept, "PT3 / Start", $ptmsg, $ptlongmsg); + my $ptlongmsg = sprintf("PT1 counts per second: %i - PT1 / Start: %1.2f%%", $rStat->{3}->[0x24], $ptoverStattart); + QA::WriteQALog($fqa, "trg", "ptrate", 10, $qastatept, "PT1 / Start", $ptmsg, $ptlongmsg); my $startsum = 0; diff --git a/hmon/permanent/hmon_mdchv.pl b/hmon/permanent/hmon_mdchv.pl index 7285575..f6384e6 100755 --- a/hmon/permanent/hmon_mdchv.pl +++ b/hmon/permanent/hmon_mdchv.pl @@ -44,6 +44,8 @@ foreach my $s (0..1) { $plot[$p*2+$s]->{dots} = 1; $plot[$p*2+$s]->{colors} = \@colors; $plot[$p*2+$s]->{buffer} = 1; + $plot[$p*2+$s]->{storable} = 1; + foreach my $c (0..5) { $plot[$p*2+$s]->{titles}->[$c] = ($s?'F ':'C ').$names[$c]; } @@ -63,6 +65,7 @@ foreach my $s (0..1) { $plot[$p*2+$s+8]->{dots} = 1; $plot[$p*2+$s+8]->{colors} = \@colors; $plot[$p*2+$s+8]->{buffer} = 1; + $plot[$p*2+$s+8]->{storable} = 1; foreach my $c (0..5) { $plot[$p*2+$s+8]->{titles}->[$c] = ($s?'F ':'C ').$names[$c]; } diff --git a/hmon/permanent/hmon_mdcpressure.pl b/hmon/permanent/hmon_mdcpressure.pl index 7bf3f49..29456b3 100755 --- a/hmon/permanent/hmon_mdcpressure.pl +++ b/hmon/permanent/hmon_mdcpressure.pl @@ -33,6 +33,7 @@ $plot->{ymin} = 950; $plot->{ymax} = 1050; $plot->{nokey} = 1; $plot->{buffer} = 1; +$plot->{storable} = 1; HPlot::PlotInit($plot); @@ -51,6 +52,7 @@ $plot2->{sizey} = 220; $plot2->{nokey} = 0; $plot2->{curves} = 2; $plot2->{buffer} = 1; +$plot2->{storable} = 1; HPlot::PlotInit($plot2); my $plotPrePlane1 = (); @@ -73,6 +75,7 @@ $plotPrePlane1->{nokey} = 0; $plotPrePlane1->{curves} = 6; $plotPrePlane1->{buffer} = 1; $plotPrePlane1->{xscale}; +$plotPrePlane1->{storable} = 1; HPlot::PlotInit($plotPrePlane1); my $plotPrePlane2 = (); @@ -94,6 +97,7 @@ $plotPrePlane2->{sizey} = 220; $plotPrePlane2->{nokey} = 0; $plotPrePlane2->{curves} = 6; $plotPrePlane2->{buffer} = 1; +$plotPrePlane2->{storable} = 1; HPlot::PlotInit($plotPrePlane2); @@ -116,6 +120,7 @@ $plotPrePlane3->{sizey} = 220; $plotPrePlane3->{nokey} = 0; $plotPrePlane3->{curves} = 6; $plotPrePlane3->{buffer} = 1; +$plotPrePlane3->{storable} = 1; HPlot::PlotInit($plotPrePlane3); diff --git a/hmon/permanent/hmon_pionlv.pl b/hmon/permanent/hmon_pionlv.pl index 78cd8c6..a57d14e 100644 --- a/hmon/permanent/hmon_pionlv.pl +++ b/hmon/permanent/hmon_pionlv.pl @@ -41,6 +41,8 @@ $plot->{xlabel} = "Seconds"; $plot->{ylabel} = "mA"; $plot->{sizex} = 630; $plot->{sizey} = 220; +$plot->{storable}= 1; + HPlot::PlotInit($plot); diff --git a/hmon/permanent/hmon_pionsupply.pl b/hmon/permanent/hmon_pionsupply.pl index 38d1e43..879289e 100755 --- a/hmon/permanent/hmon_pionsupply.pl +++ b/hmon/permanent/hmon_pionsupply.pl @@ -21,6 +21,7 @@ $plot->{ylabel} = "Volt"; $plot->{sizex} = 630; $plot->{sizey} = 220; $plot->{ymax} = 200; +$plot->{storable}= 1; HPlot::PlotInit($plot); @@ -38,6 +39,7 @@ $plot2->{xlabel} = "Entries (~0.5h total)"; $plot2->{ylabel} = "Microampere"; $plot2->{sizex} = 630; $plot2->{sizey} = 220; +$plot2->{storable}= 1; HPlot::PlotInit($plot2); while(1) { diff --git a/hmon/permanent/hmon_richhv.pl b/hmon/permanent/hmon_richhv.pl index 910b8d2..90d8fb8 100755 --- a/hmon/permanent/hmon_richhv.pl +++ b/hmon/permanent/hmon_richhv.pl @@ -29,6 +29,7 @@ my $plot = { curves => 6, xscale => 4, colors => ["#333333","#00ff00","#ff0000","#0000ff","#dddd00","#dd00dd"]}; +$plot->{storable}= 1; HPlot::PlotInit($plot); my $plot2 = { @@ -45,6 +46,7 @@ my $plot2 = { curves => 6, xscale => 30, colors => ["#333333","#00ff00","#ff0000","#0000ff","#dddd00","#dd00dd"]}; +$plot2->{storable}= 1; HPlot::PlotInit($plot2); diff --git a/hmon/permanent/hmon_vertexplots.pl b/hmon/permanent/hmon_vertexplots.pl index f3950be..4bf00a9 100755 --- a/hmon/permanent/hmon_vertexplots.pl +++ b/hmon/permanent/hmon_vertexplots.pl @@ -29,25 +29,30 @@ while(1) { $out .= ""; - my $cmd = "ls -rt /home/hadaq/trbsoft/daq/hmon/vertex/target_*e*.jpg | tail -n 5"; + my $cmd = "ls -rt /home/hadaq/trbsoft/daq/hmon/vertex/target_*.jpg | tail -n 5"; my @files = qx($cmd); @files = reverse @files; - $cmd = "ls -rt /home/hadaq/trbsoft/daq/hmon/vertex/targetSum10*e*.jpg | tail -n 5"; + $cmd = "ls -rt /home/hadaq/trbsoft/daq/hmon/vertex/targetSum*.jpg | tail -n 5"; my @files2 = qx($cmd); @files2 = reverse @files2; foreach my $i (0..(scalar @files)-1) { + next if scalar @files == 0; $out .= "
"; my @n = split('/',$files[$i]); chop $n[-1]; - my ($y,$d,$h,$m,$s) = $n[-1] =~ /.*_[\w-][\w-](\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d)_.*/; + my ($y,$d,$h,$m,$s) = $n[-1] =~ /.*_(\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d)_.*/; $out .= qq@20$y-$d $h:$m:$s
@; + } + + foreach my $i (0..(scalar @files2)-1) { + next if scalar @files2 == 0; $out .= "
"; - @n = split('/',$files2[$i]); + my @n = split('/',$files2[$i]); chop $n[-1]; - my ($y1,$d1,$h1,$m1,$s1,$y2,$d2,$h2,$m2,$s2) = $n[-1] =~ /.*_[\w-][\w-](\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d)-[\w-][\w-](\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d).*/; + my ($y1,$d1,$h1,$m1,$s1,$y2,$d2,$h2,$m2,$s2) = $n[-1] =~ /.*_(\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d)-[\w-][\w-](\d\d)(\d\d\d)(\d\d)(\d\d)(\d\d).*/; $out .= qq@20$y1-$d1 $h1:$m1:$s1 - $h2:$m2:$s2
\n@; } -- 2.43.0