Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / libadmin / samples / rxdebug_supported_stats.c
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 *
9 * Portions Copyright (c) 2003 Apple Computer, Inc.
10 */
11
12 /*
13 * This file contains sample code for the rxstats interface
14 */
15
16 #include <afsconfig.h>
17 #include <afs/param.h>
18
19 #include <roken.h>
20
21 #ifdef AFS_NT40_ENV
22 #include <pthread.h>
23 #endif
24
25 #include <rx/rx.h>
26 #include <rx/rxstat.h>
27
28 #include <afs/afs_Admin.h>
29 #include <afs/afs_clientAdmin.h>
30 #include <afs/afs_utilAdmin.h>
31
32 void
33 Usage(void)
34 {
35 fprintf(stderr, "Usage: rxdebug_supported_stats <host> <port>\n");
36 exit(1);
37 }
38
39 void
40 ParseArgs(int argc, char *argv[], char **srvrName, long *srvrPort)
41 {
42 char **argp = argv;
43
44 if (!*(++argp))
45 Usage();
46 *srvrName = *(argp++);
47 if (!*(argp))
48 Usage();
49 *srvrPort = strtol(*(argp++), NULL, 0);
50 if (*srvrPort <= 0 || *srvrPort >= 65536)
51 Usage();
52 if (*(argp))
53 Usage();
54 }
55
56 int
57 main(int argc, char *argv[])
58 {
59 int rc;
60 afs_status_t st = 0;
61 rxdebugHandle_p handle;
62 char *srvrName;
63 long srvrPort;
64 afs_uint32 supported;
65
66 ParseArgs(argc, argv, &srvrName, &srvrPort);
67
68 rc = afsclient_Init(&st);
69 if (!rc) {
70 fprintf(stderr, "afsclient_Init, status %d\n", st);
71 exit(1);
72 }
73
74 rc = afsclient_RXDebugOpenPort(srvrName, srvrPort, &handle, &st);
75 if (!rc) {
76 fprintf(stderr, "afsclient_RXDebugOpenPort, status %d\n", st);
77 exit(1);
78 }
79
80 rc = util_RXDebugSupportedStats(handle, &supported, &st);
81 if (!rc) {
82 fprintf(stderr, "util_RXDebugSupportedStats, status %d\n", st);
83 exit(1);
84 }
85
86 rc = afsclient_RXDebugClose(handle, &st);
87 if (!rc) {
88 fprintf(stderr, "afsclient_RXDebugClose, status %d\n", st);
89 exit(1);
90 }
91
92 printf("\n");
93 printf("security stats: %s supported\n",
94 (supported & RX_SERVER_DEBUG_SEC_STATS) ? "" : " not");
95 printf("all connections:%s supported\n",
96 (supported & RX_SERVER_DEBUG_ALL_CONN) ? "" : " not");
97 printf("rx stats: %s supported\n",
98 (supported & RX_SERVER_DEBUG_RX_STATS) ? "" : " not");
99 printf("waiter count: %s supported\n",
100 (supported & RX_SERVER_DEBUG_WAITER_CNT) ? "" : " not");
101 printf("idle threads: %s supported\n",
102 (supported & RX_SERVER_DEBUG_IDLE_THREADS) ? "" : " not");
103 printf("all peers: %s supported\n",
104 (supported & RX_SERVER_DEBUG_ALL_PEER) ? "" : " not");
105 printf("\n");
106
107 exit(0);
108 }