Example #1
0
def manualListHosts():
    hosts = []
    if interactiveutils.askYesNoQuestion(
            "Would you like to manually enter additional remote host names?",
            False):
        interactiveutils.addListItems(
            "Please enter the names of remote hosts to search for log files.",
            "remote-host", hosts, isValidHost)
    return hosts
                print
                print "POTENTIAL LOG FILES"
                print "-"*80
                print "\t","TIME".rjust(20), "SIZE (K)".rjust(20), "SOURCETYPE".rjust(20), "\t", "NAME"
                print "-"*80
                for name in sortedFiles:
                    modtime, size, sourcetype = g_log_files[name]
                    if sourcetype == None or sourcetype == "too_small":
                        sourcetype = "unknown"
                    if size < 1024:
                        size = 1
                    else:
                        size /= 1024
                    print "\t", time.ctime(modtime).rjust(20), str(size).rjust(20), sourcetype.rjust(20), "\t", name

                if interactiveutils.askYesNoQuestion("Collapse files into common directories?"): # TK ESD 4/25/08
                    sortedFiles = recursivelyFindCommonDirectories(g_config, sortedFiles, int(g_config['COLLAPSE_THRESHOLD'][0]))
                    print
                    print "Collapsed files:"
                    print "-"*80
                    for fname in sortedFiles:
                        print "\t", fname
                    
                ALL = "all"; SOME = "some"; NOPE = "none"; YES = "yes"; NO = "no"; ABORT = "abort"
                answer = interactiveutils.askMultipleChoiceQuestion("Index found files into Splunk?", [ALL, SOME, NOPE], NOPE) #TK ESD 3/11/08
                auth = "admin:changeme"
                if answer != NOPE:
                    success = startSplunk()
                    if not success:
                        print "Unable to start splunkd.  Exiting..."  # TK ESD 3/11/08
                        sys.exit()
def manualListHosts():
    hosts = []
    if interactiveutils.askYesNoQuestion("Would you like to manually enter additional remote host names?", False):
        interactiveutils.addListItems("Please enter the names of remote hosts to search for log files.", "remote-host", hosts, isValidHost)
    return hosts
Example #4
0
                print "\n\tUsage:", sys.argv[0], "[debug|quiet]\n"
                sys.exit()

        user = interactiveutils.promptWithDefault("username", "root")
        dir = interactiveutils.promptWithDefault("starting directory", "/")
        manyhosts = interactiveutils.askMultipleChoiceQuestion(
            "Run on more than one host? (default=no)", ['no', 'yes'], 'no')
        copyfiles = 'yes' == interactiveutils.askMultipleChoiceQuestion(
            "Do you want to retrieve the files found for further inspection?",
            ['yes', 'no'], 'yes')

        if manyhosts == 'yes':
            hosts = getHosts(config)
            password = None
            if interactiveutils.askYesNoQuestion(
                    "Do you want to automatically use a common password for all hosts?",
                    False):
                password = getPassword("Enter remote password")

            crawlerThreads = []
            for host in hosts:
                crawler = Crawler(config, user, password, host, [dir],
                                  daysSizeKPairs, collapseThreshold, copyfiles)
                crawlerThreads.append(crawler)
                try:
                    crawler.start()
                except Exception, e:
                    print "\nError. Skipping", host, "...", e, "\n"

            noresultshosts = []
            for crawler in crawlerThreads:
                g_debug = True
           elif last.startswith("quiet"):
                g_quiet = True
           else:
                print "\n\tUsage:", sys.argv[0], "[debug|quiet]\n"
                sys.exit()
           
      user = interactiveutils.promptWithDefault("username", "root")
      dir = interactiveutils.promptWithDefault("starting directory", "/")
      manyhosts = interactiveutils.askMultipleChoiceQuestion("Run on more than one host? (default=no)", ['no', 'yes'], 'no')
      copyfiles = 'yes' == interactiveutils.askMultipleChoiceQuestion("Do you want to retrieve the files found for further inspection?", ['yes', 'no'], 'yes')
      
      if manyhosts == 'yes':
            hosts = getHosts(config)
            password = None
            if interactiveutils.askYesNoQuestion("Do you want to automatically use a common password for all hosts?", False):
                 password = getPassword("Enter remote password")
 
 
            crawlerThreads = []
            for host in hosts:
                 crawler = Crawler(config, user, password, host, [dir], daysSizeKPairs, collapseThreshold, copyfiles)
                 crawlerThreads.append(crawler)
                 try:
                      crawler.start()
                 except Exception, e:
                      print "\nError. Skipping", host, "...", e, "\n"
 
            noresultshosts = []
            for crawler in crawlerThreads:
                 crawler.join()