Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Commit

Permalink
sostat: support elastic auth Security-Onion-Solutions/security-onion#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dougburks committed Jul 12, 2019
1 parent eb9389c commit 05565b5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions bin/sostat
Original file line number Diff line number Diff line change
Expand Up @@ -471,25 +471,27 @@ fi

if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then

TOT_NODES=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.total)
#SUCCESS_NODES=curl "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.successful`
FAIL_NODES=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.failed)
CLUST_NAME=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .cluster_name)
TOT_INDICES=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.count)
TOT_SHARDS=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.shards.total)
CLUST_STATUS=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .status)
FREE_MEM=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .nodes.os.mem.free_percent)
TOT_DOCS=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.docs.count)
TOT_SIZE=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.store.size_in_bytes)
source /usr/sbin/so-elastic-common

TOT_NODES=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.total)
#SUCCESS_NODES=curl $ELASTICSEARCH_AUTH "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.successful`
FAIL_NODES=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq ._nodes.failed)
CLUST_NAME=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .cluster_name)
TOT_INDICES=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.count)
TOT_SHARDS=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.shards.total)
CLUST_STATUS=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .status)
FREE_MEM=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .nodes.os.mem.free_percent)
TOT_DOCS=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.docs.count)
TOT_SIZE=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cluster/stats?pretty" | jq .indices.store.size_in_bytes)
ES_RUNNING=$(docker ps | grep so-elasticsearch)
LS_RUNNING=$(docker ps | grep so-logstash)
KIB_RUNNING=$(docker ps | grep so-kibana)
ELAST_RUNNING=$(docker ps | grep so-elastalert)
CURAT_RUNNING=$(docker ps | grep so-curator)
FREQ_RUNNING=$(docker ps | grep so-freqserver)
DOMAINSTATS_RUNNING=$(docker ps | grep so-domainstats)
EVENT_COUNT=$(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.docs.count)
AVG_EVENT_SIZE=$(echo $(($(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.store.size_in_bytes) / $(curl -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.docs.count)))
EVENT_COUNT=$(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.docs.count)
AVG_EVENT_SIZE=$(echo $(($(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.store.size_in_bytes) / $(curl $ELASTICSEARCH_AUTH -s "$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/*/_stats" | jq ._all.total.docs.count)))
)


Expand Down

0 comments on commit 05565b5

Please sign in to comment.