Beispiel #1
0
    def initApp(self, opt = None):

        if opt and opt.interval:
            LOGGER.info('Custom interval is set ' + opt.interval)
            self.interval = int(opt.interval)
        else:
            self.interval = 60 # in sec

        # apacheLogFilePath
        if opt and opt.apacheLogFilePath:
            LOGGER.info('Custom apache log file is set ' + opt.apacheLogFilePath)
            files = opt.apacheLogFilePath.split(',')
            self.apacheLogFilePath = files
        else:
            self.apacheLogFilePath = ['/var/log/apache2/access.log']

        if opt and opt.outputFilePath:
            self.outputFilePath = opt.outputFilePath
        else:
            scriptPath = os.path.realpath(__file__)
            pathname = os.path.dirname(scriptPath)
            self.outputFilePath = pathname + '/af_apache_visited_urls.log'

        if opt and opt.tags:
            self.tagsEnabled = opt.tags


        self.parser = ApacheLogsParser(apacheLogFilePath = self.apacheLogFilePath)
        self.urlsCounter = UrlsCounter(self.outputFilePath, tags = self.tagsEnabled)
Beispiel #2
0
    def initApp(self, opt=None):

        if opt and opt.interval:
            LOGGER.info('Custom interval is set ' + opt.interval)
            self.interval = int(opt.interval)
        else:
            self.interval = 60  # in sec

        # apacheLogFilePath
        if opt and opt.apacheLogFilePath:
            LOGGER.info('Custom apache log file is set ' +
                        opt.apacheLogFilePath)
            files = opt.apacheLogFilePath.split(',')
            self.apacheLogFilePath = files
        else:
            self.apacheLogFilePath = ['/var/log/apache2/access.log']

        if opt and opt.outputFilePath:
            LOGGER.info('Custom output file is set ' + opt.outputFilePath)
            self.outputFilePath = opt.outputFilePath
        else:
            scriptPath = os.path.realpath(__file__)
            pathname = os.path.dirname(scriptPath)
            self.outputFilePath = pathname + '/af_apache_visited_urls.log'

        if opt and opt.tags:
            self.tagsEnabled = opt.tags

        #
        try:
            self.parser = ApacheLogsParser(
                apacheLogFilePath=self.apacheLogFilePath)
            self.urlsCounter = UrlsCounter(self.outputFilePath,
                                           tags=self.tagsEnabled,
                                           statsdPrefix='apache_url_counter')
        except Exception as e:
            LOGGER.critical('Serious Error occured: %s', e)