| 768 | | # Now convert the unique CSIDs to raw numbers for the $data hash (missing by channel) |
| 769 | | foreach my $ch (keys %$data) |
| | 761 | &pad_missing_data_hash($data, $start, $end, $interval); |
| | 762 | my $gname = ($component ? 'c_'.$component.'_' : '') . 'missing_by_channel'; |
| | 763 | push @graphs, { GRAPH => &graph_one_count_data($gname, 'Missing Data by Channel', "%a %H:%M", '12 hours', [ values %$data ], 1010, 0, [ keys %$data ]) }; |
| | 764 | |
| | 765 | unless ($component) |
| 771 | | for (my $i = 1; $i < @{$data->{$ch}}; $i += 2) |
| 772 | | { |
| 773 | | if (!defined $data->{$ch}->[$i]) |
| | 767 | &pad_missing_data_hash($gdata, $start, $end, $interval); |
| | 768 | push @graphs, { GRAPH => &graph_one_count_data('missing_by_grabber', 'Missing Data by Grabber', "%a %H:%M", '12 hours', [ values %$gdata ], 1010, 0, [ keys %$gdata ]) }; |
| | 769 | } |
| | 770 | |
| | 771 | $template->param($varname => \@graphs); |
| | 772 | } |
| | 773 | |
| | 774 | # Pad out the hash of 'missing data' with timestamps and 0s to make |
| | 775 | # a timeseries array suitable for graphing |
| | 776 | sub pad_missing_data_hash |
| | 777 | { |
| | 778 | my ($h, $start, $end, $interval) = @_; |
| | 779 | |
| | 780 | foreach my $key (keys %$h) |
| | 781 | { |
| | 782 | print "Key=$key\n"; |
| | 783 | for (my $n = 0; $n <= @{$h->{$key}}; $n += 2) |
| | 784 | { |
| | 785 | my $t = $start + ($n / 2 * $interval); |
| | 786 | print "n=$n, t=$t\n"; |
| | 787 | |
| | 788 | last if ($t >= $end); |
| | 789 | $h->{$key}->[$n] = strftime("%Y-%m-%d %H:%M:%S", localtime($t)); |
| | 790 | if (!defined $h->{$key}->[$n+1]) |
| 783 | | my $gname = 'missing_by_channel'; |
| 784 | | $gname .= ('_' . $component) if ($component); |
| 785 | | push @graphs, { GRAPH => &graph_one_count_data($gname, 'Missing Data by Channel', "%a %H:%M", '12 hours', [ values %$data ], 1010, 0, [ keys %$data ]) }; |
| 786 | | |
| 787 | | # Do something similar for the $gdata hash (missing by component) |
| 788 | | unless ($component) |
| 789 | | { |
| 790 | | foreach my $c (keys %$gdata) |
| 791 | | { |
| 792 | | for (my $n = 0; $n <= @{$gdata->{$c}}; $n += 2) |
| 793 | | { |
| 794 | | my $t = $start + ($n / 2 * $interval); |
| 795 | | last if ($t >= $end); |
| 796 | | $gdata->{$c}->[$n] = strftime("%Y-%m-%d %H:%M:%S", localtime($t)); |
| 797 | | if (!defined $gdata->{$c}->[$n+1]) |
| 798 | | { |
| 799 | | $gdata->{$c}->[$n+1] = 0; |
| 800 | | } |
| 801 | | else |
| 802 | | { |
| 803 | | $gdata->{$c}->[$n+1] = scalar(@{$gdata->{$c}->[$n+1]}); |
| 804 | | } |
| 805 | | } |
| 806 | | } |
| 807 | | push @graphs, { GRAPH => &graph_one_count_data('missing_by_grabber', 'Missing Data by Grabber', "%a %H:%M", '12 hours', [ values %$gdata ], 1010, 0, [ keys %$gdata ]) }; |
| 808 | | } |
| 809 | | |
| 810 | | $template->param($varname => \@graphs); |