mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #322 from Security-Onion-Solutions/hotfix/so-status
hotfix/so-status
This commit is contained in:
@@ -17,7 +17,7 @@ eval:
|
|||||||
- so-idstools
|
- so-idstools
|
||||||
- so-auth-api
|
- so-auth-api
|
||||||
- so-auth-ui
|
- so-auth-ui
|
||||||
{%- if OSQUERY != 0 %}
|
{%- if OSQUERY != '0' %}
|
||||||
- so-mysql
|
- so-mysql
|
||||||
- so-fleet
|
- so-fleet
|
||||||
- so-redis
|
- so-redis
|
||||||
@@ -29,24 +29,24 @@ eval:
|
|||||||
- so-suricata
|
- so-suricata
|
||||||
- so-zeek
|
- so-zeek
|
||||||
- so-curator
|
- so-curator
|
||||||
- so-elasalert
|
- so-elastalert
|
||||||
{%- if WAZUH != 0 %}
|
{%- if WAZUH != '0' %}
|
||||||
- so-wazuh
|
- so-wazuh
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- so-soctopus
|
- so-soctopus
|
||||||
{%- if THEHIVE != 0 %}
|
{%- if THEHIVE != '0' %}
|
||||||
- so-thehive
|
- so-thehive
|
||||||
- so-thehive-es
|
- so-thehive-es
|
||||||
- so-cortex
|
- so-cortex
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if PLAYBOOK != 0 %}
|
{%- if PLAYBOOK != '0' %}
|
||||||
- so-playbook
|
- so-playbook
|
||||||
- so-navigator
|
- so-navigator
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if FREQSERVER != 0 %}
|
{%- if FREQSERVER != '0' %}
|
||||||
- so-freqserver
|
- so-freqserver
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if DOMAINSTATS != 0 %}
|
{%- if DOMAINSTATS != '0' %}
|
||||||
- so-domainstats
|
- so-domainstats
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
heavy_node:
|
heavy_node:
|
||||||
@@ -104,31 +104,31 @@ master_search:
|
|||||||
- so-elasticsearch
|
- so-elasticsearch
|
||||||
- so-curator
|
- so-curator
|
||||||
- so-kibana
|
- so-kibana
|
||||||
- so-elasalert
|
- so-elastalert
|
||||||
- so-filebeat
|
- so-filebeat
|
||||||
- so-soctopus
|
- so-soctopus
|
||||||
{%- if OSQUERY != 0 %}
|
{%- if OSQUERY != '0' %}
|
||||||
- so-mysql
|
- so-mysql
|
||||||
- so-fleet
|
- so-fleet
|
||||||
- so-redis
|
- so-redis
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if WAZUH != 0 %}
|
{%- if WAZUH != '0' %}
|
||||||
- so-wazuh
|
- so-wazuh
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- so-soctopus
|
- so-soctopus
|
||||||
{%- if THEHIVE != 0 %}
|
{%- if THEHIVE != '0' %}
|
||||||
- so-thehive
|
- so-thehive
|
||||||
- so-thehive-es
|
- so-thehive-es
|
||||||
- so-cortex
|
- so-cortex
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if PLAYBOOK != 0 %}
|
{%- if PLAYBOOK != '0' %}
|
||||||
- so-playbook
|
- so-playbook
|
||||||
- so-navigator
|
- so-navigator
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if FREQSERVER != 0 %}
|
{%- if FREQSERVER != '0' %}
|
||||||
- so-freqserver
|
- so-freqserver
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if DOMAINSTATS != 0 %}
|
{%- if DOMAINSTATS != '0' %}
|
||||||
- so-domainstats
|
- so-domainstats
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
master:
|
master:
|
||||||
@@ -147,30 +147,30 @@ master:
|
|||||||
- so-elasticsearch
|
- so-elasticsearch
|
||||||
- so-logstash
|
- so-logstash
|
||||||
- so-kibana
|
- so-kibana
|
||||||
- so-elasalert
|
- so-elastalert
|
||||||
- so-filebeat
|
- so-filebeat
|
||||||
{%- if OSQUERY != 0 %}
|
{%- if OSQUERY != '0' %}
|
||||||
- so-mysql
|
- so-mysql
|
||||||
- so-fleet
|
- so-fleet
|
||||||
- so-redis
|
- so-redis
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if WAZUH != 0 %}
|
{%- if WAZUH != '0' %}
|
||||||
- so-wazuh
|
- so-wazuh
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- so-soctopus
|
- so-soctopus
|
||||||
{%- if THEHIVE != 0 %}
|
{%- if THEHIVE != '0' %}
|
||||||
- so-thehive
|
- so-thehive
|
||||||
- so-thehive-es
|
- so-thehive-es
|
||||||
- so-cortex
|
- so-cortex
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if PLAYBOOK != 0 %}
|
{%- if PLAYBOOK != '0' %}
|
||||||
- so-playbook
|
- so-playbook
|
||||||
- so-navigator
|
- so-navigator
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if FREQSERVER != 0 %}
|
{%- if FREQSERVER != '0' %}
|
||||||
- so-freqserver
|
- so-freqserver
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if DOMAINSTATS != 0 %}
|
{%- if DOMAINSTATS != '0' %}
|
||||||
- so-domainstats
|
- so-domainstats
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
parser_node:
|
parser_node:
|
||||||
@@ -190,7 +190,7 @@ search_node:
|
|||||||
- so-elasticsearch
|
- so-elasticsearch
|
||||||
- so-curator
|
- so-curator
|
||||||
- so-filebeat
|
- so-filebeat
|
||||||
{%- if WAZUH != 0 %}
|
{%- if WAZUH != '0' %}
|
||||||
- so-wazuh
|
- so-wazuh
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
sensor:
|
sensor:
|
||||||
@@ -213,3 +213,4 @@ warm_node:
|
|||||||
- so-influxdb
|
- so-influxdb
|
||||||
- so-grafana
|
- so-grafana
|
||||||
- so-elasticsearch
|
- so-elasticsearch
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
{%- set pillar_name = pillar_val ~ pillar_suffix -%}
|
{%- set pillar_name = pillar_val ~ pillar_suffix -%}
|
||||||
{%- set container_list = salt['pillar.get'](pillar_name) %}
|
{%- set container_list = salt['pillar.get'](pillar_name) %}
|
||||||
|
|
||||||
if ! [ $(id -u)=0 ]; then
|
if ! [ "$(id -u)" = 0 ]; then
|
||||||
echo "This command must be run as root"
|
echo "This command must be run as root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -52,8 +52,8 @@ ERROR_STRING="ERROR"
|
|||||||
SUCCESS_STRING="OK"
|
SUCCESS_STRING="OK"
|
||||||
PENDING_STRING="PENDING"
|
PENDING_STRING="PENDING"
|
||||||
MISSING_STRING='MISSING'
|
MISSING_STRING='MISSING'
|
||||||
declare -a BAD_STATUSES=("removing", "paused", "exited", "dead")
|
declare -a BAD_STATUSES=("removing" "paused" "exited" "dead")
|
||||||
declare -a PENDING_STATUSES=("paused", "created", "restarting")
|
declare -a PENDING_STATUSES=("paused" "created" "restarting")
|
||||||
declare -a GOOD_STATUSES=("running")
|
declare -a GOOD_STATUSES=("running")
|
||||||
|
|
||||||
declare -a temp_container_name_list=()
|
declare -a temp_container_name_list=()
|
||||||
@@ -72,16 +72,16 @@ compare_lists() {
|
|||||||
create_expected_container_list
|
create_expected_container_list
|
||||||
|
|
||||||
if [[ ${#expected_container_list[@]} = 0 ]]; then
|
if [[ ${#expected_container_list[@]} = 0 ]]; then
|
||||||
container_name_list=$temp_container_name_list
|
container_name_list="${temp_container_name_list[*]}"
|
||||||
container_state_list=$temp_container_state_list
|
container_state_list="${temp_container_state_list[*]}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for intended_item in ${expected_container_list[@]}; do
|
for intended_item in "${expected_container_list[@]}"; do
|
||||||
found = 0
|
found=0
|
||||||
for i in ${!temp_container_name_list[@]}; do
|
for i in "${!temp_container_name_list[@]}"; do
|
||||||
[[ ${temp_container_name_list[$i]} = $intended_item ]] \
|
[[ ${temp_container_name_list[$i]} = "$intended_item" ]] \
|
||||||
&& found = 1 \
|
&& found=1 \
|
||||||
&& container_name_list+=("${temp_container_name_list[$i]}") \
|
&& container_name_list+=("${temp_container_name_list[$i]}") \
|
||||||
&& container_state_list+=("${temp_container_state_list[$i]}") \
|
&& container_state_list+=("${temp_container_state_list[$i]}") \
|
||||||
&& break
|
&& break
|
||||||
@@ -115,7 +115,7 @@ populate_container_lists() {
|
|||||||
local container_name=""
|
local container_name=""
|
||||||
local container_state=""
|
local container_state=""
|
||||||
|
|
||||||
for line in ${docker_raw_list[@]}; do
|
for line in "${docker_raw_list[@]}"; do
|
||||||
container_name="$( echo $line | sed -e 's/Name:\(.*\),State:\(.*\)/\1/' )" # Get value in the first search group (container names)
|
container_name="$( echo $line | sed -e 's/Name:\(.*\),State:\(.*\)/\1/' )" # Get value in the first search group (container names)
|
||||||
container_state="$( echo $line | sed -e 's/Name:\(.*\),State:\(.*\)/\2/' )" # Get value in the second search group (container states)
|
container_state="$( echo $line | sed -e 's/Name:\(.*\),State:\(.*\)/\2/' )" # Get value in the second search group (container states)
|
||||||
|
|
||||||
@@ -132,16 +132,16 @@ parse_status() {
|
|||||||
[[ $container_state = "missing" ]] && printf $MISSING_STRING && return 1
|
[[ $container_state = "missing" ]] && printf $MISSING_STRING && return 1
|
||||||
|
|
||||||
for state in "${GOOD_STATUSES[@]}"; do
|
for state in "${GOOD_STATUSES[@]}"; do
|
||||||
[[ $container_state = $state ]] && printf $SUCCESS_STRING && return 0
|
[[ $container_state = "$state" ]] && printf $SUCCESS_STRING && return 0
|
||||||
done
|
done
|
||||||
|
|
||||||
for state in "${PENDING_STATUSES[@]}"; do
|
for state in "${PENDING_STATUSES[@]}"; do
|
||||||
[[ $container_state = $state ]] && printf $PENDING_STRING && return 0
|
[[ $container_state = "$state" ]] && printf $PENDING_STRING && return 0
|
||||||
done
|
done
|
||||||
|
|
||||||
# This is technically not needed since the default is error state
|
# This is technically not needed since the default is error state
|
||||||
for state in "${BAD_STATUSES[@]}"; do
|
for state in "${BAD_STATUSES[@]}"; do
|
||||||
[[ $container_state = $state ]] && printf $ERROR_STRING && return 1
|
[[ $container_state = "$state" ]] && printf $ERROR_STRING && return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
printf $ERROR_STRING && return 1
|
printf $ERROR_STRING && return 1
|
||||||
@@ -151,17 +151,17 @@ parse_status() {
|
|||||||
|
|
||||||
print_line() {
|
print_line() {
|
||||||
local service_name=${1}
|
local service_name=${1}
|
||||||
local service_state=$( parse_status ${2} )
|
local service_state="$( parse_status ${2} )"
|
||||||
local columns=$(tput cols)
|
local columns=$(tput cols)
|
||||||
local state_color="\e[0m"
|
local state_color="\e[0m"
|
||||||
|
|
||||||
local PADDING_CONSTANT=14
|
local PADDING_CONSTANT=14
|
||||||
|
|
||||||
if [[ $service_state = $ERROR_STRING ]] || [[ $service_state = $MISSING_STRING ]]; then
|
if [[ $service_state = "$ERROR_STRING" ]] || [[ $service_state = "$MISSING_STRING" ]]; then
|
||||||
state_color="\e[1;31m"
|
state_color="\e[1;31m"
|
||||||
elif [[ $service_state = $SUCCESS_STRING ]]; then
|
elif [[ $service_state = "$SUCCESS_STRING" ]]; then
|
||||||
state_color="\e[1;32m"
|
state_color="\e[1;32m"
|
||||||
elif [[ $service_state = $PENDING_STRING ]]; then
|
elif [[ $service_state = "$PENDING_STRING" ]]; then
|
||||||
state_color="\e[1;33m"
|
state_color="\e[1;33m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ main() {
|
|||||||
printf "\n"
|
printf "\n"
|
||||||
printf "${focus_color}%b\e[0m" "Checking container statuses\n\n"
|
printf "${focus_color}%b\e[0m" "Checking container statuses\n\n"
|
||||||
|
|
||||||
local num_containers=${#docker_raw_list[@]}
|
local num_containers=${#container_name_list[@]}
|
||||||
|
|
||||||
for i in $(seq 0 $(($num_containers - 1 ))); do
|
for i in $(seq 0 $(($num_containers - 1 ))); do
|
||||||
print_line ${container_name_list[$i]} ${container_state_list[$i]}
|
print_line ${container_name_list[$i]} ${container_state_list[$i]}
|
||||||
@@ -204,4 +204,3 @@ main() {
|
|||||||
|
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user