#!/usr/bin/perl # pretty prints getradio.pl at jobs # Copyright (C) 2007 Karl-Heinz Herrmann # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . use Date::Calc qw(Day_of_Week Day_of_Week_to_Text Decode_Month); open (ATQ,"atq |") or die "Can't get atq output: $!\n"; while ($job=) { $job =~ /(\d+)[\s\t]+(\w+)[\s\t]+(\w+)[\s\t]+([\d]+)[\s\t]+([\d:]+)[\s\t]+(\d+)\s+([a=]?).*/; $jnr=$1; # $date=$2; # ($y,$m,$d)=split("-",$date); # $wday=Day_of_Week($y,$m,$d); # $wday=substr(Day_of_Week_to_Text($wday),0,2); $wday=$2; $m=$3; $d=$4; $y=$6; $m=Decode_Month($m); $m="0"x(2-length($m)).$m; $d="0"x(2-length($d)).$d; $time=$5; $status=$7; $date=$y."-".$m."-".$d; if ($status eq "="){ $status="running"; }else{ $status=""; } open (ATC,"at -c $jnr |") or die "Can't get at -c output: $!\n"; $command="????"; $dur="??"; $execdir=""; while ($line=){ if ($line =~ /cd (\/.*) \|\| \{/ ){ $execdir=$1; } if ($line =~ /get(dl[rf])-autokill.sh\s+(\d*)/ ){ $command=$1." "; $dur=$2; } if ($line =~ /getWDR([135]).*\.pl\s+(\d*)/ ){ $command="WDR".$1; $dur=$2; } if ($line =~ /getBR([12345]).*\.sh\s+(\d*)/ ){ $command="BR".$1." "; $dur=$2; } if ($line =~ /getradio.pl\s+(.*?)\s+(\d*)/ ){ $command=$1." "; $dur=$2; } if ($line =~ /getradio_restart.pl\s+(.*?)\s+(\d*)/ ){ $command=$1." "; $dur=$2; } } close(ATC); if (defined $atq{$date." ".$time." ".$command}){ print "DOUBLE ENTRY: ",$date," ",$time," ",$wday." "." "x(4-length($jnr)).$jnr." ".$command." ".$dur." ".$status." ".$execdir."\n"; } $atq{$date." ".$time." ".$command}=$wday." "." "x(4-length($jnr)).$jnr." "x(4-length($dur)).$dur." ".$status." ".$execdir."\n"; } foreach $dt (sort keys %atq){ print $dt," ",$atq{$dt}; }