#!/usr/bin/perl -I/nwprod/lib/incmod/perl ####################################################################################### # This program will retrieve the OSO status file from the SOC, and # generate some statistical files for the SDM. # # Modifications: # 01/27/97 Initial version # ####################################################################################### ####################################################################################### # Start Main Program ####################################################################################### use Time::CTime; use Sys::Hostname; $pcom_root="/pcom/status"; $max_oso_lines=150; #$max_oso_lines=1500; $max_ncep_lines=1915; #$max_oso_lines=3; #$max_ncep_lines=700; $hst=hostname(); $host=substr($hst,0,1); if ($host =~ /b/) { $host="blue"; } else { $host="white"; } if (!read_input()) { exit(1); } gen_report("OSO"); gen_tracker_report("TRACKER"); exit(0); ####################################################################################### # End Main Program ####################################################################################### sub gen_report { my ($filename) = @_; open(_OUTPUT, ">.$filename") || return -2; select (_OUTPUT); $~ = "_OUTPUT_HEADER"; write; $~ = "_OUTPUT"; foreach (@original) { ($index,$ptime,$job,$model,$file,$pseconds,$rseconds,$delay) = split; ($i_number,$type) = split ('\.',$index); $success = $index =~ /^\*/; $file =~ /.*\/(.*)/; if($rseconds == 0) { $~ = "_OUTPUT1"; } else { $~ = "_OUTPUT"; } write ; } format _OUTPUT_HEADER = @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| "Cray to OSO status file transfer statistics. FILE=$filename" @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| "(remember delay times and reciept times are calculated using two seperate" @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| " computer clocks, some descrepencies will be from clock differences)" @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| strftime("Report Generated at %Y.%j.%H.%M.%S GMT",gmtime(time)) @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| "--------------------------------------------------------------------------" @<@<<<< @<<<<<<< @<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< "S","Type","Job","Key","NMCZ", "OSOZ", "delay", "Cray Filename" . format _OUTPUT = @<@<<<< @<<<<<<< @<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @##.## @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ($success ? "*" : " "), $type, $job, $model, strftime("%Y-%m-%d-%H-%M-%S",gmtime($pseconds)), strftime("%Y-%m-%d-%H-%M-%S",gmtime($rseconds)), $delay, $file . format _OUTPUT1 = @<@<<<< @<<<<<<< @<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @##.## @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ($success ? "*" : " "), $type, $job, $model, strftime("%Y-%m-%d-%H-%M-%S",gmtime($pseconds)), strftime("0000-00-00-%H-%M-%S",gmtime($rseconds)), $delay, $file . select stdout; close(_OUTPUT); rename ".$filename","$filename"; } sub gen_tracker_report { my ($filename) = @_; open(_OUTPUT, ">.$filename") || return -2; select (_OUTPUT); foreach (@original) { ($index,$ptime,$job,$model,$file,$pseconds,$rseconds,$delay) = split; $file =~ /.*\/(.*)/; $nmctime=strftime("%Y-%m-%d-%H-%M-%S",gmtime($pseconds)); $nmcpdy=strftime("%Y%m%d",gmtime($pseconds)); if($rseconds == 0) { #$osotime=strftime("0000-00-00-%H-%M-%S",gmtime($rseconds)); next; } else { $osotime=strftime("%Y-%m-%d-%H-%M-%S",gmtime($rseconds)); } if($file =~ /pcom\/foreign/ || $model =~ /tix/ || $model =~ /tux/ || $model =~ /pol/ || $model =~ /for/) { next; } if($file =~ /mmus6/) { $file=~ s+/pcom/status/data+/com/rucs/prod/rucs.$nmcpdy+g; } if($file =~ /aeus41/) { $file=~ s+/pcom/status/data+/pcom/hourly+g; } print "$file\|$nmctime\|$osotime\n"; } select stdout; close(_OUTPUT); rename ".$filename","$filename"; } sub read_input { my (@crayfile); my ($i) = 0; my ($j) = 0; my ($start) = 0; $count=0; while (`wc -l ${pcom_root}/statfile` < $max_ncep_lines && $count < 6) { sleep (5); $count++; } `cat ${pcom_root}/statfile | sort -r +1 -2 -o origsorted` ; open(_FILE, "; close (_FILE); while ((`wc -l ${pcom_root}/oso/statfile.toc-$host` < $max_oso_lines) || (`wc -l ${pcom_root}/oso/statfile.toc1-$host` < $max_oso_lines)) { sleep (5); } `cat ${pcom_root}/oso/statfile.toc-$host ${pcom_root}/oso/statfile.toc1-$host | grep '^\*' | sort +1 -2 -o sorted` ; open(_FILE, "; close (_FILE); @crayfile = splice(@crayfile,0,$max_oso_lines); for ( $i=0 ; (($i <=$#crayfile) && ($i <= $max_oso_lines)); $i++ ) { ($index,$ptime,$job,$model,$file) = split(" ",$crayfile[$i]); ($oso_index,$oso_ptime,$oso_job,$oso_model,$oso_file,$oso_how,$oso_rtime) = split(" ",$original[$#orignal]); $orig_index=$#original; while ($index !~ /[ \*]$oso_index/ && $orig_index > 0) { $orig_index=$orig_index-1; ($oso_index,$oso_ptime,$oso_job,$oso_model,$oso_file,$oso_how,$oso_rtime) = split(" ",$original[$orig_index]); } ($i_number,$type) = split ('\.',$index); $file =~ /.*\/(.*)/; ($year,$day,$tmptime) = split ('\.',$ptime); ($hour,$min,$sec) = split (':',$tmptime); #calculate the number of seconds since 1970 if ($year > 70) { $leapoffset=int(($year-72)/4); if(($year%4)==0) { $leapoffset=$leapoffset-1; } $pseconds = ($year-70) * 365 * 24 * 60 * 60 + ($day+$leapoffset) * 24 * 60 *60 + $hour * 60 * 60 + $min * 60 + $sec; } else { $leapoffset=int(($year+28)/4); if(($year%4)==0) { $leapoffset=$leapoffset-1; } $pseconds = ($year+30) * 365 * 24 * 60 * 60 + ($day+$leapoffset) * 24 * 60 *60 + $hour * 60 * 60 + $min * 60 + $sec; } if ($index =~ /[ \*]$oso_index/) { $success = $oso_index =~ /^\*/ ? " " : "*"; ($oso_year,$oso_day,$osotmptime) = split ('\.',$oso_ptime); ($hour,$min,$sec) = split (':',$oso_rtime); if ($oso_year > 70) { $oso_leapoffset=int(($oso_year-72)/4); if(($oso_year%4)==0) { $oso_leapoffset=$oso_leapoffset-1; } $rseconds = ($oso_year-70) * 365 * 24 * 60 * 60 + ($oso_day+$oso_leapoffset) * 24 * 60 *60 + $hour * 60 * 60 + $min * 60 + $sec; } else { $oso_leapoffset=int(($oso_year+28)/4); if(($oso_year%4)==0) { $oso_leapoffset=$oso_leapoffset-1; } $rseconds = ($oso_year+30) * 365 * 24 * 60 * 60 + ($oso_day+$oso_leapoffset) * 24 * 60 *60 + $hour * 60 * 60 + $min * 60 + $sec; } $delay = ($rseconds - $pseconds ) /60; } else { $rseconds = 0; $delay = 0; $success = " "; } $chkmatch=$rseconds-$pseconds; if($chkmatch < -900) { $rseconds = 0; $delay = 0; $success = " "; } $crayfile[$i] = "${success}$crayfile[$i] $pseconds $rseconds $delay"; } @original = @crayfile; return 1; }