Esempio n. 1
0
File: s8.py Progetto: bengosney/L8
    def work(self, entry):
        if self.watching(entry['domain']):
            self.data.add_entry(entry)

    def watching(self, domain):
        if 'all' in self.domains or (domain is None and 'none' in self.domains):
            return True
        return domain in [s.lower() for s in self.domains]


if __name__ == "__main__":
    domains = args.domains.split(' ')
    bcolors.print_colour("S8: Mysql Stasher\n", bcolors.OKGREEN, bcolors.UNDERLINE)
    bcolors.print_colour("Stashing: %s domain(s)\n" % ', '.join(domains), bcolors.OKGREEN)
    bcolors.print_colour("Press Ctrl-C to exit\n", bcolors.OKGREEN)
    try:
        data = Data(args)
        c = Processor(data, domains)
        s = Subscriber(args.subscription)
        s.work(c.work)
    except (KeyboardInterrupt, SystemExit, StopIteration):
        pass
    except ConnectionError as err:
        Data.invalid_connection(err, args)

"""
TODO
----
Need to be able to filter for event severity and/or event contents
"""
Esempio n. 2
0
File: a8.py Progetto: bengosney/L8
        if os.path.isfile(conf_path):
            self.read(conf_path)
        else:
            self.add_section('base')
            self.write(open(conf_path, 'w'))
            bcolors.print_colour("Writing default config to ~/.a8\n", bcolors.OKBLUE, bcolors.BOLD)

    def check_section(self, section):
        if not self.has_section(section):
            self.add_section(section)

    def get_host(self, section):
        if not self.has_section(section):
            self.add_section(section)
        return dict(self.items(section, True))


if __name__ == "__main__":
    from data.config import args as db_args

    bcolors.print_colour("A8: alerting tool\n", bcolors.OKGREEN, bcolors.UNDERLINE)
    bcolors.print_colour("Press Ctrl-C to exit\n", bcolors.OKGREEN, )

    try:
        data = Data(db_args)
        p = Processor(data)
        s = Subscriber()
        s.work(p.work)
    except (KeyboardInterrupt, SystemExit):
        pass