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
0043 #include <ndrx.h>
0044 #include <ndrxdcmn.h>
0045 #include <atmi_int.h>
0046 #include <gencall.h>
0047 #include <errno.h>
0048 #include <lcf.h>
0049 #include <linenoise.h>
0050
0051 #include "nclopt.h"
0052
0053 #include <exhash.h>
0054 #include <utlist.h>
0055 #include <userlog.h>
0056 #include <singlegrp.h>
0057 #include <lcfint.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 exprivate char *decode_flags(unsigned short flags)
0071 {
0072 static char buf[10];
0073
0074 buf[0] = EXEOS;
0075
0076 if (flags & NDRX_SG_NO_ORDER)
0077 {
0078 strcat(buf, "n");
0079 }
0080
0081
0082 if (flags & NDRX_SG_SINGLETON)
0083 {
0084 strcat(buf, "i");
0085 }
0086
0087 if (flags & NDRX_SG_VERIFY)
0088 {
0089 strcat(buf, "v");
0090 }
0091
0092 return buf;
0093 }
0094
0095
0096
0097
0098
0099
0100
0101
0102 expublic int cmd_psg(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0103 {
0104 int ret = EXSUCCEED;
0105 int i;
0106 struct timespec ts;
0107 long long refresh;
0108 int print_all = EXFALSE;
0109 int print_page_2 = EXFALSE;
0110
0111 ncloptmap_t clopt[] =
0112 {
0113 {'a', BFLD_INT, (void *)&print_all, 0,
0114 NCLOPT_OPT|NCLOPT_TRUEBOOL, "Print all groups"},
0115 {'2', BFLD_INT, (void *)&print_page_2, 0,
0116 NCLOPT_OPT|NCLOPT_TRUEBOOL, "Print page 2 (nodes)"},
0117 {0}
0118 };
0119
0120
0121 if (nstd_parse_clopt(clopt, EXTRUE, argc, argv, EXFALSE))
0122 {
0123 fprintf(stderr, XADMIN_INVALID_OPTIONS_MSG);
0124 EXFAIL_OUT(ret);
0125 }
0126
0127 if (print_page_2)
0128 {
0129
0130 fprintf(stderr, "SGID CNODES SEQUENCE\n");
0131 fprintf(stderr, "---- -------------------------------- ----------\n");
0132 }
0133 else
0134 {
0135
0136 fprintf(stderr, "SGID LCKD MMON SBOOT CBOOT LPSRVID LPPID LPPROCNM REFRESH RSN FLAGS\n");
0137 fprintf(stderr, "---- ---- ---- ----- ----- ------- -------- ---------------- -------- --- -----\n");
0138 }
0139
0140
0141 for (i=1; i<=ndrx_G_libnstd_cfg.pgmax; i++)
0142 {
0143 ndrx_sg_shm_t *p_shm=ndrx_sg_get(i);
0144 ndrx_sg_shm_t local;
0145 ndrx_sg_load(&local, p_shm);
0146
0147
0148
0149
0150 if (!( local.is_locked || (local.flags & NDRX_SG_SINGLETON)) && !print_all )
0151 {
0152 continue;
0153 }
0154
0155 if (local.is_locked)
0156 {
0157 ndrx_realtime_get(&ts);
0158 refresh = ((long long)ts.tv_sec-(long long)local.last_refresh)*1000;
0159 }
0160 else
0161 {
0162 refresh=-1;
0163 }
0164
0165 if (print_page_2)
0166 {
0167 char node_buf[CONF_NDRX_NODEID_COUNT+1];
0168 int j;
0169 char *p;
0170 memset(node_buf, '0', sizeof(node_buf));
0171 node_buf[CONF_NDRX_NODEID_COUNT] = EXEOS;
0172
0173 for (j=0; j<CONF_NDRX_NODEID_COUNT; j++)
0174 {
0175 if (local.sg_nodes[j])
0176 {
0177
0178 node_buf[local.sg_nodes[j]-1] = 'Y';
0179 }
0180 else
0181 {
0182
0183 break;
0184 }
0185 }
0186
0187 fprintf(stdout, "%4d %s %10ld\n",
0188 i, node_buf, local.sequence);
0189 }
0190 else
0191 {
0192 fprintf(stdout, "%4d %-4.4s %-4.4s %-5.5s %-5.5s %7d %8d %-16.16s %8.8s %3d %-5.5s\n",
0193 i,
0194 local.is_locked?"Y":"N",
0195 local.is_mmon?"Y":"N",
0196 local.is_srv_booted?"Y":"N",
0197 local.is_clt_booted?"Y":"N",
0198 local.lockprov_srvid,
0199 (int)local.lockprov_pid,
0200 local.lockprov_procname,
0201 ndrx_decode_msec((long)refresh, 0, 0, 2),
0202 local.reason,
0203 decode_flags(local.flags)
0204 );
0205 }
0206 }
0207
0208 out:
0209 return ret;
0210 }
0211
0212
0213
0214
0215
0216
0217
0218
0219 expublic int cmd_mmon(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0220 {
0221 int ret=EXSUCCEED;
0222
0223 if (NULL!=ndrx_G_shmcfg)
0224 {
0225 ndrx_G_shmcfg->is_mmon=1;
0226 __sync_synchronize();
0227 printf("OK\n");
0228 }
0229 else
0230 {
0231 ret = EXFAIL;
0232 }
0233
0234 return ret;
0235 }
0236
0237
0238
0239
0240 expublic int cmd_mmoff(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0241 {
0242 int ret=EXSUCCEED;
0243
0244 if (NULL!=ndrx_G_shmcfg)
0245 {
0246 ndrx_G_shmcfg->is_mmon=0;
0247 __sync_synchronize();
0248 printf("OK\n");
0249 }
0250 else
0251 {
0252 ret = EXFAIL;
0253 }
0254
0255 return ret;
0256 }
0257
0258