Package Products :: Package ZenRRD :: Package parsers :: Module uptime |
[hide private]
[frames] | no frames]

# Module uptime

source code

Classes | [hide private]
uptime

Functions | [hide private]
parseUptime(output) Parse the uptime command's output capturing the days, hours and minutes that the system has been up. | source code
asTimeticks(days=0, hours=0, minutes=0) | source code
parseSysUpTime(output) Parse the sysUpTime (measured in timeticks) from the output of the uptime command. | source code

Variables | [hide private]
| log = `logging.getLogger("zen.zencommand")`
| UPTIME_PATTERN = `re.compile(r"up +(?:(?P<days>\d+) day\(?s?\)?`...``
| UPTIME_FORMAT = `"uptime: days=%(days)s, hours=%(hours)s, minut`...``

Function Details | [hide private]

### parseUptime(output) | source code
Parse the uptime command's output capturing the days, hours and minutes that the system has been up. Returns a dictionary of the captured values.
    >>> UPTIME_FORMAT % parseUptime("up 12 day(s), 1:42")
    'uptime: days=12, hours=1, minutes=42'
    >>> UPTIME_FORMAT % parseUptime("up 1 day, 1:42")
    'uptime: days=1, hours=1, minutes=42'
    >>> UPTIME_FORMAT % parseUptime("up 5 days, 1:42")
    'uptime: days=5, hours=1, minutes=42'
    >>> UPTIME_FORMAT % parseUptime("up 3 days, 6 min")
    'uptime: days=3, hours=0, minutes=6'
    >>> UPTIME_FORMAT % parseUptime("up 1:14")
    'uptime: days=0, hours=1, minutes=14'
    >>> UPTIME_FORMAT % parseUptime("up 4 min")
    'uptime: days=0, hours=0, minutes=4'

Variables Details | [hide private]

  ### UPTIME_PATTERN Value:
      re.compile(r"up +(?:(?P<days>\d+) day\(?s?\)?, +)?(?:(?P<hours>\d+):)?
      (?P<minutes>\d+)")

  ### UPTIME_FORMAT Value:
      "uptime: days=%(days)s, hours=%(hours)s, minutes=%(minutes)s"