Seting up EPICS logging using the ChannelArchiver

The Epics ChannelArchiver is being used in Hall C to log over 700 target and other EPICS signals. Although there are occaisional hiccups, it successfully logs about 100 MB of EPICS data a day.

The data logged by the viewed either by the X-Window application Xarr or over the web with the CGI program CGIExport. Either of these programs can also be used to extract text formated data useful spreadsheets and other applications.

Below we detail the steps followed to compile and configure the ChannelArchiver and viewer applications for the G0 target. These details are given both as a form of collaboratino documentation and in the hopes that these details can help setup EPICS logging for other applications.

The applications were installed on the account g0targ on the machine gzerol2.acc.jlab.org. This machine is a PC running RedHat Linux version 6.2.

Installing and Compiling Software

  1. Add the followign to ~/.bash_profile
    export HOST_ARCH=Linux 
    export XARR_DB_INDEX=/home/g0targ/Archives/ArchiveData/freq_directory
    
    (Or do equivalent if using tcsh instead of bash)
  2. Obtain car-xarr-cgiexport.tgz from Stephen Wood. From the home directory untar this file which will create the ~/car-xarr subdirectory.
  3. Unpack Epics Version R3.13.0.beta12CEBAF3 into ~/epics. A tar file from Stephen Wood can be obtained for this.
  4. Edit ~/epics/R3.13.0.beta12CEBAF3/config/RELEASE. Set EPICS_BASE and TEMPLATE_TOP:
    EPICS_BASE=/home/g0targ/epics/R3.13.0.beta12CEBAF3/base
    TEMPLATE_TOP=/home/g0targ/epics/R3.13.0.beta12CEBAF3/base/templates/makeBaseApp/top
    
    (Replace /home/g0targ if different)
  5. Compile epics
    cd ~/epics/R33.13.0.beta12CEBAF3/base
    make
    
  6. Get lesstif-0.89.9-2.i386.rpm and lesstif-2.0-devel-0.89.9-2.i386.rpm from /u/mirror/redhat/powertools/6.2/i386/i386 (Any CUE machine). Get gnuplot-3.7.1-3.i386.rpm from /u/mirror/redhat/redhat-6.2/i386/RedHat/RPMS. Install these from root account.
  7. Build car and xarr with
    cd ~/car-xarr
    make
    
  8. Copy all the relevant binaries to ~/bin or somewhere else in your PATH.
    cp -p ~/car-xarr/CAR/bin/Linux/ArchiveEngine ~/bin
    cp -p ~/car-xarr/XARR/bin/Linux/xarr ~/bin
    

Configuring and Starting the Archiver

  1. Create the directories for the arhiver configuration and data
    mkdir ~/Archives
    mkdir ~/Archives/ArchiveData
    mkdir ~/Archives/cfg
    
    Note, the ArchiveData directory is going to hold all the output of the logger. It will get large, so it might be a good idea that ArchiveData be a softlink to a directory on a really huge disk.
  2. Create scripts to start and stop the archiver. Make sure that the script to start the archiver sets the following environment variables: EPICS_TS_MIN_WEST EPICS_CA_AUTO_ADDR_LIST EPICS_CA_ADDR_LIST Here is an example ~/Archives/start_archiver script:
    #!/bin/bash
    
    export EPICS_TS_MIN_WEST=300
    export EPICS_CA_AUTO_ADDR_LIST=YES
    export EPICS_CA_ADDR_LIST="129.57.211.255 129.57.215.255 129.57.239.255 129.57.243.255"
    
    ARCHIVE_ENGINE_NAME=ArchiveEngine
    ARCHIVE_ENGINE=/home/g0targ/bin/$ARCHIVE_ENGINE_NAME
    ARCHIVE_DIR=/home/g0targ/Archives
    
    cd $ARCHIVE_DIR
    
    alreadyrunning="`ps auxww | grep $ARCHIVE_ENGINE_NAME | grep -v grep`"
    if [ "$alreadyrunning" = "" ] ; then
        $ARCHIVE_ENGINE -log $ARCHIVE_DIR/archive.log ./config $ARCHIVE_DIR/ArchiveData/freq_directory > archive.out 2>&1 &
    else
        echo "The Archiver is already running"
    fi
    
    Here is an example ~/Archives/stop_archiver script:
    #!/bin/bash
    
    ARCHIVE_ENGINE_NAME=ArchiveEngine
    ARCHIVE_ENGINE=/home/g0targ/bin/$ARCHIVE_ENGINE_NAME
    ARCHIVE_DIR=/home/g0targ/Archives
    ARCHIVE_LOCK_FILE=$ARCHIVE_DIR/archive_active.lck
    
    killall $ARCHIVE_ENGINE_NAME
    
    sleep 1
    
    stillrunning="`ps auxww | grep $ARCHIVE_ENGINE_NAME | grep -v grep`"
    if [ "$stillrunning" != "" ] ; then
        killall -9 $ARCHIVE_ENGINE_NAME
    fi
    
    if [ -f $ARCHIVE_LOCK_FILE ]; then
        rm -f $ARCHIVE_LOCK_FILE
    fi
    
  3. Setup the configuration files "~/Archives/config" and any files it references. As an example, ~/Archives/config:
    # Group: config
    # This file was auto-created by the ChannelArchiver Engine
    # Instance: EPICS Channel Archiver Engine
    
    !write_period   30
    !default_period 1
    !get_threshold  300
    !file_size      24
    !buffer_reserve 3
    
    !group demo
    
    and ~/Archives/demo
    # Group: demo
    
    hallc:bcm1 1 monitor
    hallc:bcm2 1 monitor
    
  4. Start the archiver running by executing your start_archiver script Make sure it is running by looking for 3 instances of "ArchiveEngine" running.

Setting up XARR

Make sure XARR_DB_INDEX is defined as described above and that the xarr binary has been copied to some directory in your PATH. (e.g. ~/bin)

Type xarr.

Setting up CGIExport

CGIExport is a CGI program that allows viewing of data archived by the ChannelArchiver using any web browser.

  1. Type the following commands:
    mkdir ~/public_html
    mkdir ~/public_html/cgi
    mkdir ~/public_html/cgi/tmp
    chmod 777 ~/public_html/cgi/tmp
    chmod 755 ~
    cp ~/car-xarr/CAR/bin/Linux/CGIExport ~/public_html/cgi/CGIExport.cgi
    cp -p ~/car-xarr/CAR/CGIExport/src/Tests * ~/public_html
    
  2. Install the apache web server. Apache may already be installed on the system. Edit /etc/httpd/conf/httpd.conf, removing the "#" on the line "#AddHandler cgi-script .cgi".

    After "UserDir public_html" in httpd.conf, add:

    
            AllowOverride AuthConfig Limit
            Options Indexes ExecCGI
    
    
  3. Restart web server with /etc/rc.d/init.d/httpd restart
  4. In ~/public_html, create an index.html file with a link to CGIExport. The following index.html is a simple example:
    <html>
    <body>
    <a href="cgi/CGIExport.cgi?DIRECTORY=..%2FArchives%2FArchiveData%2Ffreq_directory&COMMAND=START">Archiver</a>
    </body>
    <html>
    
  5. Customize cgi_body_start.txt and cgi_body_end.txt in ~/public_html. In particular, it is a good idea to add a comment to cgi_body_end.txt indicating who maintains this particular installation of CGIExport. For example, after the line with the author's (Kay-Uwe Kasemir) email address, add:
    %lt;br%gt;Installed for G0 by
    <a href="mailto:saw@jlab.org">Stephen A. Wood%lt;/a%gt;
    
  6. Visit http://gzerol2.acc.jlab.org/~g0targ/ and play with the CGIExport utility.
  7. Each time a plot is make with CGIExport, files are left behind in ~/public_html/cgi/tmp. These files need to be periodically deleted. A cron job could be used to do this automatically every day.
  8. Access to the CGIExport display tool can be limited by the normal .htaccess mechanisms of apache. For example, the following .htaccess file limits access to users from machines explicitely listed on "allow from" lines and to those who know a username/password defined in the .htpasswd file. .htpasswd is maintained with the htpasswd command.
    <Limit GET>
    order deny,allow
    deny from all
    allow from gzerol2.acc.jlab.org wood.jlab.org
    allow from gzero.jlab.org
    AuthType Basic
    AuthUserFile /home/g0targ/public_html/.htpasswd
    AuthGroupFile /dev/null
    AuthName ByPassword
    require valid-user
    satisfy any
    </Limit>
    

Other Documentation

Documentation for Channel archiver and CGIExport

Xarr manual


Stephen A. Wood
Last modified: Thu Jan 18 15:57:56 EST 2001