

.. _sphx_glr_auto_examples_monitoring_ligier_mirror.py:


=============
Ligier Mirror
=============

Subscribes to given tag(s) and sends them to another Ligier.




.. code-block:: python

    # Author: Tamas Gal <tgal@km3net.de>
    # License: MIT
    from __future__ import division

    import socket

    from km3pipe import Pipeline, Module
    from km3pipe.io import CHPump
    import controlhost as ch

    from km3pipe.logger import logging


    class LigierSender(Module):
        def configure(self):
            self.ligier = self.get("ligier") or "127.0.0.1"
            self.port = self.get("port") or 5553
            self.socket = socket.socket()
            self.client = self.socket.connect((self.ligier, self.port))

        def process(self, blob):
            self.socket.send(blob["CHPrefix"].data + blob["CHData"])

        def finish(self):
            self.socket.close()


    pipe = Pipeline()
    pipe.attach(CHPump, host='192.168.0.121',
                        port=5553,
                        tags='IO_EVT, IO_SUM, IO_TSL',
                        timeout=60*60*24*7,
                        max_queue=2000)
    pipe.attach(LigierSender)
    pipe.drain()

**Total running time of the script:** ( 0 minutes  0.000 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: ligier_mirror.py <ligier_mirror.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: ligier_mirror.ipynb <ligier_mirror.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
