Skip to content

Commit 710def9

Browse files
committed
Adapt services (telefraf, eewids-parser) to newer versions
1 parent d9d7b39 commit 710def9

File tree

2 files changed

+209
-98
lines changed

2 files changed

+209
-98
lines changed

eewids-parser/eewids-parser.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This file is part of EEWIDS (Easily Expandable WIDS)
55
66
Copyright (C) 2018 Alexander Paetzelt <techge+eewids posteo net>
7+
Copyright (C) 2020 Alexander Paetzelt <techge+eewids posteo net>
78
89
This program is free software: you can redistribute it and/or modify
910
it under the terms of the GNU General Public License as published by
@@ -24,7 +25,6 @@
2425
import argparse
2526
import json
2627
import pika
27-
import requests
2828

2929
import parser as p
3030

@@ -66,20 +66,22 @@ def main(rab_host, rab_port):
6666

6767
# create queue for receiving raw capture data
6868
# TODO you probably do not want a random queue, but one which is used by multiple workers!!!
69-
recv_channel.queue_declare(queue='eewids-parser', exclusive=False)
69+
result = recv_channel.queue_declare(queue='eewids-parser', exclusive=False)
70+
queue_name = result.method.queue
7071
#recv_queue = recv_channel.queue.declare(exclusive=True)
7172
# TODO change routing key on capture tool and here, make it meaningful and global/as argument
72-
recv_channel.queue_bind(exchange='capture-raw', queue='eewids-parser', routing_key='*.*.*')
73+
# FIXME do not abort if it does not exist
74+
recv_channel.queue_bind(exchange='capture-raw', queue=queue_name, routing_key='*')
7375

7476
def callback(ch, method, properties, body):
7577

7678
parsed_data = p.packet_parse(body)
7779
distribute(parsed_data, send_channel)
7880

7981
# TODO look up right arguments to make sure that this is dividable through multiple workers!
80-
recv_channel.basic_consume(callback,
81-
queue='eewids-parser',
82-
no_ack=False)
82+
recv_channel.basic_consume(on_message_callback=callback,
83+
queue=queue_name,
84+
auto_ack=True)
8385

8486
print(' [*] Starting parsing. To exit press CTRL+C')
8587
recv_channel.start_consuming()

0 commit comments

Comments
 (0)