0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <memory.h>
0038 #include <sys/param.h>
0039
0040 #include <ndrstandard.h>
0041 #include <ndebug.h>
0042 #include <nstdutil.h>
0043
0044 #include <ndrx.h>
0045 #include <ndrxdcmn.h>
0046 #include <atmi_int.h>
0047 #include <gencall.h>
0048 #include <nclopt.h>
0049
0050 #include "nstopwatch.h"
0051
0052
0053
0054
0055
0056
0057 exprivate int M_resources;
0058
0059
0060
0061
0062
0063
0064
0065
0066 exprivate void print_hdr(void)
0067 {
0068 fprintf(stderr, " SLOT SERVICE NAME NSRV FLAGS CSRVS TCLST CMAX CNODES\n");
0069 fprintf(stderr, "------ ------------ ---- ----- ----- ----- ---- --------------------------------\n");
0070 }
0071
0072
0073
0074
0075
0076
0077 exprivate char *gen_clstr_map(command_reply_shm_psvc_t * reply)
0078 {
0079 static char map[CONF_NDRX_NODEID_COUNT+1];
0080 char tmp[6];
0081 int i;
0082 map[0] = EXEOS;
0083
0084 for (i=0; i<CONF_NDRX_NODEID_COUNT; i++)
0085 {
0086 if (reply->cnodes[i].srvs < 10)
0087 {
0088 snprintf(tmp, sizeof(tmp), "%d", reply->cnodes[i].srvs);
0089 }
0090 else
0091 {
0092 NDRX_STRCPY_SAFE(tmp, "+");
0093 }
0094 strcat(map, tmp);
0095 }
0096
0097 return map;
0098 }
0099
0100
0101
0102
0103
0104
0105
0106 expublic int shm_psvc_rsp_process(command_reply_t *reply, size_t reply_len)
0107 {
0108 int i;
0109 char svc[12+1];
0110
0111 if (NDRXD_CALL_TYPE_PM_SHM_PSVC==reply->msg_type)
0112 {
0113 command_reply_shm_psvc_t * shm_psvc_info = (command_reply_shm_psvc_t*)reply;
0114
0115 FIX_SVC_NM(shm_psvc_info->service, svc, (sizeof(svc)-1));
0116
0117 fprintf(stdout, "%6d %-12.12s %4.4s %5d %5d %5d %4d %-*.*s\n",
0118 shm_psvc_info->slot,
0119 svc,
0120 ndrx_decode_num(shm_psvc_info->srvs, 0, 0, 1),
0121 shm_psvc_info->flags,
0122 shm_psvc_info->csrvs, shm_psvc_info->totclustered,
0123 shm_psvc_info->cnodes_max_id,
0124 CONF_NDRX_NODEID_COUNT,
0125 CONF_NDRX_NODEID_COUNT, gen_clstr_map(shm_psvc_info));
0126
0127
0128
0129
0130 if (M_resources && shm_psvc_info->resids[0].resid)
0131 {
0132 fprintf(stderr, "\t\n");
0133 fprintf(stderr, "\tRES NO IDENTIFIER SERVERS\n");
0134 fprintf(stderr, "\t------ ---------- -------\n");
0135 for (i=0; i<shm_psvc_info->resnr; i++)
0136 {
0137 fprintf(stdout, "\t%6d %10d %7hd\n",
0138 i, shm_psvc_info->resids[i].resid,
0139 shm_psvc_info->resids[i].cnt);
0140 }
0141 fprintf(stderr, "\t\n");
0142
0143
0144 print_hdr();
0145 }
0146 }
0147
0148 return EXSUCCEED;
0149 }
0150
0151
0152
0153
0154
0155
0156
0157
0158 expublic int cmd_shm_psvc(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0159 {
0160 int ret = EXSUCCEED;
0161 command_call_t call;
0162
0163 ncloptmap_t clopt[] =
0164 {
0165 {'r', BFLD_INT, (void *)&M_resources, sizeof(M_resources),
0166 NCLOPT_OPT, "Print resources"},
0167 {0}
0168 };
0169
0170 M_resources = EXFALSE;
0171
0172
0173 if (nstd_parse_clopt(clopt, EXTRUE, argc, argv, EXFALSE))
0174 {
0175 fprintf(stderr, XADMIN_INVALID_OPTIONS_MSG);
0176 EXFAIL_OUT(ret);
0177 }
0178
0179 memset(&call, 0, sizeof(call));
0180
0181
0182 print_hdr();
0183
0184 ret=cmd_generic_listcall(p_cmd_map->ndrxd_cmd, NDRXD_SRC_ADMIN,
0185 NDRXD_CALL_TYPE_GENERIC,
0186 &call, sizeof(call),
0187 G_config.reply_queue_str,
0188 G_config.reply_queue,
0189 G_config.ndrxd_q,
0190 G_config.ndrxd_q_str,
0191 argc, argv,
0192 p_have_next,
0193 G_call_args,
0194 EXFALSE,
0195 G_config.listcall_flags);
0196 out:
0197 return ret;
0198 }
0199
0200