Esempio n. 1
0
File: mysql.c Progetto: KnightKu/lmt
static int
_setup (void)
{
    err_init (MONITOR_NAME);
    err_set_dest ("cerebro");
    lmt_conf_init (0, NULL);
    return 0;
}
Esempio n. 2
0
File: tparse.c Progetto: LLNL/lmt
int
main (int argc, char *argv[])
{
    err_init (argv[0]);
    lmt_conf_init (1, NULL);

    lmt_conf_set_proto_debug (1);

    parse_utils ();
    parse_legacy ();
    parse_current ();
    parse_current_short ();
    parse_current_long ();
    exit (0);
}
Esempio n. 3
0
File: lmtmetric.c Progetto: LLNL/lmt
int
main (int argc, char *argv[])
{
    pctx_t ctx;
    char buf[CEREBRO_MAX_DATA_STRING_LEN];
    char *proc_root = "/proc";
    char *metric = NULL;
    unsigned long update_period = 0;
    int c, n = 0;

    err_init (argv[0]);
    lmt_conf_init (0, NULL);
    lmt_conf_set_proto_debug (1);

    optind = 0;
    opterr = 0;
    while ((c = GETOPT (argc, argv, OPTIONS, longopts)) != -1) {
        switch (c) {
        case 'm':   /* --metric NAME */
            metric = optarg;
            break;
        case 'r':   /* --proc-root DIR */
            proc_root = optarg;
            break;
        case 't':   /* --update-period SECS */
            update_period = strtoul (optarg, NULL, 10);
            break;
        default:
            usage ();
        }
    }
    if (optind < argc)
        usage();
    if (metric && strcmp (metric, "ost") && strcmp (metric, "mdt")
            && strcmp (metric, "osc") && strcmp (metric, "router")
            && strcmp (metric, "sysstat"))
        usage();
    if (!metric)
        metric = "sysstat";

    if (!(ctx = proc_create (proc_root)))
        err_exit ("proc_create");

    do {
        errno = 0;
        if (!strcmp (metric, "sysstat"))
            n = _sysstat (ctx, buf, sizeof (buf));
        else if (!strcmp (metric, "ost"))
            n = lmt_ost_string_v2 (ctx, buf, sizeof (buf));
        else if (!strcmp (metric, "mdt"))
            n = lmt_mdt_string_v2 (ctx, buf, sizeof (buf));
        else if (!strcmp (metric, "osc"))
            n = lmt_osc_string_v1 (ctx, buf, sizeof (buf));
        else if (!strcmp (metric, "router"))
            n = lmt_router_string_v1 (ctx, buf, sizeof (buf));
        if (n < 0 && errno == 0)
            msg ("%s metric information unavailable", metric);
        else if (n < 0)
            err ("%s metric", metric);
        else
            printf ("%s: %s\n", metric, buf);
        if (update_period > 0)
            sleep (update_period);
    } while (update_period > 0);

    proc_destroy (ctx);
    exit (0);
}