Skip to content

Commit

Permalink
BugFix
Browse files Browse the repository at this point in the history
  • Loading branch information
helviojunior committed May 17, 2024
1 parent a3508fb commit 42f6146
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ RUN apt update \
wget \
gpg \
vim \
jq \
&& apt clean all \
&& apt autoremove

Expand Down Expand Up @@ -69,6 +70,7 @@ python3 /root/config_elk.py \n \
chown -R elasticsearch:elasticsearch /u01/ \n \
ln -s /u01/ /root/.filecrawler \n \
/etc/init.d/elasticsearch start \n \
curl -s 'http://localhost:9200/_cat/indices/.kib*?v=true&s=index' | grep -oE '\.kibana([^ ]+)' | xargs -I {} curl -s -XDELETE \"http://localhost:9200/{}\" \n \
/etc/init.d/kibana start \n \
/bin/bash \n \
/etc/init.d/elasticsearch stop \n \
Expand All @@ -89,6 +91,7 @@ ENV LS_HEAP_SIZE="125m"
ENV KBN_PATH_CONF=/opt/kibana/config/
ENV LOGSTASH_START=0
ENV MAX_MAP_COUNT=262144
ENV NODE_ENV="production"
ENTRYPOINT ["/root/start.sh"]

#https://phoenixnap.com/kb/elk-stack-docker
2 changes: 1 addition & 1 deletion filecrawler/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _add_flags_args(self, flags: _ArgumentGroup):
default=5,
metavar='[tasks]',
type=int,
help=Color.s('number of connects in parallel (per host, default: {G}16{W})'))
help=Color.s('number of connects in parallel (per host, default: {G}5{W})'))

flags.add_argument('--create-config',
action='store_true',
Expand Down
9 changes: 8 additions & 1 deletion filecrawler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,15 @@ def print_config():
def create_config():
sample_config = Configuration.get_config_sample()

class CustomDumper(yaml.Dumper):
def represent_data(self, data):
if isinstance(data, str) and data.isdigit():
return self.represent_scalar('tag:yaml.org,2002:str', data, style="'")

return super(CustomDumper, self).represent_data(data)

with open(Configuration.config_file, 'w') as f:
yaml.dump(sample_config, f, sort_keys=False, default_flow_style=False)
yaml.dump(sample_config, f, sort_keys=False, default_flow_style=False, Dumper=CustomDumper)

Logger.pl('{+} {W}Config file created at {O}%s{W}\n' % Configuration.config_file)

Expand Down
27 changes: 21 additions & 6 deletions scripts/config_elk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@

import yaml


class CustomDumper(yaml.Dumper):
def represent_data(self, data):
if isinstance(data, str) and data.isdigit():
return self.represent_scalar('tag:yaml.org,2002:str', data, style="'")

return super(CustomDumper, self).represent_data(data)


with open('/etc/elasticsearch/elasticsearch.yml', 'r') as f:
data = dict(yaml.load(f, Loader=yaml.FullLoader))
'''
network.host: 127.0.0.1
http.host: 127.0.0.1
network.host: localhost
http.host: localhost
http.port: 9200
'''
data.update({
'network.host': '0.0.0.0',
'network.publish_host': '127.0.0.1',
'network.host': 'localhost',
'network.publish_host': '0.0.0.0',
'http.host': '0.0.0.0',
'http.port': 9200,
'cluster.name': 'filecrawler',
Expand All @@ -25,15 +34,21 @@
})

with open('/etc/elasticsearch/elasticsearch.yml', 'w') as f:
yaml.dump(data, f, sort_keys=False, default_flow_style=False)
yaml.dump(data, f, sort_keys=False, default_flow_style=False, Dumper=CustomDumper)

with open('/opt/kibana/config/kibana.yml', 'r') as f:
kibana = dict(yaml.load(f, Loader=yaml.FullLoader))
kibana.update({
'server.host': '0.0.0.0',
'xpack.reporting.kibanaServer.hostname': 'localhost',
'server.maxPayload': 1048576,
'server.name': 'FileCrawler',
'elasticsearch.hosts': ["http://localhost:9200"],
'i18n.locale': 'en',
'server.port': 80,
})


with open('/opt/kibana/config/kibana.yml', 'w') as f:
yaml.dump(kibana, f, sort_keys=False, default_flow_style=False)
yaml.dump(kibana, f, sort_keys=False, default_flow_style=False, Dumper=CustomDumper)

0 comments on commit 42f6146

Please sign in to comment.