Skip to content

Commit

Permalink
Blank Discover Tab
Browse files Browse the repository at this point in the history
When installing, the discover tab would be blank when loading Kibana.
Adding sleep to the install to allow the initial index/config to be
created before importing dashboards and mappings.
  • Loading branch information
Travis Smith committed Jul 17, 2017
1 parent 551e356 commit 74c4511
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions install/elasticSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,32 @@ def install(fileCheckKey):
#Sleeping 10 seconds to begin with to give it time to startup.
sleep(10)
while True:
writeSsIndex=os.popen('curl -XPUT \'localhost:9200/sweet_security?pretty\' -H \'Content-Type: application/json\' -d\' {"mappings" : {"ports" : {"properties" : {"mac" : {"type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "port" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}},"protocol" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}},"name" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "product" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "version" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "lastSeen": { "type" : "date" }}}, "devices" : { "properties" : { "hostname" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "nickname" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "ip4" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "mac" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "vendor" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "ignore" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "active" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "defaultFwAction" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "isolate" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "firstSeen" : { "type" : "date" }, "lastSeen" : { "type" : "date" }}}, "firewallProfiles" : { "properties" : { "mac" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "destination" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "action" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}}}}}\'').read()
writeSsIndex = os.popen(
'curl -XPUT \'localhost:9200/sweet_security?pretty\' -H \'Content-Type: application/json\' -d\' {"mappings" : {"ports" : {"properties" : {"mac" : {"type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "port" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}},"protocol" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}},"name" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "product" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "version" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "lastSeen": { "type" : "date" }}}, "devices" : { "properties" : { "hostname" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "nickname" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "ip4" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "mac" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "vendor" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "ignore" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "active" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "defaultFwAction" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "isolate" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "firstSeen" : { "type" : "date" }, "lastSeen" : { "type" : "date" }}}, "firewallProfiles" : { "properties" : { "mac" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "destination" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}, "action" : { "type" : "text", "fields": {"keyword": {"type": "keyword"}}}}}}}\'').read()
try:
jsonSS=json.loads(writeSsIndex)
jsonSS = json.loads(writeSsIndex)
if jsonSS['acknowledged'] == True:
print " sweet_security index created"
break
else:
print "Waiting for Elasticsearch to start, will try again in 10 seconds..."
except:
print "Error: Waiting for Elasticsearch to start, will try again in 10 seconds..."
#Sleep 10 seconds to give ES time to get started
# Sleep 10 seconds to give ES time to get started
sleep(10)
while True:
writeSsAlertIndex=os.popen('curl -XPUT \'localhost:9200/sweet_security_alerts?pretty\' -H \'Content-Type: application/json\' -d\'{ "mappings" : { "alerts" : { "properties" : { "source" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "message" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "mac" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "firstSeen" : { "type" : "date" }, "addressedOn" : { "type" : "date" }, "addressed" : { "type" : "integer"}}}}}\'').read()
writeSsAlertIndex = os.popen(
'curl -XPUT \'localhost:9200/sweet_security_alerts?pretty\' -H \'Content-Type: application/json\' -d\'{ "mappings" : { "alerts" : { "properties" : { "source" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "message" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "mac" : { "type" : "text", "fields": {"raw": {"type": "keyword"}}}, "firstSeen" : { "type" : "date" }, "addressedOn" : { "type" : "date" }, "addressed" : { "type" : "integer"}}}}}\'').read()
try:
jsonSSAlert=json.loads(writeSsAlertIndex)
jsonSSAlert = json.loads(writeSsAlertIndex)
if jsonSSAlert['acknowledged'] == True:
print " sweet_security_alert index created"
break
else:
print "Waiting for Elasticsearch to start, will try again in 10 seconds..."
except:
print "Error: Waiting for Elasticsearch to start, will try again in 10 seconds..."
#Sleep 10 seconds to give ES time to get started
# Sleep 10 seconds to give ES time to get started
sleep(10)
try:
try:
Expand All @@ -87,7 +89,8 @@ def install(fileCheckKey):
if fileCheckKey is None:
configData = {'defaultMonitor': 0, 'defaultIsolate': 0, 'defaultFW': 1, 'defaultLogRetention': 0}
else:
configData = {'defaultMonitor': 0, 'defaultIsolate': 0, 'defaultFW': 1, 'defaultLogRetention': 0, 'fileCheckKey': fileCheckKey}
configData = {'defaultMonitor': 0, 'defaultIsolate': 0, 'defaultFW': 1, 'defaultLogRetention': 0,
'fileCheckKey': fileCheckKey}
res = esService.index(index='sweet_security', doc_type='configuration', body=configData)
return res
except Exception, e:
Expand Down
3 changes: 3 additions & 0 deletions install/kibana.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def install(chosenInterfaceIP):
os.popen('sudo service kibana start').read()
else:
print "Kibana already installed"
#Having to induce sleep so Kibana can create initial index stuff
sleep(10)
print "Importing Kibana Index Patterns"
patternPath = os.path.join(cwd, 'kibana/patterns')
for file in os.listdir(patternPath):
Expand All @@ -99,6 +101,7 @@ def install(chosenInterfaceIP):
sleep(10)



def importDashboard(jsonFileName):
from elasticsearch import Elasticsearch
esService = Elasticsearch()
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def validateIP(ip):
os.popen('sudo htpasswd -cb /etc/apache2/.elasticsearch %s "%s"' % (elasticUser, elasticPass)).read()
# Get system default configurations
fileCheckKey = None
fileCheckKey = None
while True:
installFileCheck = get_user_input("\033[1mCheck Files Against FileCheck.IO (y/N)\033[0m: ")
if installFileCheck.lower() not in ('y', 'n', ''):
Expand Down

0 comments on commit 74c4511

Please sign in to comment.