/var/lib/pcp/testsuite/src/badpmda.c is in pcp-testsuite 4.0.1-1.
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 | /*
* Copyright (c) 1995-2001 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2004 Ken McDonell. All Rights Reserved.
*/
#include <pcp/pmapi.h>
#include <pcp/pmda.h>
static pmdaInterface dispatch;
int
main(int argc, char **argv)
{
int c;
int sts;
int errflag = 0;
int id = 0;
int port = -1;
char *sockname = NULL;
/* trim cmd name of leading directory components */
pmSetProgname(argv[0]);
while ((c = getopt(argc, argv, "c:p:s:?")) != EOF) {
switch (c) {
case 'c': /* case number */
id = atoi(optarg);
break;
case 's': /* socket name */
sockname = optarg;
break;
case 'p': /* port number */
port = atoi(optarg);
break;
case '?':
default:
errflag++;
break;
}
}
if (errflag) {
fprintf(stderr,
"Usage: %s [options]\n\
\n\
Options:\n\
-c number case number (default 0)\n\
-s name socket name\n\
-p number port number\n",
pmGetProgname());
exit(1);
}
switch (id) {
case 0:
fprintf(stderr, "--- case 0 pmdaConnect() ---\n");
pmdaConnect(&dispatch);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaConnect: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaConnect: OK\n");
break;
case 1:
fprintf(stderr, "--- case 1 pmdaExt alloc + pmdaConnect() ---\n");
dispatch.version.any.ext = (pmdaExt *)calloc(1, sizeof(pmdaExt));
pmdaConnect(&dispatch);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaConnect: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaConnect: OK\n");
break;
case 2:
fprintf(stderr, "--- case 2 pmdaDaemon() + pmdaInet + pmdaConnect() ---\n");
pmdaDaemon(&dispatch, PMDA_INTERFACE_LATEST, "badpmda", 123, NULL, NULL);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaDaemon: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaDaemon: OK\n");
dispatch.version.any.ext->e_io = pmdaInet;
dispatch.version.any.ext->e_port = port;
pmdaConnect(&dispatch);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaConnect: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaConnect: OK\n");
break;
case 3:
fprintf(stderr, "--- case 3 pmdaDaemon() + pmdaInet + pmdaConnect() + pmdaConnect() ---\n");
pmdaDaemon(&dispatch, PMDA_INTERFACE_LATEST, "badpmda", 123, NULL, NULL);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaDaemon: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaDaemon: OK\n");
dispatch.version.any.ext->e_io = pmdaUnix;
dispatch.version.any.ext->e_sockname = sockname;
pmdaConnect(&dispatch);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaConnect: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaConnect: OK\n");
pmdaConnect(&dispatch);
sts = dispatch.status;
if (sts < 0)
fprintf(stderr, "pmdaConnect: Error: %s\n", pmErrStr(sts));
else
fprintf(stderr, "pmdaConnect: OK\n");
break;
}
return 0;
}
|