/var/lib/pcp/testsuite/src/pmnsunload.c is in pcp-testsuite 3.8.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /*
* Copyright (c) 1997-2001 Silicon Graphics, Inc. All Rights Reserved.
*/
/*
* check open/close archive for mem leaks
*/
#include <pcp/pmapi.h>
#include <pcp/impl.h>
#include "localconfig.h"
static int vflag;
static int tflag;
void
do_PMNS_op(char *msg)
{
int sts;
char *name = "pmcd.control.debug";
pmID pmid;
printf("---%s---\n", msg);
printf("PMNS location = %d\n", pmGetPMNSLocation());
if ((sts = pmLookupName(1, &name, &pmid)) < 0) {
fprintf(stderr, "%s: lookup failed: %s\n", pmProgname, pmErrStr(sts));
exit(1);
}
}
int
main(int argc, char **argv)
{
int c;
int sts;
int errflag = 0;
char *archive = "foo";
char *host = "localhost";
char *namespace = PM_NS_DEFAULT;
static char *usage = "[-D N] [-L] [-h host] [-a archive] [-n namespace] [-v] [-i iterations]";
int niter=100;
int i;
int contype = PM_CONTEXT_HOST;
__pmSetProgname(argv[0]);
while ((c = getopt(argc, argv, "Li:h:a:D:n:tv")) != EOF) {
switch (c) {
case 'i': /* iterations */
niter = atoi(optarg);
break;
case 'L': /* local */
contype = PM_CONTEXT_LOCAL;
break;
case 'h': /* host */
host = optarg;
contype = PM_CONTEXT_HOST;
break;
case 'a': /* archive */
archive = optarg;
contype = PM_CONTEXT_ARCHIVE;
break;
case 'D': /* debug flag */
sts = __pmParseDebug(optarg);
if (sts < 0) {
fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n",
pmProgname, optarg);
errflag++;
}
else
pmDebug |= sts;
break;
case 'n': /* alternative name space file */
namespace = optarg;
break;
case 'v': /* verbose output */
vflag++;
break;
case 't': /* trim namespace */
tflag++;
break;
case '?':
default:
errflag++;
break;
}
}
if (errflag) {
printf("Usage: %s %s\n", pmProgname, usage);
exit(1);
}
switch (contype) {
case PM_CONTEXT_LOCAL:
if ((sts = pmNewContext(PM_CONTEXT_LOCAL, NULL)) < 0) {
printf("%s: Cannot create local context: %s\n", pmProgname, pmErrStr(sts));
exit(1);
}
break;
case PM_CONTEXT_ARCHIVE:
if ((sts = pmNewContext(PM_CONTEXT_ARCHIVE, archive)) < 0) {
printf("%s: Cannot connect to archive \"%s\": %s\n", pmProgname, archive, pmErrStr(sts));
exit(1);
}
break;
case PM_CONTEXT_HOST:
if ((sts = pmNewContext(PM_CONTEXT_HOST, host)) < 0) {
printf("%s: Cannot connect to host \"%s\": %s\n", pmProgname, host, pmErrStr(sts));
exit(1);
}
break;
}
for (i=0; i < niter; i++) {
printf("***iteration %d***\n", i);
do_PMNS_op("pre-unload");
pmUnloadNameSpace();
do_PMNS_op("post-unload");
if ((sts = pmLoadNameSpace(namespace)) < 0) {
printf("%s: Cannot load namespace from \"%s\": %s\n", pmProgname, namespace, pmErrStr(sts));
exit(1);
}
do_PMNS_op("post-load");
}
pmUnloadNameSpace();
(void)pmDestroyContext(pmWhichContext());
#if PCP_VER >= 3611
__pmShutdown();
#endif
exit(0);
}
|