# lrauv-log-critical #

**lrauv-log-critical is a Python (>=3.4) command-line tool for producing reliability analytics by automated ingestion of LRAUV system logs.**

## Reliability data products are available on: http://tethysdata.shore.mbari.org/reliability/

lrauv-log-critical performs the following tasks:  

    - Locates all LRAUV *.dlist files and lists deployment/log names.
    - Scans syslog files for '(CRITICAL)' messages.
    - Logs critical messages and computes total runtimes.
    - Eliminates redundant messages.
    - Computes time between critical failures (TBCF) and mean time between critical failures (MTBCF).  
    - Exports and visualizes results.

### Install dependencies:
```
#!bash
# Python 3.4 or later:
$ pip install pandas  # tested using Pandas 0.19.2
$ pip install seaborn  # tested using Seaborn 0.7.2
   
```
    
   
### Usage:
    
```
#!bash
    
$ python3 lrauv-log-critical.py --help

    usage: lrauv-log-critical.py [-h] [-p PATH] [-v] [-f] [-r] [-s]
                             [-vh VEHICLES [VEHICLES ...]]
                             [-i IGNORE [IGNORE ...]]
    
    Process CRITICAL messages in LRAUV syslogs.
    
    optional arguments:
      -h, --help            show this help message and exit
      -p PATH, --path PATH  set path to LRAUV data root
      -v, --verbose         enable output verbosity
      -f, --force           force fresh scan
      -r, --report          generate csv reports w/out scan
      -s, --sync            enable sync /var/www/html/ data folders
      -vh VEHICLES [VEHICLES ...], --vehicles VEHICLES [VEHICLES ...]
                            list of vehicles to process
      -i IGNORE [IGNORE ...], --ignore IGNORE [IGNORE ...]
                            list of deployment name key-words to ignore
    
# to execute on tethysdata:
$ export PATH=$PATH:/opt/rh/python35/root/usr/bin
$ python3 lrauv-log-critical.py --sync --verbose --path /mbari/LRAUV -vh tethys
# or:
$ ./home/tethysadmin/lrauv-tools/handle-lrauv-logs/lrauv-log-critical.sh
```
    
    
    
###Things to note:
    
- lrauv-log-critical's main "engine" is the `SysTools` object, which is implemented in [`scripts/syslog_tools.py`](https://bitbucket.org/braanan/lrauv-log-critical/src/648a6d4794f815500ed4e3a88101599ae74e2913/scripts/syslog_tools.py?at=master&fileviewer=file-view-default).

- SysTools eliminates redundant critical failure messages by placing time bounds on repeating errors.
  Filtering settings are defined in the MESSAGE FILTERING SETTINGS section in `syslog_tools.py`.          

- If working from a remote (i.e., not on tethysdata), SysTools will make a temporary local copy of the 
  syslog it's processing and remove it when done (determined to be faster than reading over network).          

- SysTools cashes a summary (json) of the processed data for each vehicle. Upon execution SysTools 
  loads the json files (if present) and will only process new deployments. You can force a fresh scan by 
  executing lrauv-log-critical.py with the `--force` flag.
