コード例 #1
0
ファイル: monitor.py プロジェクト: sucof/dynamite-nsm
def uninstall_monitor(prompt_user=True):
    """
    Uninstall standalone monitor components (ElasticSearch, Logstash, and Kibana)

    :return: True, if uninstall successful
    """
    es_profiler = elasticsearch.ElasticProfiler()
    ls_profiler = logstash.LogstashProfiler()
    kb_profiler = kibana.KibanaProfiler()
    if not (es_profiler.is_installed and ls_profiler.is_installed
            and kb_profiler.is_installed):
        sys.stderr.write(
            '[-] A standalone monitor installation was not detected on this system. Please uninstall '
            'ElasticSearch, Logstash, or Kibana individually.\n')
        return False
    if prompt_user:
        sys.stderr.write(
            '[-] WARNING! UNINSTALLING THE MONITOR WILL PREVENT EVENTS FROM BEING PROCESSED/VISUALIZED.\n'
        )
        resp = utilities.prompt_input(
            'Are you sure you wish to continue? ([no]|yes): ')
        while resp not in ['', 'no', 'yes']:
            resp = utilities.prompt_input(
                'Are you sure you wish to continue? ([no]|yes): ')
        if resp != 'yes':
            sys.stdout.write('[+] Exiting\n')
            return False
    es_uninstall = elasticsearch.uninstall_elasticsearch(stdout=True,
                                                         prompt_user=False)
    ls_uninstall = logstash.uninstall_logstash(stdout=True, prompt_user=False)
    kb_uninstall = kibana.uninstall_kibana(stdout=True, prompt_user=False)
    res = es_uninstall and ls_uninstall and kb_uninstall
    if res:
        sys.stdout.write('[+] Monitor uninstalled successfully.\n')
    else:
        sys.stderr.write(
            '[-] An error occurred while uninstalling one or more monitor components.\n'
        )
    return res
コード例 #2
0
 elif args.command == 'uninstall':
     if args.component == 'elasticsearch':
         if elasticsearch.uninstall_elasticsearch(stdout=True,
                                                  prompt_user=True):
             sys.exit(0)
         else:
             sys.stderr.write('[-] Failed to uninstall ElasticSearch.\n')
             sys.exit(1)
     elif args.component == 'logstash':
         if logstash.uninstall_logstash(stdout=True, prompt_user=True):
             sys.exit(0)
         else:
             sys.stderr.write('[-] Failed to uninstall LogStash.\n')
             sys.exit(1)
     elif args.component == 'kibana':
         if kibana.uninstall_kibana(stdout=True, prompt_user=True):
             sys.exit(0)
         else:
             sys.stderr.write('[-] Failed to uninstall Kibana.\n')
             sys.exit(1)
     elif args.component == 'monitor':
         if monitor.uninstall_monitor(prompt_user=True):
             sys.exit(0)
         else:
             sys.stderr.write('[-] Failed to uninstall Monitor.\n')
             sys.exit(1)
     elif args.component == 'agent':
         if agent.uninstall_agent(prompt_user=True):
             sys.exit(0)
         else:
             sys.stderr.write('[-] Failed to uninstall Agent.\n')