.. _analytics_mc: ######### analytics ######### The Analytics MC provides FIREWHEEL experiments with tools for monitoring and collecting data on each VM during an experiment. By decorating a :py:class:`Vertex ` with the Analytics MC, that :py:class:`Vertex ` gains access to methods that will schedule different analytic capabilities to be executed at the start of an experiment (time == 1). After decorating your :py:class:`Vertex `, you will need to call the newly available methods depending on the kind of data which should be collected. ******************** Current capabilities ******************** All the methods are documented in :py:class:`analytics.Analytics`, but for ease of use we list a few of the more useful methods here. Some methods are Linux dependent (e.g. `strace `__) while others depend on `psutil `__. Linux dependent =============== * :py:meth:`analytics.Analytics.run_tcpdump` Runs `tcpdump `_ on the VM to capture any network traffic during the positive time of the experiment. **Default command:** ``tcpdump -U -w /opt/analytics/pcaps/tmp.pcap -Z root`` * :py:meth:`analytics.Analytics.add_port_tracking` Runs ``netstat -tulpn`` every ```` seconds and tracks the changes between each call. One of three possible headers will be outputted with each log: ``INITIAL``, ``ADDED``, or ``DELETED``. These headers are used to track the state of each line outputted by each `netstat `__ execution. * :py:meth:`analytics.Analytics.tailf_dir` Given a positive ( >= 1 ) time, a target directory, and a regex to match against, this method schedules a script that will execute a ``tail -f`` on any file created in the target directory that matches on the regex. This script was designed for use by the :py:meth:`strace ` method so that each new ``.strace`` file will be reported back to the VM Resource Management logs on the :ref:`cluster-compute-nodes` (see :ref:`vmr-output` more details). Each outputted line from the ``tail -f`` is wrapped in the format used by the :ref:`JSONLogger` (see the :ref:`utilities.python_mc`), so that it is also placed into the VM Resource ``.json`` logs. * :py:meth:`analytics.Analytics.strace` This script utilizes `pgrep `_ and a provided regular expression to determine the processes to attach `strace `__. The programmer could, instead of using this tool, schedule the `strace `__ with the original execution of the process they want to track, which would avoid the need to find and attach to the process after the fact. However, this tool was designed in order to avoid that exact scenario. **Default command:** ``strace -ff -tt -s 1024 -o /opt/analytics/traces/(no_tailf_dirs|tailf_dirs)/