mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Move files out of common
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
#!/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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
. /usr/sbin/so-common
|
|
||||||
|
|
||||||
/usr/sbin/so-restart nodered $1
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
. /usr/sbin/so-common
|
|
||||||
|
|
||||||
/usr/sbin/so-start nodered $1
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
. /usr/sbin/so-common
|
|
||||||
|
|
||||||
/usr/sbin/so-stop nodered $1
|
|
||||||
154
salt/elasticsearch/tools/sbin/so-elastic-clear
Executable file
154
salt/elasticsearch/tools/sbin/so-elastic-clear
Executable file
@@ -0,0 +1,154 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
{%- set NODEIP = salt['pillar.get']('host:mainip', '') %}
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
SKIP=0
|
||||||
|
#########################################
|
||||||
|
# Options
|
||||||
|
#########################################
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
Security Onion Elastic Clear
|
||||||
|
Options:
|
||||||
|
-h This message
|
||||||
|
-y Skip interactive mode
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
while getopts "h:cdely" OPTION
|
||||||
|
do
|
||||||
|
case $OPTION in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
DELETE_CASES_DATA=1
|
||||||
|
SKIP=1
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
DONT_STOP_SERVICES=1
|
||||||
|
SKIP=1
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
DELETE_ELASTALERT_DATA=1
|
||||||
|
SKIP=1
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
DELETE_LOG_DATA=1
|
||||||
|
SKIP=1
|
||||||
|
;;
|
||||||
|
y)
|
||||||
|
DELETE_CASES_DATA=1
|
||||||
|
DELETE_ELASTALERT_DATA=1
|
||||||
|
DELETE_LOG_DATA=1
|
||||||
|
SKIP=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ $SKIP -ne 1 ]; then
|
||||||
|
# List indices
|
||||||
|
echo
|
||||||
|
curl -K /opt/so/conf/elasticsearch/curl.config -k -L https://{{ NODEIP }}:9200/_cat/indices?v
|
||||||
|
echo
|
||||||
|
# Inform user we are about to delete all data
|
||||||
|
echo
|
||||||
|
echo "This script will delete all data (documents, indices, etc.) in the Elasticsearch database."
|
||||||
|
echo
|
||||||
|
echo "If you would like to proceed, please type "AGREE" and hit ENTER."
|
||||||
|
echo
|
||||||
|
# Read user input
|
||||||
|
read INPUT
|
||||||
|
if [ "$INPUT" != "AGREE" ] ; then exit 0; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$DONT_STOP_SERVICES" ]; then
|
||||||
|
# Stop Elastic Agent
|
||||||
|
for i in $(pgrep elastic-agent | grep -v grep); do
|
||||||
|
kill -9 $i;
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check to see if Elastic Fleet, Logstash, Elastalert are running
|
||||||
|
#EF_ENABLED=$(so-status | grep elastic-fleet)
|
||||||
|
LS_ENABLED=$(so-status | grep logstash)
|
||||||
|
EA_ENABLED=$(so-status | grep elastalert)
|
||||||
|
|
||||||
|
#if [ ! -z "$EF_ENABLED" ]; then
|
||||||
|
# /usr/sbin/so-elastic-fleet-stop
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if [ ! -z "$LS_ENABLED" ]; then
|
||||||
|
/usr/sbin/so-logstash-stop
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$EA_ENABLED" ]; then
|
||||||
|
/usr/sbin/so-elastalert-stop
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$DELETE_CASES_DATA" ]; then
|
||||||
|
# Delete Cases data
|
||||||
|
echo "Deleting Cases data..."
|
||||||
|
INDXS=$(/usr/sbin/so-elasticsearch-query _cat/indices?h=index | grep "so-case")
|
||||||
|
for INDX in ${INDXS}
|
||||||
|
do
|
||||||
|
echo "Deleting $INDX"
|
||||||
|
/usr/sbin/so-elasticsearch-query ${INDX} -XDELETE > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete Elastalert data
|
||||||
|
if [ ! -z "$DELETE_ELASTALERT_DATA" ]; then
|
||||||
|
# Delete Elastalert data
|
||||||
|
echo "Deleting Elastalert data..."
|
||||||
|
INDXS=$(/usr/sbin/so-elasticsearch-query _cat/indices?h=index | grep "elastalert")
|
||||||
|
for INDX in ${INDXS}
|
||||||
|
do
|
||||||
|
echo "Deleting $INDX"
|
||||||
|
/usr/sbin/so-elasticsearch-query ${INDX} -XDELETE > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete log data
|
||||||
|
if [ ! -z "$DELETE_LOG_DATA" ]; then
|
||||||
|
echo "Deleting log data ..."
|
||||||
|
DATASTREAMS=$(/usr/sbin/so-elasticsearch-query _data_stream | jq -r '.[] |.[].name')
|
||||||
|
for DATASTREAM in ${DATASTREAMS}
|
||||||
|
do
|
||||||
|
# Delete the data stream
|
||||||
|
echo "Deleting $DATASTREAM..."
|
||||||
|
/usr/sbin/so-elasticsearch-query _data_stream/${DATASTREAM} -XDELETE > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DONT_STOP_SERVICES" ]; then
|
||||||
|
#Start Logstash
|
||||||
|
if [ ! -z "$LS_ENABLED" ]; then
|
||||||
|
/usr/sbin/so-logstash-start
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Start Elastic Fleet
|
||||||
|
#if [ ! -z "$EF_ENABLED" ]; then
|
||||||
|
# /usr/sbin/so-elastic-fleet-start
|
||||||
|
#fi
|
||||||
|
|
||||||
|
#Start Elastalert
|
||||||
|
if [ ! -z "$EA_ENABLED" ]; then
|
||||||
|
/usr/sbin/so-elastalert-start
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Elastic Agent
|
||||||
|
/usr/bin/elastic-agent restart
|
||||||
|
fi
|
||||||
25
salt/elasticsearch/tools/sbin/so-elastic-diagnose
Executable file
25
salt/elasticsearch/tools/sbin/so-elastic-diagnose
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Source common settings
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
# Check for log files
|
||||||
|
for FILE in /opt/so/log/elasticsearch/*.log /opt/so/log/logstash/*.log /opt/so/log/kibana/*.log /opt/so/log/elastalert/*.log /opt/so/log/curator/*.log /opt/so/log/freqserver/*.log /opt/so/log/nginx/*.log; do
|
||||||
|
|
||||||
|
# If file exists, then look for errors or warnings
|
||||||
|
if [ -f $FILE ]; then
|
||||||
|
MESSAGE=`grep -i 'ERROR\|FAIL\|WARN' $FILE`
|
||||||
|
if [ ! -z "$MESSAGE" ]; then
|
||||||
|
header $FILE
|
||||||
|
echo $MESSAGE | sed 's/WARN/\nWARN/g' | sed 's/WARNING/\nWARNING/g' | sed 's/ERROR/\nERROR/g' | sort | uniq -c | sort -nr
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
31
salt/elasticsearch/tools/sbin/so-elastic-restart
Executable file
31
salt/elasticsearch/tools/sbin/so-elastic-restart
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode', 'so-import']%}
|
||||||
|
/usr/sbin/so-restart elasticsearch $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval', 'so-manager', 'so-managersearch', 'so-standalone', 'so-import']%}
|
||||||
|
/usr/sbin/so-restart kibana $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-restart logstash $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-restart curator $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone']%}
|
||||||
|
/usr/sbin/so-restart elastalert $1
|
||||||
|
{%- endif %}
|
||||||
31
salt/elasticsearch/tools/sbin/so-elastic-start
Executable file
31
salt/elasticsearch/tools/sbin/so-elastic-start
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode', 'so-import']%}
|
||||||
|
/usr/sbin/so-start elasticsearch $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval', 'so-manager', 'so-managersearch', 'so-standalone', 'so-import']%}
|
||||||
|
/usr/sbin/so-start kibana $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-start logstash $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-start curator $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone']%}
|
||||||
|
/usr/sbin/so-start elastalert $1
|
||||||
|
{%- endif %}
|
||||||
31
salt/elasticsearch/tools/sbin/so-elastic-stop
Executable file
31
salt/elasticsearch/tools/sbin/so-elastic-stop
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode', 'so-import']%}
|
||||||
|
/usr/sbin/so-stop elasticsearch $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval', 'so-manager', 'so-managersearch', 'so-standalone', 'so-import']%}
|
||||||
|
/usr/sbin/so-stop kibana $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-stop logstash $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone', 'so-heavynode', 'so-searchnode']%}
|
||||||
|
/usr/sbin/so-stop curator $1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if grains['role'] in ['so-eval','so-manager', 'so-managersearch', 'so-standalone']%}
|
||||||
|
/usr/sbin/so-stop elastalert $1
|
||||||
|
{%- endif %}
|
||||||
Reference in New Issue
Block a user