#!/bin/bash

# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at 
# https://securityonion.net/license; you may not use this file except in compliance with the
# Elastic License 2.0.



# Show Zeek stats (capstats, netstats)

show_stats() {
  echo '##############'
  echo '# Zeek Stats #'
  echo '##############'
  echo
  echo "Average throughput:"
  echo
  docker exec so-zeek env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin /opt/zeek/bin/zeekctl capstats
  echo
  echo "Average packet loss:"
  echo
  docker exec so-zeek env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin /opt/zeek/bin/zeekctl netstats
  echo
}

if docker ps | grep -q zeek; then
  show_stats
else
  echo "Zeek is not running! Try starting it with 'so-zeek-start'." && exit 1;
fi
