This repository contains a set of Bash scripts that make up a data pipeline, designed to automate the process of interacting with an SEL-735 meter. The pipeline is divided into two main executable scripts:
data_pipeline.sh
: Handles the first four steps:
archive_pipeline.sh
: Handles the final step:
Ensure you have the following before running the pipeline:
ssh
to the ot-dev and das.lab.acep.uaf.edu serverscamio-ot-dev
:
lftp
— FTP Operationsyq
- YAML Parsingzip
- Compressing Datarsync
— Transfering Datajq
— JSON ParsingYou must be connected to the camio-ot-dev
server. See camio-ot-dev(SSH) in the ACEP Wiki.
Clone the repository:
git clone git@github.com:acep-uaf/camio-meter-streams.git
cd camio-meter-streams/cli_meter
Note: You can check your SSH connection with ssh -T git@github.com
Navigate to the config
directory and copy the config.yml.example
file to a new config.yml
file:
cd config
cp config.yml.example config.yml
Update the config.yml
file with the FTP credentials and meter configuration data.
Secure the config.yml
file so that only the owner can read and write:
chmod 600 config.yml
Navigate to the config
directory and copy the archive_config.yml.example
file to a new archive_config.yml
file:
cd config
cp archive_config.yml.example archive_config.yml
Update the archive_config.yml
file with the source and destination directories and details.
Secure the archive_config.yml
file so that only the owner can read and write:
chmod 600 archive_config.yml
To run the data pipeline and then transfer data to the Data Acquisition System (DAS):
Run the Data Pipeline First
Execute the data_pipeline
script from the cli_meter
directory. The script requires a configuration file specified via the -c/--config
flag. If this is your first time running the pipeline, the initial download may take a few hours. To pause the download safely, see: How to Stop the Pipeline
./data_pipeline.sh -c /path/to/config.yml
Run the Archive Pipeline
After the data_pipeline
script completes, execute the archive_pipeline
script from the cli_meter
directory. The script requires a configuration file specified via the -c/--config
flag.
./archive_pipeline.sh -c /path/to/archive_config.yml
The rsync uses the --exclude
flag to exclude the working
directory to ensure only complete files are transfered.
Run the Cleanup Process (Conditional)
If the archive_pipeline
script completes successfully and the enable_cleanup
flag is set to true in the archive configuration file, the cleanup.sh
script will be executed automatically. This script removes outdated event files from level0 based on the retention period specified in the configuration file.
Ensure that the cleanup.sh
script is configured correctly in the archive_config.yml
file to specify the retention period for each directory set for the cleanup process.
When you need to stop the pipeline:
Ctrl+C
to interrupt the process. data_pipeline
command.The download will resume from where it left off, provided the same config file (-c
)is used.Ctrl+Z
:
Ctrl+Z
to suspend the process, as it may cause the pipeline to end without properly closing the FTP connection.This repository includes automated tests for the scripts using Bats (Bash Automated Testing System). The tests are located in the test
directory.
Ensure you have bats-core
installed. You can install it using the following steps:
On Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y bats
On macOS (using Homebrew):
brew install bats-core
Navigate to the project directory:
cd /path/to/camio-meter-streams/cli_meter
Run all the tests:
bats test/
Run specific test files:
bats test/test_data_pipeline.bats
bats test/test_commons.bats