view probes/tests/cpuacct.c @ 3:2cb8a6cbe468

cpuacct: convert per cpu usage from nanoseconds to jiffies
author Louis Opter <louis@dotcloud.com>
date Fri, 31 Dec 2010 20:04:25 +0100
parents 6ce4443e7545
children
line wrap: on
line source

#include <sys/types.h>

#include <err.h>
#include <stdlib.h>
#include <stdio.h>

#include "lxcstats.h"
#include "_lxcstats.h"
#include "probes/probes.h"

int
main(void)
{
    lxcst_handle    *hdl;
    struct lxcst    *c;
    int             i;

    hdl = lxcst_open();
    if (!hdl)
        err(EXIT_FAILURE, "lxcst_open failed");

    c = _lxcst_container_new(hdl, ".");
    if (!c)
        err(EXIT_FAILURE, "cant create container");

    if (_lxcst_probe_cpuacct(c))
        err(EXIT_FAILURE, "probe cpuacct failed");

    printf("user %d\nsystem %d\n", c->cpuacct.user, c->cpuacct.system);
    for (i = 0; c->cpuacct.percpu[i]; ++i)
        printf("cpu[%d] %u\n", i, c->cpuacct.percpu[i]);

    _lxcst_container_delete(c);

    lxcst_close(hdl);

    return (EXIT_SUCCESS);
}