cfengine/core — pull request #46 by nyetsche (2012-04-18 21:09:55+00:00)
Title: add basic idea of a $sys.uptime (in secs) scalar

Proposal to add a '$sys.uptime' variable, measuring in seconds the uptime of the host. Available on Linux only ( with the current code - may be doable for other OSes as well ).

squashed commits:

commit f1f91a3fd924619c4c61685ae4923fc658343a13
Author: Matt Lesko
Date: Wed Apr 4 10:41:44 2012 -0400

add basic idea of a $sys.uptime (in secs) scalar

Create a system-level scalar variable, $sys.uptime, that is computed
from the sysinfo() call - on Linux, this returns a structure roughly the
equivalent of the 'uptime' command - other variables can be taken out as
well, but the seconds since boot ( uptime ) is most useful.

Possible use cases - set a class if the server in question has been up
for only a few minutes:

classes:
"RecentUptime" expression => islessthan("600", "${sys.uptime}")

NOTE: This was coded for Linux systems - the sysinfo command does not
appear to be very portable. Previous code in this function calls
function with a similar name, but available on Solaris ( and other
*BSDs? ).

Other UNIX systems will require a different setup, at present I do not
have the infrastructure to test/code for other systems.

commit 25ddecac6cc5ba4527f666d42923c5b82b68bbb9
Author: Matt Lesko
Date: Wed Apr 4 10:40:54 2012 -0400

added a check for the headers sys/sysinfo.h, which is what exists on linux