eqwatch - earthquake information for the SCG monitor

Data flow:

(1) Mail in /var/mail/hgs
    From 0100017e7dabb670-3a7f2991-2e15-4a9d-9ea8-1bfd33b91e9b-000000@amazonses.com
    Subject: 2022-01-21 16:07:28 (M4.2) Caucasus region, Russia 43.2 47.9 (72724)


(2) ~/Seism/USGS/ens-daily-upd
      In crontab. Retains lines /^Subject: / and reformats information from the mail's html marked-up body
    awk -f eqtimes.awk USGS-ENS.mbox
/var/mail/hgs | ...  > /home/hgs/www/SCG/ens-eqtimes-daily-upd.tsf
    awk {} /home/hgs/www/SCG/ENS-mail.txt                >> /home/hgs/www/SCG/ens-eqtimes-daily-upd.tsf
                                                  
(symlink /home/hgs/www/SCG/ens-eqtimes-daily-upd.txt )
    YYYY MM DD  hh mm ss  Mw     USGS-ID        Lat      Long      Region

    2022-01-21  16 07 28  4.2    us-7000gdx0  43.210 N   47.878 E  Caucasus region, Russia

     A similar refreshing is carried out by eqlookup.pl, however to /home/hgs/www/SCG/ENS-mail.txt
     Before March 2011, the format of ENS-mail.txt is not as informative.

(3)  ~/bin/ens-shortlist2html                               > /home/hgs/www/SCG/ens-eqtimes-daily-upd.html
     The script is activated by (a) cron once every hour, (b) eqwatch.pl when it has found a new event, (c) ens-daily-update twice per day.
    <a href="http://holt.oso.chalmers.se/cgi-bin/SCG-monitor.cgi?name1=2022-01-21&name2=16&name3=00&name4=10">
    SCG response for&nbsp;</a>2022-01-21  16 07 28  4.2    us-7000gdx0  43.210 N   47.878 E  Caucasus region, Russia<br>

     The html-file is linked in  monitor-plot.html: "Our shortlist"
     Clicking on a link activates the  retro-agent production chain.


The earthquake watch

  USAGE:
    eqwatch &

is a perlscript that belongs to the three-some of processes running indefinitely on Holt. It is included in the startup
~/perlproc/START  

   cd ~/perlproc

   eqwatch &
Location: (symlinks) /home/bin/eqwatch -> /home/hgs/perlproc/eqwatch.pl -> /home/hgs/perlproc/eqwatch.ev.pl

Standard execution needs no arguments. Stop it preferably by finding its PID and issue a kill.

PURPOSE / How it works:
Every minute:  Looks whether there are new earthquake messages in the mailbox
             If yes, makes a text graphic: The earthquake message shown on
             monitor-plot.html below the hourly diagram, yellow background.

Every hour:     Renew the shortlist using eqlookup.pl

 Options:
 -now      - run with debug and without sleep
 -onetrip  - for test and development: run just once

 (default: run indefinitely with hard-wired sleep 60 seconds and without much messaging.)

 Hard wires:
 mailbox = /var/mail/hgs
 sleep = 60

The earthquake look-up

 USAGE:    
        (1)    eqlookup.pl  [options]
        (2)    eqlookup.pl  [-D] <date>

               ~/bin/eqlookup -> ~/perlproc/eqlookup.pl
 
 PURPOSE:
 
          Renews the ASCII version of the local earthquake catalog, the so-called shortlist.  Is regularly called from eqwatch.pl
As an example, G1-plot-hour (the program that creates the main diagram for the  retro-agent) issues this command sequence.
Instructions here are for the case that the script needs renewal.
To make the "plot" (the events text in graphic form on the monitor page), issue 
             eqlookup.pl <date>
 
date forms recognized:
             YYYY-MM-DD-HH
             YYYY-MM-DD HH
             YYYY-MM-DD:HH
             YYYY-MM-DD_HH
The hour HH is mandatory though.
 
 OPTIONS:

   -R[X]   - To renew the catalog, issue 
               eqlookup.pl -R <extra-mbox-file>
             or
               eqlookup.pl -RX
             the latter uses a hard-wired old copy of the mailbox file in addition to the recent mails,
             currently /home/hgs/Seism/USGS/USGS-ENS.mbox

    -D     - debugging-style printing.


Daily earthquake shortlist update:

USAGE: 

                ens-daily-upd
No arguments. Processes the mailbox on this machine and potentially additional copied mailboxes.

~/Seism/USGS/USGS-ENS-from-ore.mbox has been copied 2014-04-20.
 
Currently, we use ~/Seism/USGS/USGS-ENS.mbox (hard-wired; 2022-01-21)
 
The script fails before 2011-12-11 because of a change in format request (it cannot handle the html-version).
Therefore, the old data is added from ~/www/SCG/ENS-mail.txt
 
Let cron run this script a few times per day.


Making the earthquake shortlist in html

 USAGE:
ens-shortlist2html
           Location: /home/hgs/Seism/USGS/ens-shortlist2html

 PURPOSE:
A csh script. It updates the html file /home/hgs/www/SCG/ens-eqtimes-daily-upd.html
 

It's a cron job running every hour minutes. Also called in eqwatch and ens-daily-update
 INPUT:

     /home/hgs/www/SCG/ens-eqtimes-daily-upd.tsf -> ens-eqtimes-daily-upd.txt

 HTML:
/home/hgs/www/SCG/ens-eqtimes-daily-upd.html contains clickable links to call the  retro-agent

SCG response for TODAY      04 43 17 5.0 us-70003dri 35.360 N 27.694 E Dodecanese Islands, Greece
SCG response for TODAY      02 48 52 5.4 us-70003dpt 43.185 N 29.105 W northern Mid-Atlantic Ridge
SCG response for 2019-04-27 23 25 58 4.3 us-70003d5r 37.583 N 20.678 E Ionian Sea
SCG response for 2019-04-27 15 07 58 4.4 us-70003cz6 37.555 N 20.360 E Ionian Sea

with links spelling out like e.g.
http://holt.oso.chalmers.se/cgi-bin/SCG-monitor.cgi?name1=2019-04-27&name2=15&name3=00&name4=10