pyloggr.main.syslog_server¶
This module provides stuff to implement a the main syslog/RELP server with Tornado
-
class
ListOfClients
[source]¶ Bases:
object
Stores the current Syslog clients, sends notifications to observers, publishes the list of clients in Redis
-
class
MainSyslogServer
(rabbitmq_config, syslog_parameters, server_id)[source]¶ Bases:
pyloggr.syslog.server.BaseSyslogServer
Tornado syslog server
SyslogServer listens for syslog messages (RELP, RELP/TLS, TCP, TCP/TLS, Unix socket) and sends messages to RabbitMQ.
-
handle_data
(data, sockname, peername)[source]¶ Handle UDP syslog
Parameters: - data – data sent
- sockname – the server socket info
- peername – the client socket info
-
handle_stream
(stream, address)[source]¶ Called by tornado when we have a new client.
Parameters: - stream (IOStream) – IOStream for the new connection
- address (tuple) – tuple (client IP, client source port)
Note
Tornado coroutine
-
-
class
Notification
(dictionnary, routing_key)¶ Bases:
tuple
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__repr__
()¶ Return a nicely formatted representation string
-
_asdict
()¶ Return a new OrderedDict which maps field names to their values
-
_replace
(_self, **kwds)¶ Return a new Notification object replacing specified fields with new values
-
dictionnary
¶ Alias for field number 0
-
routing_key
¶ Alias for field number 1
-
-
class
Publicator
(syslog_servers_conf, rabbitmq_config)[source]¶ Bases:
object
Publicator manages the RabbitMQ connection and actually makes the publish calls.
Publicator runs in its own thread, and has its own IOLoop.
Parameters: - syslog_servers_conf – Syslog configuration (used to initialize packers)
- rabbitmq_config – RabbitMQ connection parameters
-
init_thread
()[source]¶ Publicator thread: start a new IOLoop, make it current, call _do_start as a callback
-
notify_observers
(d, routing_key='')[source]¶ Send a notification via RabbitMQ
Parameters: - d (dict) – dictionnary to send as a notification
- routing_key (str) – RabbitMQ routing key
-
publish_syslog_message
(protocol, server_port, client_host, bytes_event, client_id, relp_id=None)[source]¶ Ask publications to publish a syslog event to RabbitMQ. Can be called by any thread
Parameters: - protocol (str) – ‘tcp’ or ‘relp’
- server_port (int) – which syslog server port was used to transmit the event
- client_host (str) – client hostname that sent the event
- bytes_event (bytes) – the event as bytes
- client_id (str) – SyslogClientConnection client_id
- relp_id (int) – event RELP id
-
class
SyslogClientConnection
(stream, address, syslog_parameters)[source]¶ Bases:
pyloggr.syslog.server.BaseSyslogClientConnection
Encapsulates a connection with a syslog client
-
_process_event
(bytes_event, protocol, relp_event_id=None)[source]¶ _process_relp_event(bytes_event, relp_event_id) Process a TCP syslog or RELP event.
Parameters: - bytes_event – the event as bytes
- protocol – relp or tcp
- relp_event_id – event RELP ID, given by the RELP client
-
after_published_relp
(*args, **kwargs)[source]¶ Called after an event received by RELP has been published in RabbitMQ
Parameters: - status – True if the event was successfully sent
- event – the Event object
- relp_id – event RELP id
-
props
¶ Return a few properties for this client
Return type: dict
-
-
class
SyslogMessage
(protocol, server_port, client_host, bytes_event, client_id, relp_id, total_messages)¶ Bases:
tuple
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__repr__
()¶ Return a nicely formatted representation string
-
_asdict
()¶ Return a new OrderedDict which maps field names to their values
-
_replace
(_self, **kwds)¶ Return a new SyslogMessage object replacing specified fields with new values
-
bytes_event
¶ Alias for field number 3
-
client_host
¶ Alias for field number 2
-
client_id
¶ Alias for field number 4
-
protocol
¶ Alias for field number 0
-
relp_id
¶ Alias for field number 5
-
server_port
¶ Alias for field number 1
-
total_messages
¶ Alias for field number 6
-