Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fleetctl: service uptime for list-units #1669

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dongsupark
Copy link
Contributor

@dongsupark dongsupark commented Aug 23, 2016

Allow fleetctl list-units to retrieve per-unit uptime from systemd, for example:

localhost # ./fleet/fleetctl list-units
UNIT MACHINE ACTIVE SUB UPTIME
world.service 06ecd4f7.../192.168.122.30 active running 2015-07-06 07:38:38 AM UTC, Since 11m39s
world2.service 1d3430ef.../192.168.122.31 active running 2015-07-06 07:48:24 AM UTC, Since 1m54s
world_glob.service 06ecd4f7.../192.168.122.30 active running 2015-07-06 07:48:00 AM UTC, Since 2m18s
world_glob.service 1d3430ef.../192.168.122.31 active running 2015-07-06 07:47:59 AM UTC, Since 2m18s

What's changed since #1293:

  • Avoided unnecessary iteration for each unit when fetching systemd properties. Instead make use of setting internal UnitState, both for the normal loop for systemd (>= 230) and for the fallback loop for systemd (<= 229).
  • Fixed typos and bugs in registry and schema
  • Excluded ActiveEnterTimestamp from unit comparison condition.
  • Added timezone e.g. UTC to the output

Fixes #1128
Supersedes #1293
/cc @wuqixuan

@jonboulle
Copy link
Contributor

I'm not sure about this one - please hold off until I can give it a little more thought

@dongsupark
Copy link
Contributor Author

@jonboulle I see.

@dongsupark dongsupark force-pushed the master branch 2 times, most recently from bdc94e8 to fa5aa3a Compare August 30, 2016 12:26
@dongsupark dongsupark force-pushed the master branch 3 times, most recently from 20a3e96 to 3aaa1ab Compare November 10, 2016 15:24
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from eb6872f to 365565e Compare November 24, 2016 15:35
@dongsupark dongsupark force-pushed the master branch 6 times, most recently from 39a99ba to 44591b0 Compare December 15, 2016 19:48
wuqixuan and others added 2 commits December 16, 2016 12:56
We can get the uptime from systemctl, the resolve is like below:
localhost # /home/wood/fleet/fleetctl list-units
UNIT                    MACHINE                         ACTIVE  SUB     UPTIME
world.service           06ecd4f7.../192.168.122.30      active  running 2015-07-06 07:38:38 AM, Since 11m39s
world2.service          1d3430ef.../192.168.122.31      active  running 2015-07-06 07:48:24 AM, Since 1m54s
world_glob.service      06ecd4f7.../192.168.122.30      active  running 2015-07-06 07:48:00 AM, Since 2m18s
world_glob.service      1d3430ef.../192.168.122.31      active  running 2015-07-06 07:47:59 AM, Since 2m18s
To avoid an additional iteration of unit states for each unit, set
UnitState.ActiveEnterTimestamp accordingly, by calling
m.systemd.GetUnitProperty(). Note that we need to retrieve the property
not only in the normal loop for the current systemd (>=230), but also
in the fallback handling for the older version of systemd (<=229).
@dongsupark dongsupark force-pushed the dongsu/fleetctl-list-units-uptime branch from 7a8a336 to 63a3b28 Compare December 16, 2016 13:47
Dongsu Park added 2 commits December 16, 2016 15:20
* fix typo in registry/unit_state*.go, from ActiveEnterTimestamp to
  activeEnterTimestamp.
* Add a new field systemdActiveEnterTimestamp to both v1-json.go and
  v1.json.
Actually it's not necessary to check that both units have the same value
for ActiveEnterTimestamp, as it can vary at any time. So let's exclude
ActiveEnterTimestamp from the condition for unit comparison.
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from 0132632 to 6974811 Compare February 8, 2017 10:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants