Legend:
- Unmodified
- Added
- Removed
-
shepherd
r145 r146 89 89 # if there is more than this, we will continue asking grabbers for more 90 90 # programming on this channel 91 $policy{peak_max_missing} = 1 0*60; # up to 10mins max allowed missing91 $policy{peak_max_missing} = 15*60; # up to 15 mins max allowed missing 92 92 $policy{peak_start} = (16*(60*60))+(30*60); # 4.30pm 93 93 $policy{peak_stop} = (23*(60*60))+(30*60); # 11.30pm … … 103 103 # all other timeslots - 104 104 # allow up to 45 minutes maximum missing programming 105 $policy{other_max_missing} = 45*60; # up to 45mins max allowed missing105 $policy{other_max_missing} = 60*60; # up to 60 mins max allowed missing 106 106 107 107 # if a postprocessor failed 5 times in a row, automatically disable it … … 1007 1007 1008 1008 my $data; 1009 my $lastpol = ""; 1009 1010 $data->{data_ok} = 1; # unless proven otherwise 1010 1011 $data->{have} = 0; 1011 1012 $data->{missing} = 0; 1012 1013 my $already_missing = "";1014 my $already_missing_last = "";1015 1013 1016 1014 for my $slotnum (0..($policy{num_timeslots}-1)) { … … 1034 1032 1035 1033 # day changed, dump any 'already_missing' data 1036 if ($already_missing ne "") { 1037 $already_missing .= sprintf "-%02d:%02d", 1038 int($already_missing_last/3600),int(($already_missing_last%3600)/60) 1039 if ($already_missing_last ne ""); 1040 push(@{($data->{missing_all})}, $already_missing); 1041 $already_missing = ""; 1042 $already_missing_last = ""; 1043 } 1034 &dump_already_missing($data); 1044 1035 } 1045 1036 … … 1049 1040 1050 1041 # if we have missing data queued up, push it now 1051 if ($already_missing ne "") { 1052 $already_missing .= sprintf "-%02d:%02d", 1053 int($already_missing_last/3600),int(($already_missing_last%3600)/60) 1054 if ($already_missing_last ne ""); 1055 push(@{($data->{missing_all})}, $already_missing); 1056 $already_missing = ""; 1057 $already_missing_last = ""; 1058 } 1042 &dump_already_missing($data); 1043 1044 &dump_already_missing_period($data->{day}->[$day],$lastpol) 1045 if ($lastpol ne ""); 1059 1046 1060 1047 $data->{day}->[$day]->{have} += $policy{timeslot_size}; … … 1073 1060 1074 1061 # store details of where we are missing data 1075 if ($already_missing eq "") { 1076 $already_missing = sprintf "#%d/%02d:%02d", $day, 1077 int($bucket_seconds_offset/3600),int(($bucket_seconds_offset%3600)/60); 1078 $already_missing_last = $bucket_seconds_offset + $policy{timeslot_size} - 1; 1079 } else { 1080 $already_missing_last = $bucket_seconds_offset + $policy{timeslot_size} - 1; 1062 if (!defined $data->{already_missing}) { 1063 $data->{already_missing} = sprintf "#%d/%02d:%02d", 1064 $day, 1065 int($bucket_seconds_offset / 3600), 1066 int(($bucket_seconds_offset % 3600) / 60); 1081 1067 } 1068 $data->{already_missing_last} = $bucket_seconds_offset + $policy{timeslot_size} - 1; 1082 1069 1083 1070 $data->{day}->[$day]->{missing} += $policy{timeslot_size}; … … 1085 1072 1086 1073 # work out what policy missing data for this bucket fits into 1074 my $pol; 1087 1075 if (($bucket_seconds_offset >= $policy{peak_start}) && 1088 ($bucket_seconds_offset < $policy{peak_stop})) { 1089 $data->{day}->[$day]->{missing_peak} += $policy{timeslot_size}; 1090 push(@{($data->{day}->[$day]->{missing_peak_table})}, $bucket_seconds_offset); 1076 (($bucket_seconds_offset+$policy{timeslot_size}) <= $policy{peak_stop})) { 1077 $pol = "peak"; 1091 1078 } elsif (($bucket_seconds_offset >= $policy{nonpeak_start}) && 1092 ($bucket_seconds_offset < $policy{nonpeak_stop})) { 1093 $data->{day}->[$day]->{missing_nonpeak} += $policy{timeslot_size}; 1094 push(@{($data->{day}->[$day]->{missing_nonpeak_table})}, $bucket_seconds_offset); 1079 (($bucket_seconds_offset+$policy{timeslot_size}) <= $policy{nonpeak_stop})) { 1080 $pol = "nonpeak"; 1095 1081 } else { 1096 $data->{day}->[$day]->{missing_other} += $policy{timeslot_size}; 1097 push(@{($data->{day}->[$day]->{missing_other_table})}, $bucket_seconds_offset); 1082 $pol = "other"; 1098 1083 } 1084 1085 &dump_already_missing_period($data->{day}->[$day],$lastpol) 1086 if (($lastpol ne $pol) && ($lastpol ne "")); 1087 1088 $lastpol = $pol; 1089 1090 $data->{day}->[$day]->{"missing_".$pol} += $policy{timeslot_size}; 1091 1092 $data->{day}->[$day]->{"already_missing_".$pol."_start"} = $bucket_seconds_offset 1093 if (!defined $data->{day}->[$day]->{"already_missing_".$pol."_start"}); 1094 $data->{day}->[$day]->{"already_missing_".$pol."_stop"} = $bucket_seconds_offset + $policy{timeslot_size} - 1; 1099 1095 1100 1096 $data->{day}->[$day]->{day_ok} = 0 if ($data->{day}->[$day]->{missing_peak} > $policy{peak_max_missing}); … … 1105 1101 } 1106 1102 1103 # finished all timeslots in this channel. 1107 1104 # if we have missing data queued up, push it now 1108 if ($already_missing ne "") {1109 $already_missing .= sprintf "-%02d:%02d", 1110 int($already_missing_last/3600),int(($already_missing_last%3600)/60)1111 if ($already_missing_last ne "");1112 push(@{($data->{missing_all})}, $already_missing);1113 $already_missing = "";1114 $already_missing_last = "";1115 } 1116 1117 my $statusstring = sprintf " ch %s: %s (%s)%s",1118 $ch, pretty_duration($data->{have}), $data->{data_ok} ? "pass" : "fail",1119 ($data->{missing} ? " missing" : "");1105 &dump_already_missing($data); 1106 1107 # fill in any last missing period data 1108 foreach my $day (@{($data->{day})}) { 1109 &dump_already_missing_period($day,"peak"); 1110 &dump_already_missing_period($day,"nonpeak"); 1111 &dump_already_missing_period($day,"other"); 1112 } 1113 1114 my $statusstring = sprintf " > ch %s: %s programming: %s\n", 1115 $ch, pretty_duration($data->{have}), 1116 $data->{data_ok} ? "PASS (within thresholds)" : "FAIL, missing data over policy threshold:"; 1120 1117 1121 1118 # display per-day missing data statistics 1122 1119 foreach my $day (@{($data->{day})}) { 1123 if ($day->{missing} > 0) {1124 $statusstring .= sprintf " #%d(",$day->{num};1120 unless ($day->{day_ok}) { 1121 $statusstring .= sprintf "\t".(strftime("%a %e %b",localtime($policy{starttime}+($day->{num}*86400)))).": "; 1125 1122 1126 1123 # do we have any data for this day? 1127 if ($day->{have}) { 1128 $statusstring .= sprintf "%s peak",pretty_duration($day->{missing_peak}) 1129 if ($day->{missing_peak}); 1130 1131 $statusstring .= sprintf "%s%s non-peak", 1132 ($day->{missing_peak} ? ", " : ""), 1133 pretty_duration($day->{missing_nonpeak},$policy{nonpeak_max_missing}) 1134 if ($day->{missing_nonpeak}); 1135 1136 $statusstring .= sprintf "%s%s other", 1137 (($day->{missing_peak} + $day->{missing_nonpeak}) > 0 ? ", " : ""), 1138 pretty_duration($day->{missing_other},$policy{other_max_missing}) 1139 if ($day->{missing_other} > 0); 1140 } else { 1141 $statusstring .= "all[!]"; 1142 } 1143 1144 $statusstring .= ")"; 1124 $statusstring .= "peak ".join(", ",(@{($day->{missing_peak_table})})) 1125 if (($day->{missing_peak}) && ($day->{missing_peak} > $policy{peak_max_missing})); 1126 1127 $statusstring .= sprintf "%snon-peak %s", 1128 ($day->{missing_peak} ? " / " : ""), 1129 join(", ",(@{($day->{missing_nonpeak_table})})) 1130 if (($day->{missing_nonpeak}) && ($day->{missing_nonpeak} > $policy{nonpeak_max_missing})); 1131 1132 $statusstring .= sprintf "%sother %s", 1133 (($day->{missing_peak} + $day->{missing_nonpeak}) > 0 ? " / " : ""), 1134 join(", ",(@{($day->{missing_other_table})})) 1135 if (($day->{missing_other}) && ($day->{missing_other} > $policy{other_max_missing})); 1136 1137 $statusstring .= "\n"; 1145 1138 } 1146 1139 } 1147 &log(" > $statusstring\n") unless $quiet; 1148 1149 &log("[debug] Missing the following bucket slots for this $ch: ". 1150 join(" ",(@{($data->{missing_all})}))."\n") 1151 if ($data->{missing} > 0); 1140 &log($statusstring) unless $quiet; 1152 1141 1153 1142 delete $channel_data->{$ch}->{analysis} if (defined $channel_data->{$ch}->{analysis}); … … 1156 1145 1157 1146 &log((sprintf " > OVERALL: %s\n", ($overall_data_ok ? "PASS" : "FAIL"))) unless $quiet; 1147 1158 1148 return $overall_data_ok; # return 1 for good, 0 for need more 1159 1149 } 1160 1150 1151 # helper routine for filling in 'missing_all' array 1152 sub dump_already_missing 1153 { 1154 my $d = shift; 1155 if (defined $d->{already_missing}) { 1156 $d->{already_missing} .= sprintf "-%02d:%02d", 1157 int($d->{already_missing_last} / 3600), 1158 int(($d->{already_missing_last} % 3600) / 60) 1159 if (defined $d->{already_missing_last}); 1160 push(@{($d->{missing_all})}, $d->{already_missing}); 1161 delete $d->{already_missing}; 1162 delete $d->{already_missing_last}; 1163 } 1164 } 1165 1166 # helper routine for filling in per-day missing data 1167 # specific to peak/nonpeak/other 1168 sub dump_already_missing_period 1169 { 1170 my ($d,$p) = @_; 1171 my $startvar = "already_missing_".$p."_start"; 1172 my $stopvar = "already_missing_".$p."_stop"; 1173 1174 if (defined $d->{$startvar}) { 1175 push(@{($d->{"missing_".$p."_table"})}, 1176 sprintf "%02d:%02d-%02d:%02d", 1177 int($d->{$startvar} / 3600), 1178 int(($d->{$startvar} % 3600) / 60), 1179 int($d->{$stopvar} / 3600), 1180 int(($d->{$stopvar} % 3600) / 60)); 1181 delete $d->{$startvar}; 1182 delete $d->{$stopvar}; 1183 } 1184 } 1161 1185 1162 1186 # given a duration (seconds), return it in a pretty "{days}d{hr}h{min}m" string … … 1166 1190 my ($d,$crit) = @_; 1167 1191 my $s = ""; 1168 $s .= sprintf "%dd",int($d / (60*60*24)) if ($d > (60*60*24));1169 $s .= sprintf "%dh",int(($d % (60*60*24)) / (60*60)) if (($d % (60*60*24)) > (60*60));1170 $s .= sprintf "%dm",int(($d % (60*60)) / 60) if (($d % (60*60)) > 60);1171 $s .= "no data[!]" if ($s eq "");1192 $s .= sprintf "%dd",int($d / (60*60*24)) if ($d >= (60*60*24)); 1193 $s .= sprintf "%dh",int(($d % (60*60*24)) / (60*60)) if (($d % (60*60*24)) >= (60*60)); 1194 $s .= sprintf "%dm",int(($d % (60*60)) / 60) if (($d % (60*60)) >= 60); 1195 $s .= "no" if ($s eq ""); 1172 1196 1173 1197 if (defined $crit) { … … 1776 1800 printf "Logging to $log_file.\n"; 1777 1801 open(LOG_FILE,">$log_file") || die "can't open log file $log_file for writing: $!\n"; 1802 1803 my $now = localtime(time); 1804 printf LOG_FILE "$progname version $version started at $now\n\n"; 1778 1805 } 1779 1806
