summaryrefslogtreecommitdiff
path: root/qa/src/record-setarg.c
blob: d745d47911d10fa9d5f0f0a3ae82111d3352496e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * record-setarg - simulate pmRecord*() usage
 *
 * Copyright (c) 1995-2001 Silicon Graphics, Inc.  All Rights Reserved.
 */

#include <pcp/pmapi.h>
#include <pcp/impl.h>
#include <pcp/pmafm.h>

/*
 * Usage: record-setarg folio
 */

int
main(int argc, char **argv)
{
    pmRecordHost	*rhp;
    int			sts;
    FILE		*f;
    extern int		errno;
    char		buf[20];

    if (argc < 2) {
	printf("Usage: record-setarg folio\n");
	exit(1);
    }

    f = pmRecordSetup(argv[1], "record-setarg", 0);
    if (f == NULL) {
	printf("pmRecordSetup(\"%s\", ...): %s\n",
		argv[1], pmErrStr(-errno));
	exit(1);
    }

    sts = pmRecordAddHost("localhost", 1, &rhp);
    if (sts < 0) {
	printf("pmRecordAddHost: %s\n", pmErrStr(sts));
	exit(1);
    }
    fprintf(rhp->f_config, "log mandatory on default sample.bin [ \"bin-400\" \"bin-800\" ]\n");

    sts = pmRecordControl(NULL, PM_REC_SETARG, "-t");
    sprintf(buf, "%dsec", 1);
    sts += pmRecordControl(NULL, PM_REC_SETARG, buf);
    sprintf(buf, "-T%dsec", 10);
    sts += pmRecordControl(NULL, PM_REC_SETARG, buf);
    if (sts < 0) {
	printf("pmRecordControl(NULL, PM_REC_SETARG, NULL): %s\n",
		pmErrStr(sts));
	exit(1);
    }

    sts = pmRecordControl(NULL, PM_REC_ON, NULL);
    if (sts < 0) {
	printf("pmRecordControl(NULL, PM_REC_ON, NULL): %s\n",
		pmErrStr(sts));
	exit(1);
    }

    printf("\nsleeping ...\n\n");
    sleep(12);

    sts = pmRecordControl(rhp, PM_REC_OFF, NULL);
    if (sts < 0)
	printf("pmRecordControl(..., PM_REC_OFF, ...): %s\n", pmErrStr(sts));

    exit(0);
}