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 <stdio.h>
0035 #include <stdlib.h>
0036 #include <string.h>
0037 #include <errno.h>
0038 #include <regex.h>
0039 #include <utlist.h>
0040 #include <unistd.h>
0041 #include <signal.h>
0042 #include <fcntl.h>
0043
0044 #include <ndebug.h>
0045 #include <atmi.h>
0046 #include <atmi_int.h>
0047 #include <typed_buf.h>
0048 #include <ndrstandard.h>
0049 #include <ubf.h>
0050 #include <Exfields.h>
0051 #include <Excompat.h>
0052 #include <ubfutil.h>
0053 #include <sys_unix.h>
0054 #include <gencall.h>
0055 #include "tpadmsv.h"
0056 #include "expr.h"
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 typedef struct
0067 {
0068 char servicename[MAXTIDENT+1];
0069 char srvgrp[MAXTIDENT+1];
0070 char state[3+1];
0071 char lmid[MAXTIDENT+1];
0072 long srvid;
0073 char svcrname[MAXTIDENT+1];
0074 long ncompleted;
0075 long totsuccnum;
0076 long totsfailnum;
0077 long lastexectimeusec;
0078 long maxexectimeusec;
0079 long minexectimeusec;
0080 } ndrx_adm_svcgrp_t;
0081
0082
0083
0084
0085 expublic ndrx_adm_elmap_t ndrx_G_svcgrp_map[] =
0086 {
0087
0088 {TA_LMID, TPADM_EL(ndrx_adm_svcgrp_t, lmid)}
0089 ,{TA_SERVICENAME, TPADM_EL(ndrx_adm_svcgrp_t, servicename)}
0090 ,{TA_SRVGRP, TPADM_EL(ndrx_adm_svcgrp_t, srvgrp)}
0091 ,{TA_STATE, TPADM_EL(ndrx_adm_svcgrp_t, state)}
0092 ,{TA_SRVID, TPADM_EL(ndrx_adm_svcgrp_t, srvid)}
0093 ,{TA_SVCRNAM, TPADM_EL(ndrx_adm_svcgrp_t, svcrname)}
0094 ,{TA_NCOMPLETED, TPADM_EL(ndrx_adm_svcgrp_t, ncompleted)}
0095 ,{TA_TOTSUCCNUM, TPADM_EL(ndrx_adm_svcgrp_t, totsuccnum)}
0096 ,{TA_TOTSFAILNUM, TPADM_EL(ndrx_adm_svcgrp_t, totsfailnum)}
0097 ,{TA_LASTEXECTIMEUSEC, TPADM_EL(ndrx_adm_svcgrp_t, lastexectimeusec)}
0098 ,{TA_MAXEXECTIMEUSEC, TPADM_EL(ndrx_adm_svcgrp_t, maxexectimeusec)}
0099 ,{TA_MINEXECTIMEUSEC, TPADM_EL(ndrx_adm_svcgrp_t, minexectimeusec)}
0100 ,{BBADFLDID}
0101 };
0102
0103
0104
0105
0106 exprivate ndrx_adm_cursors_t *M_cursnew;
0107 exprivate int M_idx = 0;
0108
0109
0110
0111
0112
0113
0114
0115
0116 exprivate int ndrx_adm_svcgrp_proc_list(command_reply_t *reply, size_t reply_len)
0117 {
0118 command_reply_psc_t * psc_info = (command_reply_psc_t*)reply;
0119 int ret = EXSUCCEED;
0120 int i;
0121 if (NDRXD_CALL_TYPE_SVCINFO!=reply->msg_type)
0122 {
0123
0124 goto out;
0125 }
0126
0127 NDRX_LOG(log_debug, "psc out srvid: [%d]", psc_info->srvid);
0128
0129 for (i=0; i<psc_info->svc_count; i++)
0130 {
0131
0132 ndrx_adm_svcgrp_t svc;
0133 memset(&svc, 0, sizeof(svc));
0134
0135 NDRX_STRCPY_SAFE(svc.servicename, psc_info->svcdet[i].svc_nm);
0136 snprintf(svc.srvgrp, sizeof(svc.srvgrp), "%d/%d", psc_info->nodeid,
0137 psc_info->srvid);
0138 NDRX_STRCPY_SAFE(svc.state, "ACT");
0139 snprintf(svc.lmid, sizeof(svc.lmid), "%d", psc_info->nodeid);
0140 svc.srvid = psc_info->srvid;
0141 NDRX_STRCPY_SAFE(svc.svcrname,psc_info->svcdet[i].fn_nm);
0142 svc.ncompleted = psc_info->svcdet[i].done+psc_info->svcdet[i].fail;
0143
0144 if (svc.ncompleted < -1)
0145 {
0146 svc.ncompleted = -1;
0147 }
0148 svc.totsuccnum = psc_info->svcdet[i].done;
0149 svc.totsfailnum = psc_info->svcdet[i].fail;
0150 svc.lastexectimeusec = psc_info->svcdet[i].last *1000;
0151 svc.maxexectimeusec = psc_info->svcdet[i].max*1000;
0152 svc.minexectimeusec = psc_info->svcdet[i].min*1000;
0153
0154 if (svc.lastexectimeusec < -1)
0155 {
0156 svc.lastexectimeusec = -1;
0157 }
0158
0159 if (svc.maxexectimeusec < -1)
0160 {
0161 svc.maxexectimeusec = -1;
0162 }
0163
0164 if (svc.minexectimeusec < -1)
0165 {
0166 svc.minexectimeusec = -1;
0167 }
0168
0169 if (EXSUCCEED!=ndrx_growlist_add(&M_cursnew->list, (void *)&svc, M_idx))
0170 {
0171 NDRX_LOG(log_error, "Growlist failed - out of memory?");
0172 EXFAIL_OUT(ret);
0173 }
0174
0175 NDRX_LOG(log_debug, "Service added [%s] / [%s]", svc.servicename, svc.srvgrp);
0176 M_idx++;
0177
0178 }
0179
0180 out:
0181 return ret;
0182 }
0183
0184
0185
0186
0187
0188
0189
0190 expublic int ndrx_adm_svcgrp_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags)
0191 {
0192 int ret = EXSUCCEED;
0193
0194
0195 M_idx = 0;
0196
0197 ndrx_growlist_init(&cursnew->list, 100, sizeof(ndrx_adm_svcgrp_t));
0198
0199 M_cursnew = cursnew;
0200 cursnew->map = ndrx_G_svcgrp_map;
0201
0202 if (EXSUCCEED!=ndrx_adm_list_call(ndrx_adm_svcgrp_proc_list,
0203 NDRXD_COM_PSC_RQ, NDRXD_COM_PSC_RP, ndrx_get_G_atmi_conf()->ndrxd_q_str))
0204 {
0205 NDRX_LOG(log_error, "Failed to call PSC");
0206 EXFAIL_OUT(ret);
0207 }
0208
0209 out:
0210
0211 if (EXSUCCEED!=ret)
0212 {
0213 ndrx_growlist_free(&M_cursnew->list);
0214 }
0215
0216 return ret;
0217 }
0218
0219