mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #11970 from Security-Onion-Solutions/jertel/hfm
grid page enhancements
This commit is contained in:
@@ -9,23 +9,23 @@ if [ -f /usr/sbin/so-common ]; then
|
|||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
function usage() {
|
||||||
echo "This script must be run using sudo!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# -lt 1 ]]; then
|
|
||||||
echo "Usage: $0 -o=<operation> -m=[id]"
|
echo "Usage: $0 -o=<operation> -m=[id]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " where <operation> is one of the following:"
|
echo " where <operation> is one of the following:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " list: Lists all keys with hashes"
|
echo " add: Accepts a new key and adds the minion files"
|
||||||
echo " accept: Accepts a new key and adds the minion files"
|
|
||||||
echo " delete: Removes the key and deletes the minion files"
|
echo " delete: Removes the key and deletes the minion files"
|
||||||
|
echo " list: Lists all keys with hashes"
|
||||||
echo " reject: Rejects a key"
|
echo " reject: Rejects a key"
|
||||||
|
echo " restart: Restart a minion (reboot)"
|
||||||
echo " test: Perform minion test"
|
echo " test: Perform minion test"
|
||||||
echo ""
|
echo ""
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
@@ -38,6 +38,8 @@ for i in "$@"; do
|
|||||||
MINION_ID="${i#*=}"
|
MINION_ID="${i#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
# The following args are used internally during setup, not to be specified manually.
|
||||||
-e=*|--esheap=*)
|
-e=*|--esheap=*)
|
||||||
ES_HEAP_SIZE="${i#*=}"
|
ES_HEAP_SIZE="${i#*=}"
|
||||||
shift
|
shift
|
||||||
@@ -63,6 +65,7 @@ for i in "$@"; do
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -76,7 +79,7 @@ function getinstallinfo() {
|
|||||||
source <(echo $INSTALLVARS)
|
source <(echo $INSTALLVARS)
|
||||||
}
|
}
|
||||||
|
|
||||||
function testminion() {
|
function testMinion() {
|
||||||
# Always run on the host, since this is going to be the manager of a distributed grid, or an eval/standalone.
|
# Always run on the host, since this is going to be the manager of a distributed grid, or an eval/standalone.
|
||||||
# Distributed managers must run this in order for the sensor nodes to have access to the so-tcpreplay image.
|
# Distributed managers must run this in order for the sensor nodes to have access to the so-tcpreplay image.
|
||||||
so-test
|
so-test
|
||||||
@@ -92,12 +95,19 @@ function testminion() {
|
|||||||
exit $result
|
exit $result
|
||||||
}
|
}
|
||||||
|
|
||||||
function listminions() {
|
function restartMinion() {
|
||||||
|
salt "$MINION_ID" system.reboot
|
||||||
|
result=$?
|
||||||
|
|
||||||
|
exit $result
|
||||||
|
}
|
||||||
|
|
||||||
|
function listMinions() {
|
||||||
salt-key list -F --out=json
|
salt-key list -F --out=json
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
function rejectminion() {
|
function rejectMinion() {
|
||||||
salt-key -y -r $MINION_ID
|
salt-key -y -r $MINION_ID
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
@@ -106,11 +116,11 @@ function acceptminion() {
|
|||||||
salt-key -y -a $MINION_ID
|
salt-key -y -a $MINION_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteminion() {
|
function deleteMinion() {
|
||||||
salt-key -y -d $MINION_ID
|
salt-key -y -d $MINION_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteminionfiles () {
|
function deleteMinionFiles () {
|
||||||
rm -f $PILLARFILE
|
rm -f $PILLARFILE
|
||||||
rm -f $ADVPILLARFILE
|
rm -f $ADVPILLARFILE
|
||||||
}
|
}
|
||||||
@@ -589,25 +599,33 @@ function testConnection() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$OPERATION" = 'list' ]]; then
|
function addMinion() {
|
||||||
listminions
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$OPERATION" = 'delete' ]]; then
|
|
||||||
deleteminionfiles
|
|
||||||
deleteminion
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$OPERATION" == 'add' || "$OPERATION" == 'setup' ]]; then
|
|
||||||
# Skip this if its setup
|
|
||||||
if [[ $OPERATION == 'add' ]]; then
|
|
||||||
# Accept the salt key
|
# Accept the salt key
|
||||||
acceptminion
|
acceptminion
|
||||||
# Test to see if the minion was accepted
|
# Test to see if the minion was accepted
|
||||||
testConnection
|
testConnection
|
||||||
# Pull the info from the file to build what is needed
|
# Pull the info from the file to build what is needed
|
||||||
getinstallinfo
|
getinstallinfo
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateMineAndApplyStates() {
|
||||||
|
# tell the minion to populate the mine with data from mine_functions which is populated during setup
|
||||||
|
# this only needs to happen on non managers since they handle this during setup
|
||||||
|
# and they need to wait for ca creation to update the mine
|
||||||
|
updateMine
|
||||||
|
checkMine "network.ip_addrs"
|
||||||
|
# apply the elasticsearch state to the manager if a new searchnode was added
|
||||||
|
if [[ "$NODETYPE" == "SEARCHNODE" || "$NODETYPE" == "HEAVYNODE" ]]; then
|
||||||
|
# calls so-common and set_minionid sets MINIONID to local minion id
|
||||||
|
set_minionid
|
||||||
|
salt $MINIONID state.apply elasticsearch queue=True --async
|
||||||
|
salt $MINIONID state.apply soc queue=True --async
|
||||||
fi
|
fi
|
||||||
|
# run this async so the cli doesn't wait for a return
|
||||||
|
salt "$MINION_ID" state.highstate --async queue=True
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupMinionFiles() {
|
||||||
# Check to see if nodetype is set
|
# Check to see if nodetype is set
|
||||||
if [ -z $NODETYPE ]; then
|
if [ -z $NODETYPE ]; then
|
||||||
echo "No node type specified"
|
echo "No node type specified"
|
||||||
@@ -624,25 +642,41 @@ if [[ "$OPERATION" == 'add' || "$OPERATION" == 'setup' ]]; then
|
|||||||
|
|
||||||
create$NODETYPE
|
create$NODETYPE
|
||||||
echo "Minion file created for $MINION_ID"
|
echo "Minion file created for $MINION_ID"
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "$OPERATION" == 'add' ]]; then
|
case "$OPERATION" in
|
||||||
# tell the minion to populate the mine with data from mine_functions which is populated during setup
|
"add")
|
||||||
# this only needs to happen on non managers since they handle this during setup
|
addMinion
|
||||||
# and they need to wait for ca creation to update the mine
|
setupMinionFiles
|
||||||
updateMine
|
updateMineAndApplyStates
|
||||||
checkMine "network.ip_addrs"
|
;;
|
||||||
# apply the elasticsearch state to the manager if a new searchnode was added
|
|
||||||
if [[ "$NODETYPE" == "SEARCHNODE" || "$NODETYPE" == "HEAVYNODE" ]]; then
|
|
||||||
# calls so-common and set_minionid sets MINIONID to local minion id
|
|
||||||
set_minionid
|
|
||||||
salt $MINIONID state.apply elasticsearch queue=True --async
|
|
||||||
salt $MINIONID state.apply soc queue=True --async
|
|
||||||
fi
|
|
||||||
# run this async so the cli doesn't wait for a return
|
|
||||||
salt "$MINION_ID" state.highstate --async queue=True
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$OPERATION" = 'test' ]]; then
|
"delete")
|
||||||
testminion
|
deleteMinionFiles
|
||||||
fi
|
deleteMinion
|
||||||
|
;;
|
||||||
|
|
||||||
|
"list")
|
||||||
|
listMinions
|
||||||
|
;;
|
||||||
|
|
||||||
|
"reject")
|
||||||
|
rejectMinion
|
||||||
|
;;
|
||||||
|
|
||||||
|
"restart")
|
||||||
|
restartMinion
|
||||||
|
;;
|
||||||
|
|
||||||
|
"setup")
|
||||||
|
# only should be invoked directly during setup, never manually
|
||||||
|
setupMinionFiles
|
||||||
|
;;
|
||||||
|
|
||||||
|
"test")
|
||||||
|
testMinion
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -14,6 +14,7 @@ telegraf:
|
|||||||
- checkfiles.sh
|
- checkfiles.sh
|
||||||
- influxdbsize.sh
|
- influxdbsize.sh
|
||||||
- oldpcap.sh
|
- oldpcap.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
- stenoloss.sh
|
- stenoloss.sh
|
||||||
@@ -25,6 +26,7 @@ telegraf:
|
|||||||
- eps.sh
|
- eps.sh
|
||||||
- influxdbsize.sh
|
- influxdbsize.sh
|
||||||
- oldpcap.sh
|
- oldpcap.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- redis.sh
|
- redis.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
@@ -34,20 +36,24 @@ telegraf:
|
|||||||
- zeekloss.sh
|
- zeekloss.sh
|
||||||
manager:
|
manager:
|
||||||
- influxdbsize.sh
|
- influxdbsize.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- redis.sh
|
- redis.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
managersearch:
|
managersearch:
|
||||||
- eps.sh
|
- eps.sh
|
||||||
- influxdbsize.sh
|
- influxdbsize.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- redis.sh
|
- redis.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
import:
|
import:
|
||||||
|
- os.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
sensor:
|
sensor:
|
||||||
- checkfiles.sh
|
- checkfiles.sh
|
||||||
- oldpcap.sh
|
- oldpcap.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
- stenoloss.sh
|
- stenoloss.sh
|
||||||
@@ -58,6 +64,7 @@ telegraf:
|
|||||||
- checkfiles.sh
|
- checkfiles.sh
|
||||||
- eps.sh
|
- eps.sh
|
||||||
- oldpcap.sh
|
- oldpcap.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- redis.sh
|
- redis.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
@@ -66,17 +73,22 @@ telegraf:
|
|||||||
- zeekcaptureloss.sh
|
- zeekcaptureloss.sh
|
||||||
- zeekloss.sh
|
- zeekloss.sh
|
||||||
idh:
|
idh:
|
||||||
|
- os.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
searchnode:
|
searchnode:
|
||||||
- eps.sh
|
- eps.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
receiver:
|
receiver:
|
||||||
- eps.sh
|
- eps.sh
|
||||||
|
- os.sh
|
||||||
- raid.sh
|
- raid.sh
|
||||||
- redis.sh
|
- redis.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
fleet:
|
fleet:
|
||||||
|
- os.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
desktop:
|
desktop:
|
||||||
|
- os.sh
|
||||||
- sostatus.sh
|
- sostatus.sh
|
||||||
|
|||||||
29
salt/telegraf/scripts/os.sh
Normal file
29
salt/telegraf/scripts/os.sh
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
# if this script isn't already running
|
||||||
|
if [[ ! "`pidof -x $(basename $0) -o %PPID`" ]]; then
|
||||||
|
|
||||||
|
NEEDS_RESTART=0
|
||||||
|
|
||||||
|
if which needs-restarting &> /dev/null; then
|
||||||
|
# DNF/RPM family
|
||||||
|
if ! needs-restarting -r &> /dev/null; then
|
||||||
|
NEEDS_RESTART=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# APT family
|
||||||
|
if [ -f /var/run/reboot-required ]; then
|
||||||
|
NEEDS_RESTART=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "os restart=$NEEDS_RESTART"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user