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

add uptime and loadavg files #62

Closed
wants to merge 1 commit into from
Closed

Conversation

tschuy
Copy link
Contributor

@tschuy tschuy commented Jan 26, 2017

Closes #60.

As far as I can tell, we don't currently collect the uptime. It's not a particularly expensive syscall to just grab /proc/uptime: https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/fs/proc/uptime.c

tschuy@tschuy:(mayday)(uptime) → cat test.c
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i;

    FILE * fp;
    for (i = 0; i < 1000000; i++) {
        fp=fopen("/proc/uptime", "r");
	fclose(fp);
    }
    return 0;
}
tschuy@tschuy:(mayday)(uptime) → time ./getuptime 

real	0m3.516s
user	0m0.257s
sys	0m3.250s

3.5 microseconds per read for uptime, and very similar timing for loadavg.

@tschuy tschuy closed this Feb 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some more commands to consider
1 participant