Source code for insights.combiners.uptime


Combiner for uptime information. It uses the results of the ``Uptime``
parser to get the uptime information.  ``Uptime`` is
the preferred source of data.

    >>> ut = shared[uptime]
    >>> ut.updays
    >>> ht.uptime

from __future__ import division
from collections import namedtuple
from insights import SkipComponent
from insights.core.plugins import combiner
from insights.parsers.uptime import Uptime as upt
from insights.util import deprecated

Uptime = namedtuple("Uptime",
                        "currtime", "updays", "uphhmm",
                        "users", "loadavg", "uptime"])
"""namedtuple: Type for storing the uptime information."""

[docs]@combiner(upt) def uptime(ut): """ .. warning:: This combiner method is deprecated, please use :py:class:`insights.parsers.uptime.Uptime` instead. Check uptime to get the uptime information. Returns: insights.combiners.uptime.Uptime: A named tuple with `currtime`, `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components. Raises: SkipComponent: If no data is available or if ``loadavg`` is not available. """ deprecated(uptime, "Use the `Uptime` parser instead.") if ut.loadavg: return Uptime(ut.currtime, ut.updays, ut.uphhmm, ut.users, ut.loadavg, ut.uptime) raise SkipComponent("Unable to get uptime information.")