config ) #[(7, 0), (30, 1000)] # find files <7days&>1k or <30days&>1m aCount = len(sys.argv) if aCount == 2: last = sys.argv[-1].lower() if last.startswith("debug"): 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")
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() username = interactiveutils.promptWithDefault("splunk username", "admin") password = interactiveutils.promptPassWithDefault("splunk password", "changeme") auth = username + ":" + password if answer == ALL: for fname in sortedFiles: addFile(fname, auth) elif answer == SOME: for fname in sortedFiles: fileanswer = interactiveutils.askMultipleChoiceQuestion("Index " + str(fname) + " into Splunk?", [YES, NO, ABORT], NO) #TK ESD 3/11/08 if fileanswer == YES: addFile(fname, auth) elif fileanswer == ABORT: break except KeyboardInterrupt, e: print "\nExiting...\n"
collapseThreshold = 3 daysSizeKPairs = getDaysSizeKPairs(config) #[(7, 0), (30, 1000)] # find files <7days&>1k or <30days&>1m aCount = len(sys.argv) if aCount == 2: last = sys.argv[-1].lower() if last.startswith("debug"): 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)