Exemple #1
0
        def __init__(self, connection):
            self.module_name = "monitor"
            self.connection = connection
            self.timestamp = -1
            self.prefix_tree = None
            self.process_ids = []
            self.rules = None
            self.prefixes = set()
            self.prefix_file = "/root/monitor_prefixes.json"
            self.monitors = None
            self.flag = True
            self.redis = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
            ping_redis(self.redis)
            self.correlation_id = None

            # EXCHANGES
            self.config_exchange = create_exchange("config", connection)

            # QUEUES
            self.config_queue = create_queue(
                self.module_name,
                exchange=self.config_exchange,
                routing_key="notify",
                priority=2,
            )

            signal_loading(self.module_name, True)
            self.config_request_rpc()

            # setup Redis monitor listeners
            self.setup_redis_mon_listeners()

            log.info("started")
            signal_loading(self.module_name, False)
Exemple #2
0
        def __init__(self, connection):
            self.module_name = "autoignore"
            self.connection = connection
            self.prefix_tree = None
            self.autoignore_rules = None
            # https: // docs.celeryproject.org / projects / kombu / en / stable / reference / kombu.asynchronous.timer.html
            # https://docs.celeryproject.org/projects/kombu/en/stable/_modules/kombu/asynchronous/timer.html#Timer
            self.rule_timer_threads = {}
            self.timestamp = -1

            # DB variables
            self.ro_db = DB(
                application_name="autoignore-readonly",
                user=DB_USER,
                password=DB_PASS,
                host=DB_HOST,
                port=DB_PORT,
                database=DB_NAME,
                reconnect=True,
                autocommit=True,
                readonly=True,
            )
            self.wo_db = DB(
                application_name="autoignore-write",
                user=DB_USER,
                password=DB_PASS,
                host=DB_HOST,
                port=DB_PORT,
                database=DB_NAME,
            )

            # EXCHANGES
            self.config_exchange = create_exchange("config", connection)

            # QUEUES
            self.config_queue = create_queue(
                self.module_name,
                exchange=self.config_exchange,
                routing_key="notify",
                priority=3,
            )

            # redis db
            self.redis = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
            ping_redis(self.redis)

            signal_loading(self.module_name, True)
            self.config_request_rpc()
            signal_loading(self.module_name, False)
Exemple #3
0
    parser.add_argument(
        "-p",
        "--prefixes",
        type=str,
        dest="prefixes_file",
        default=None,
        help="Prefix(es) to be monitored (json file with prefix list)",
    )
    parser.add_argument(
        "-r",
        "--hosts",
        type=str,
        dest="hosts",
        default=None,
        help="Directory with csvs to read",
    )

    args = parser.parse_args()
    hosts = args.hosts
    if hosts:
        hosts = set(hosts.split(","))
    ping_redis(redis)

    try:
        with Connection(RABBITMQ_URI) as connection:
            parse_ripe_ris(connection, args.prefixes_file, hosts)
    except Exception:
        log.exception("exception")
    except KeyboardInterrupt:
        pass