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

Commit

Permalink
securityonion-sostat: update Elastic verbiage for when components are…
Browse files Browse the repository at this point in the history
  • Loading branch information
dougburks committed Sep 9, 2019
1 parent 05565b5 commit 63820c2
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bin/sostat
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
else
echo
CLUST_NAME=$(grep cluster.name /etc/elasticsearch/elasticsearch.yml | awk '{print $2}'|sed -e 's/^"//' -e 's/"$//')
echo && echo -e "Elasticsearch is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-elasticsearch'\n\n\nIf that does not work, try checking /var/log/elasticsearch/"$CLUST_NAME".log for clues."
echo && echo -e "Elasticsearch is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-elasticsearch-start'\n\n\nIf that does not work, try checking /var/log/elasticsearch/"$CLUST_NAME".log for clues."
fi

if [ "$LOGSTASH_ENABLED" = "yes" ]; then
Expand Down Expand Up @@ -565,7 +565,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo "To obtain queue stats, try running sostat again in a few minutes."
fi
else
echo && echo -e "Logstash is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-logstash'\n\n\nIf that does not work, try checking /var/log/logstash/logstash.log for clues."
echo && echo -e "Logstash is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-logstash-start'\n\n\nIf that does not work, try checking /var/log/logstash/logstash.log for clues."
fi
fi

Expand All @@ -590,7 +590,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo
docker stats --no-stream so-kibana
else
echo && echo -e "Kibana is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-kibana'\n\n\nIf that does not work, try checking /var/log/kibana/kibana.log for clues."
echo && echo -e "Kibana is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-kibana-start'\n\n\nIf that does not work, try checking /var/log/kibana/kibana.log for clues."
fi
fi

Expand All @@ -602,7 +602,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo
docker stats --no-stream so-elastalert
else
echo && echo -e "ElastAlert is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-elastalert'\n\n\nIf that does not work, try checking /var/log/elastalert/elastalert_stderr.log for clues."
echo && echo -e "ElastAlert is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-elastalert-start'\n\n\nIf that does not work, try checking /var/log/elastalert/elastalert_stderr.log for clues."
fi
fi

Expand All @@ -614,7 +614,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo
docker stats --no-stream so-curator
else
echo && echo -e "Curator is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-curator'\n\n\nIf that does not work, try checking /var/log/curator/curator.log for clues."
echo && echo -e "Curator is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-curator-start'\n\n\nIf that does not work, try checking /var/log/curator/curator.log for clues."
fi
fi

Expand All @@ -634,10 +634,10 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo "Freq Server is working."
else
echo
echo "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-freqserver'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
echo "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-freqserver-start'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
fi
else
echo && echo -e "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-freqserver'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
echo && echo -e "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-freqserver-start'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
fi
fi

Expand All @@ -657,10 +657,10 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ]; then
echo "Domain_stats is working."
else
echo
echo "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-domainstats'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
echo "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-domainstats-start'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
fi
else
echo && echo -e "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-domainstats'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
echo && echo -e "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-domainstats-start'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
fi
fi
if [ "$ES_RUNNING" ]; then
Expand Down
12 changes: 12 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
securityonion-sostat (20120722-0ubuntu0securityonion130) xenial; urgency=medium

* securityonion-sostat: update Elastic verbiage for when components are not running Security-Onion-Solutions/security-onion#1633

-- Doug Burks <[email protected]> Mon, 09 Sep 2019 15:52:53 -0400

securityonion-sostat (20120722-0ubuntu0securityonion129) xenial; urgency=medium

* sostat: support elastic auth #1562

-- Doug Burks <[email protected]> Fri, 12 Jul 2019 15:16:18 -0400

securityonion-sostat (20120722-0ubuntu0securityonion128) xenial; urgency=medium

* fix spacing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
securityonion-sostat (20120722-0ubuntu0securityonion130) xenial; urgency=medium
.
* securityonion-sostat: update Elastic verbiage for when components are not running Security-Onion-Solutions/security-onion#1633
Author: Doug Burks <[email protected]>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- securityonion-sostat-20120722.orig/bin/sostat
+++ securityonion-sostat-20120722/bin/sostat
@@ -517,7 +517,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
else
echo
CLUST_NAME=$(grep cluster.name /etc/elasticsearch/elasticsearch.yml | awk '{print $2}'|sed -e 's/^"//' -e 's/"$//')
- echo && echo -e "Elasticsearch is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-elasticsearch'\n\n\nIf that does not work, try checking /var/log/elasticsearch/"$CLUST_NAME".log for clues."
+ echo && echo -e "Elasticsearch is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-elasticsearch-start'\n\n\nIf that does not work, try checking /var/log/elasticsearch/"$CLUST_NAME".log for clues."
fi

if [ "$LOGSTASH_ENABLED" = "yes" ]; then
@@ -565,7 +565,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo "To obtain queue stats, try running sostat again in a few minutes."
fi
else
- echo && echo -e "Logstash is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-logstash'\n\n\nIf that does not work, try checking /var/log/logstash/logstash.log for clues."
+ echo && echo -e "Logstash is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-logstash-start'\n\n\nIf that does not work, try checking /var/log/logstash/logstash.log for clues."
fi
fi

@@ -590,7 +590,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo
docker stats --no-stream so-kibana
else
- echo && echo -e "Kibana is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-kibana'\n\n\nIf that does not work, try checking /var/log/kibana/kibana.log for clues."
+ echo && echo -e "Kibana is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-kibana-start'\n\n\nIf that does not work, try checking /var/log/kibana/kibana.log for clues."
fi
fi

@@ -602,7 +602,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo
docker stats --no-stream so-elastalert
else
- echo && echo -e "ElastAlert is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-elastalert'\n\n\nIf that does not work, try checking /var/log/elastalert/elastalert_stderr.log for clues."
+ echo && echo -e "ElastAlert is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-elastalert-start'\n\n\nIf that does not work, try checking /var/log/elastalert/elastalert_stderr.log for clues."
fi
fi

@@ -614,7 +614,7 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo
docker stats --no-stream so-curator
else
- echo && echo -e "Curator is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-curator'\n\n\nIf that does not work, try checking /var/log/curator/curator.log for clues."
+ echo && echo -e "Curator is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-curator-start'\n\n\nIf that does not work, try checking /var/log/curator/curator.log for clues."
fi
fi

@@ -634,10 +634,10 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo "Freq Server is working."
else
echo
- echo "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-freqserver'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
+ echo "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-freqserver-start'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
fi
else
- echo && echo -e "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-freqserver'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
+ echo && echo -e "Freq_server is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-freqserver-start'\n\n\nIf that does not work, try checking /var/log/freq_server/freq_server.log for clues."
fi
fi

@@ -657,10 +657,10 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
echo "Domain_stats is working."
else
echo
- echo "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-domainstats'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
+ echo "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-domainstats-start'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
fi
else
- echo && echo -e "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo docker start so-domainstats'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
+ echo && echo -e "Domain_stats is not running.\n\nTry starting it with:\n\n'sudo so-elastic-start'\n OR\n'sudo so-domainstats-start'\n\n\nIf that does not work, try checking /var/log/domain_stats/domain_stats.log for clues."
fi
fi
if [ "$ES_RUNNING" ]; then
2 changes: 2 additions & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ securityonion-sostat:-awk-division-error-when-Bro-doesn't-report-stats-correctly
re-apply-debconffrontend-noninteractive
issues-1536-and-1544
fix-spacing
sostat:-support-elastic-auth-#1562
securityonion-sostat:-update-Elastic-verbiage-for-when-components-are-not-running-Security-Onion-Solutionssecurity-onion#1633
67 changes: 67 additions & 0 deletions debian/patches/sostat:-support-elastic-auth-#1562
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
securityonion-sostat (20120722-0ubuntu0securityonion129) xenial; urgency=medium
.
* sostat: support elastic auth #1562
Author: Doug Burks <[email protected]>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- securityonion-sostat-20120722.orig/bin/sostat
+++ securityonion-sostat-20120722/bin/sostat
@@ -471,16 +471,18 @@ 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)
@@ -488,8 +490,8 @@ if [ "$ELASTICSEARCH_ENABLED" = "yes" ];
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)))
)


0 comments on commit 63820c2

Please sign in to comment.