diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/src/check_import_name.c | |
download | pcp-debian.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/src/check_import_name.c')
-rw-r--r-- | qa/src/check_import_name.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/qa/src/check_import_name.c b/qa/src/check_import_name.c new file mode 100644 index 0000000..8efa3e8 --- /dev/null +++ b/qa/src/check_import_name.c @@ -0,0 +1,47 @@ +/* + * Exercise libpcp_import metric name validation. + * + * Copyright (c) 2013 Red Hat. + */ + +#include <pcp/pmapi.h> +#include <pcp/impl.h> +#include <pcp/import.h> + +static void +check(int sts, char *name) +{ + if (sts < 0) { + fprintf(stderr, "%s: Error: %s\n", name, pmiErrStr(sts)); + } else { + fprintf(stderr, "%s: OK", name); + if (sts != 0) + fprintf(stderr, " -> %d", sts); + fputc('\n', stderr); + } +} + +int +main(int argc, char **argv) +{ + int sts; + + if (argc != 2) { + printf("Usage: %s <name>\n", argv[0]); + exit(1); + } + + sts = pmiStart("tmplog", 0); + check(sts, "pmiStart"); + sts = pmiSetHostname("tmphost.com"); + check(sts, "pmiSetHostname"); + sts = pmiSetTimezone("GMT-12"); + check(sts, "pmiSetTimezone"); + + printf("Checking metric name: \"%s\" ...\n", argv[1]); + sts = pmiAddMetric(argv[1], pmid_build(245,0,1), + PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT, + pmiUnits(1,-1,0,PM_SPACE_MBYTE,PM_TIME_SEC,0)); + check(sts, "pmiAddMetric"); + exit(0); +} |