Changeset 705
- Timestamp:
- 05/28/07 20:30:48 (6 years ago)
- Files:
-
- 2 modified
-
applications/shepherd (modified) (13 diffs)
-
status (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/shepherd
r704 r705 2 2 3 3 my $progname = 'shepherd'; 4 my $version = '0.4.9 7';4 my $version = '0.4.98'; 5 5 6 6 # tv_grab_au … … 80 80 my $last_successful_run; 81 81 my $last_successful_run_data; 82 my $last_successful_runs; 82 83 my $components = { }; 83 84 my $components_pending_install = { }; … … 89 90 my $log_file = "$progname.log"; 90 91 my $sysid = time.".".$$; 91 my $oldest_days = 30;92 92 my $pending_messages = { }; 93 93 my $starttime = time; … … 726 726 my $total_wanted = $plugin_data->{$progname}->{total_duration} + $plugin_data->{$progname}->{total_missing}; 727 727 $last_successful_run_data = ($total_wanted ? 100* $plugin_data->{$progname}->{total_duration} / $total_wanted : 0); 728 729 $last_successful_runs->{$last_successful_run} = $last_successful_run_data; 728 730 } 729 731 … … 890 892 &log(2, "WARNING: ".ucfirst($progname)." is being run too frequently.\n"); 891 893 892 if ($oldest_days <= 7) { 894 # enforce hard limit 895 my $num_runs = 0; 896 my $earliest_run = time; 897 foreach my $when (sort {$b <=> $a} keys %{$last_successful_runs}) { 898 if (($when + (86400*30)) < time) { 899 delete $last_successful_runs->{$when}; # age out old entries 900 next; 901 } 902 903 if ($when >= (time - (86400*7))) { 904 $num_runs++; 905 $earliest_run = $when if ($num_runs == 30); 906 } 907 } 908 if ($num_runs >= 30) { 893 909 &log(2, "\n*** ERROR: EXTREME OVERUSE ***\n\n". 894 910 "Shepherd has run more than 30 times in the last 7 days! To avoid overloading\n". … … 898 914 "TO AVOID THIS ERROR: Please do not run Shepherd more than once or twice per\n". 899 915 "day. Shepherd is now in a locked state. To unlock Shepherd, wait \n". 900 (8-$oldest_days)." days. Alternately, you may reinstall Shepherd.\n\n". 916 pretty_duration((7*86400)-(time-$earliest_run)). 917 ". Alternately, you may reinstall Shepherd.\n\n". 901 918 "Please do not abuse Shepherd. All users depend on your courtesy.\n\n"); 902 919 … … 1058 1075 # keep last 30 log files 1059 1076 my $num; 1060 my $found = 0;1061 $oldest_days = 0;1062 1063 1077 for ($num = 30; $num > 0; $num--) { 1064 1078 my $f1 = sprintf "%s/%s.%d.gz",$LOG_DIR,$log_file,$num; … … 1066 1080 unlink($f2); 1067 1081 rename($f1,$f2); 1068 1069 if (-s $f2) {1070 $found++;1071 $oldest_days = -M $f2 if ((-M $f2) > $oldest_days);1072 }1073 1082 } 1074 1083 … … 1076 1085 my $f2 = sprintf "%s/%s.1",$LOG_DIR,$log_file; 1077 1086 rename($f1,$f2); 1078 1079 $oldest_days = 30 if ($found <= 28);1080 1087 } 1081 1088 … … 1390 1397 { 1391 1398 write_file($config_file, 'configuration', 1392 [$region, $pref_title_source, $want_paytv_channels, $sysid, $last_successful_run, $last_successful_run_data, $ mirror_site, $components, $components_pending_install, $pending_messages ],1393 ["region", "pref_title_source", "want_paytv_channels", "sysid", "last_successful_run", "last_successful_run_data", " mirror_site", "components", "components_pending_install", "pending_messages" ]);1399 [$region, $pref_title_source, $want_paytv_channels, $sysid, $last_successful_run, $last_successful_run_data, $last_successful_runs, $mirror_site, $components, $components_pending_install, $pending_messages ], 1400 ["region", "pref_title_source", "want_paytv_channels", "sysid", "last_successful_run", "last_successful_run_data", "last_successful_runs", "mirror_site", "components", "components_pending_install", "pending_messages" ]); 1394 1401 } 1395 1402 … … 2196 2203 ($ctype eq 'grabber' ? 2197 2204 " Enabled/\n". 2198 sprintf(" %-1 7s Version Ready Last Run Status", ucfirst($ctype))2205 sprintf(" %-15s Version Ready Last Run Status", ucfirst($ctype)) 2199 2206 : ucfirst($ctype)) . 2200 "\n ------------ -- ---------- ----- ---------------------------------------------\n");2207 "\n ------------ ---------- ----- ---------- -------------------------------------\n"); 2201 2208 foreach (sort { ($components->{$b}->{lastdata} or 0) <=> ($components->{$a}->{lastdata} or 0) } query_component_type($ctype)) 2202 2209 { 2203 2210 my $h = $components->{$_}; 2204 &log(sprintf " %-1 5s%10s %1s/%1s%1s %11s %s\n",2205 length($_) > 1 5 ? substr($_,0,13).".." : $_,2211 &log(sprintf " %-13s%10s %1s/%1s%1s %11s %s\n", 2212 length($_) > 13 ? substr($_,0,11).".." : $_, 2206 2213 $h->{ver}, 2207 2214 $h->{disabled} ? 'N' : 'Y', … … 2209 2216 (defined $plugin_data->{$_}->{tainted} ? "!" : ""), 2210 2217 pretty_date($h->{lastdata}), 2211 $h->{laststatus} ? pretty_print($h->{laststatus},35) : ''); 2218 ((defined $h->{disabled} && $h->{disabled} == 2) ? "centrally disabled" : 2219 ($h->{laststatus} ? pretty_print($h->{laststatus},37) : ''))); 2212 2220 } 2213 2221 } … … 2221 2229 $last_successful_run_data; 2222 2230 } 2223 &log("$str.\n"); 2231 &log("\n$str.\n"); 2232 2233 $str = sprintf " History of runs: "; 2234 foreach my $when (sort {$b <=> $a} keys (%{$last_successful_runs})) { 2235 $str .= pretty_duration(time - $when). 2236 (sprintf "[%2.2f%%] ",$last_successful_runs->{$when}); 2237 } 2238 &log("$str\n"); 2224 2239 } 2225 2240 &log("\nPreferred titles from grabber '$pref_title_source'\n") if ($pref_title_source); -
status
r704 r705 1 application shepherd 0.4.9 71 application shepherd 0.4.98 2 2 reference channel_list 2 3 3 reference Shepherd/Common.pm 0.12
