Ejemplo n.º 1
0
def stop_monitor():
    """
    Stops ElasticSearch, Logstash, and Kibana on localhost

    :return: True, if successfully stopped
    """
    es_profiler = elasticsearch.ElasticProfiler()
    ls_profiler = logstash.LogstashProfiler()
    kb_profiler = kibana.KibanaProfiler()
    es_process = elasticsearch.ElasticProcess()
    ls_process = logstash.LogstashProcess()
    kb_process = kibana.KibanaProcess()
    if not (es_profiler.is_installed or ls_profiler.is_installed
            or kb_profiler.is_installed):
        sys.stderr.write('[-] Could not start monitor. Is it installed?\n')
        sys.stderr.write('[-] dynamite install monitor\n')
        return False
    sys.stdout.write('[+] Stopping monitor processes.\n')
    if not es_process.stop(stdout=True):
        sys.stderr.write('[-] Could not stop monitor.elasticsearch.\n')
        return False
    elif not ls_process.stop(stdout=True):
        sys.stderr.write('[-] Could not stop monitor.logstash.\n')
        return False
    elif not kb_process.stop(stdout=True):
        sys.stderr.write('[-] Could not stop monitor.kibana.\n')
        return False
    return True
Ejemplo n.º 2
0
def status_monitor():
    """
    Retrieve the status of the monitor processes

    :return: A tuple where the first element is elasticsearch status (dict), second is logstash status (dict),
    and third is Kibana status.
    """
    es_profiler = elasticsearch.ElasticProfiler()
    ls_profiler = logstash.LogstashProfiler()
    kb_profiler = kibana.KibanaProfiler()
    es_process = elasticsearch.ElasticProcess()
    ls_process = logstash.LogstashProcess()
    kb_process = kibana.KibanaProcess()
    if not (es_profiler.is_installed or ls_profiler.is_installed
            or kb_profiler.is_installed):
        sys.stderr.write('[-] Could not start monitor. Is it installed?\n')
        sys.stderr.write('[-] dynamite install monitor\n')
        return False
    return es_process.status(), ls_process.status(), kb_process.status()
Ejemplo n.º 3
0
                 '\'dynamite status logstash\'.\n')
             sys.exit(0)
         elif not logstash.LogstashProfiler(stderr=False).is_installed:
             _not_installed('start', 'logstash')
             sys.exit(0)
         else:
             sys.stderr.write(
                 '[-] An error occurred while attempting to start LogStash.\n'
             )
             sys.exit(1)
     except Exception:
         _fatal_exception('start', 'logstash', args.debug)
 elif args.component == 'kibana':
     try:
         sys.stdout.write('[+] Starting Kibana\n')
         started = kibana.KibanaProcess().start(stdout=True)
         if started:
             sys.stdout.write(
                 '[+] Kibana started successfully. Check its status at any time with: '
                 '\'dynamite status kibana\'.\n')
             sys.exit(0)
         elif not kibana.KibanaProfiler(stderr=False).is_installed:
             _not_installed('start', 'kibana')
             sys.exit(0)
         else:
             sys.stderr.write(
                 '[-] An error occurred while attempting to start Kibana.\n'
             )
             sys.exit(1)
     except Exception:
         _fatal_exception('start', 'kibana', args.debug)