BNMR: Shift Monitor
Links
Introduction
The BNMR shift monitor system consists of two perlscripts
- monitor.pl
- cycle_monitor_logfiles.pl
both of which are normally run as cron jobs, and a shell-script check_exptnum.
The Shift Monitor program monitor.pl keeps a running total of how much usable beam time (in minutes) each experiment number has had access to, while running as experiment bnmr or bnqr (or both). It reads the proton current from EPICS once per minute. The information is stored in shift files in the directory /isdaq/data1/bnmr/mon/<year>/. This is also the location of the log files used to store messages.
How it works
The perlscript /home/bnmr/vmic_online/perl/monitor.pl is run on isdaq01 (i.e. the host for bnmr and bnqr experiments) as a cron job (except for testing). Its output is written to a log file. It is run as user bnmr, which has permission to access the EPICS variables needed, and, of course, its own odb.
Access to the bnqr odb has to be done via ssh. A script /home/bnqr/vmic_online/bnqr/bin/check_exptnum is run to read bnqr's experiment number using odb -c , and a ssh-key for access.
The perlscript monitor.pl reads the proton current from EPICS (via caget "CCS2ISAC:BL2ACURRENT").
- If it is below the threshold value (supplied as the first input parameter to
monitor.pl ) it exits.
- Otherwise it reads from the EPICS switches whether bnmr, bnqr or both experiments (i.e. dual channel mode) are enabled.
- If bnmr or bnqr or both experiments are enabled, it reads the experiment numbers from both bnmr and bnqr. The experiment number must be > 0. Otherwise it exits.
- The program determines the name of the shift file by date and by 12-hour shift (AM/PM).
- If no file of that filename exists, it is created and a line written for each different experiment number, and each running experiment assigned 1 minute of running time.
- If bnmr and bnqr are both running (dual channel mode) with the same experiment number, only one line will be created with bnmr and bnqr both given 1 minute accumulated time).
- If there is an existing file, the program looks for a line with the experiment number. If it finds one, the accumulated time is incremented for the appropriate experiment. All other lines are copied and an updated file is written. If no line exists for this experiment number, it will be created.