00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00059 #include "ims_pm.h"
00060
00061
00062 #ifdef WITH_IMS_PM
00063
00064 #include <unistd.h>
00065 #include <fcntl.h>
00066 #include <time.h>
00067
00068 #include "mod.h"
00069 #include "../../script_cb.h"
00070 #include "../tm/tm_load.h"
00071
00072 #include "sip.h"
00073
00074 str log_prefix;
00075
00076 str log_header={"#\n#\n# Time,Node Type, Node Name, Event, String parameter 1, String Parameter 2, Integer parameter 1, Integer parameter 2\n",0};
00077
00078 int fd_log=0;
00079 FILE *f_log=0;
00080
00081 str ims_pm_event_types[] = {
00082 {"OP.NOP",6},
00083 {"OP.NodeStart",12},
00084 {"OP.NodeStop",11},
00085
00086 {"UR.AttInitReg",13},
00087 {"UR.SuccInitReg",14},
00088 {"UR.FailInitReg",14},
00089 {"UR.MeanInitRegSetupTime",23},
00090
00091 {"UR.AttReReg",11},
00092 {"UR.SuccReReg",12},
00093 {"UR.FailReReg",12},
00094 {"UR.MeanReRegSetupTime",21},
00095
00096 {"UR.AttDeRegUe",13},
00097 {"UR.SuccDeRegUe",14},
00098 {"UR.FailDeRegUe",14},
00099 {"UR.MeanDeRegUeSetupTime",23},
00100
00101 {"UR.AttDeRegHss",14},
00102 {"UR.SuccDeRegHss",15},
00103 {"UR.FailDeRegHss",15},
00104 {"UR.MeanDeRegHssSetupTime",24},
00105
00106 {"UR.AttDeRegCscf",15},
00107 {"UR.SuccDeRegCscf",16},
00108 {"UR.FailDeRegCscf",16},
00109 {"UR.MeanDeRegCscfSetupTime",25},
00110
00111 {"UR.Att3rdPartyReg",17},
00112 {"UR.Succ3rdPartyReg",18},
00113 {"UR.Fail3rdPartyReg",18},
00114 {"UR.Mean3rdPartyRegSetupTime",27},
00115
00116 {"UR.AttUAR",9},
00117 {"UR.SuccUAA",10},
00118 {"UR.FailUAA",10},
00119 {"UR.MeanUATime",13},
00120
00121 {"UR.AttSAR",9},
00122 {"UR.SuccSAA",10},
00123 {"UR.FailSAA",10},
00124 {"UR.MeanSATime",13},
00125
00126 {"SC.AttSession",13},
00127 {"SC.SuccSession",14},
00128 {"SC.AnsSession",13},
00129 {"SC.FailSession",14},
00130 {"SC.NbrSimulAnsSessionMax",25},
00131
00132 {"LIQ.AttLIR",10},
00133 {"LIQ.SuccLIA",11},
00134 {"LIQ.FailLIA",11},
00135 {"LIQ.MeanLITime",14},
00136
00137 {"IC.AttSessionFromOtherNtwkDmn",29},
00138 {"IC.403SessionFromOtherNtwkDmn",29},
00139 {"IC.AttSessionToOtherNtwkDmn",27},
00140 {"IC.403SessionToOtherNtwkDmn",27},
00141
00142 {"RU.AttInitRegOfVisitUsers",25},
00143 {"RU.Nbr3InitRegOfVisitUsers",26},
00144 {"RU.RmgUsersOut",14},
00145
00146 {"MA.AttMAR",9},
00147 {"MA.SuccMAA",10},
00148 {"MA.FailMAA",10},
00149 {"MA.MeanMATime",13},
00150
00151 {"UP.AttPPR",9},
00152 {"UP.SuccPPA",10},
00153 {"UP.FailPPA",10},
00154 {"UP.MeanPPTime",13},
00155
00156 {"OTHER.Att",9},
00157 {"OTHER.Succ",10},
00158 {"OTHER.Fail",10},
00159 {"OTHER.MeanTime",14},
00160
00161 {"RD.NbrIMPU",10},
00162 {"RD.NbrContact",13},
00163 {"RD.NbrSubs",10},
00164 {"RD.NbrIPSecSA",13},
00165 {"RD.NbrTLSSA",11},
00166 {"RD.NbrNATPinHoles",17},
00167 {"RD.NbrDialogs",13},
00168 {"RD.NbrAV",8},
00169
00170 {"DBU.NbrImsSubscription",22},
00171 {"DBU.NbrPriUserId",16},
00172 {"DBU.NbrSipPubUserId",19},
00173 {"DBU.NbrTelPubUserId",19},
00174 {"DBU.NbrPriSrvId",15},
00175 {"DBU.NbrSipPubSrvId",18},
00176 {"DBU.NbrTelPubSrvId",18},
00177
00178 {"DBU.NbrRegPubUserId",19},
00179 {"DBU.NbrUnregPubUserId",21},
00180 {"DBU.NbrRegPriUsrId",18},
00181
00182 {"DTR.AttUDR",10},
00183 {"DTR.SuccUDA",11},
00184 {"DTR.FailUDA",11},
00185 {"DTR.FailUDA.NoReply",19},
00186 {"DTR.MeanUDTime",14},
00187
00188 {"DTR.AttPUR",10},
00189 {"DTR.SuccPUA",11},
00190 {"DTR.FailPUA",11},
00191 {"DTR.MeanPUTime",14},
00192
00193 {"SUB.AttSNR",10},
00194 {"SUB.SuccSNA",11},
00195 {"SUB.FailSNA",11},
00196 {"SUB.MeanSNTime",14},
00197
00198 {"NOTIF.AttPNR",12},
00199 {"NOTIF.SuccPNA",13},
00200 {"NOTIF.FailPNA",13},
00201 {"NOTIF.MeanSNTime",16},
00202
00203
00204 {0,0}
00205 };
00206
00207
00208 static str zero={0,0};
00209
00210 void ims_pm_init(str node_name,char* type, char *file_name)
00211 {
00212 log_prefix.len = 1+strlen(type)+1+node_name.len+1;
00213 log_prefix.s = pkg_malloc(log_prefix.len);
00214 if (!log_prefix.s) {
00215 LOG(L_ERR,"ERR:"M_NAME":ims_pm_init(): Error alocating %d bytes\n",log_prefix.len);
00216 log_prefix.len=0;
00217 return;
00218 }
00219 log_prefix.len=0;
00220
00221 log_prefix.s[log_prefix.len++]=',';
00222
00223 memcpy(log_prefix.s+log_prefix.len,type,strlen(type));
00224 log_prefix.len+=strlen(type);
00225
00226 log_prefix.s[log_prefix.len++]=',';
00227
00228 memcpy(log_prefix.s+log_prefix.len,node_name.s,node_name.len);
00229 log_prefix.len+=node_name.len;
00230
00231 log_prefix.s[log_prefix.len++]=',';
00232
00233 fd_log = open(file_name,O_WRONLY|O_APPEND|O_CREAT|O_NONBLOCK);
00234 if (fd_log<0){
00235 LOG(L_ERR,"ERR:"M_NAME":ims_pm_init(): Error opening fd logger file %s : %s\n",file_name,strerror(errno));
00236 fd_log = 0;
00237 return;
00238 }
00239 f_log = fdopen(fd_log,"a");
00240 if (!f_log){
00241 LOG(L_ERR,"ERR:"M_NAME":ims_pm_init(): Error opening logger file %s : %s\n",file_name,strerror(errno));
00242 close(fd_log);
00243 fd_log=0;
00244 return;
00245 }
00246
00247 log_header.len = strlen(log_header.s);
00248
00249 if (write(fd_log,log_header.s,log_header.len)<0){
00250 LOG(L_ERR,"ERR:"M_NAME":ims_pm_init(): Error writing to IMS PM log file: %s\n",strerror(errno));
00251 }
00252 IMS_PM_LOG(OP_NodeStart);
00253
00254 }
00255
00256 void ims_pm_destroy()
00257 {
00258 IMS_PM_LOG(OP_NodeStop);
00259 if (fd_log) close(fd_log);
00260 }
00261
00262 void ims_pm_log(enum _ims_pm_event_types event,str ps1,str ps2,int pi1,int pi2)
00263 {
00264 fprintf(f_log,"%u%.*s%.*s,%.*s,%.*s,%d,%d\n",
00265 (unsigned int)time(0),
00266 log_prefix.len,log_prefix.s,
00267 ims_pm_event_types[event].len,ims_pm_event_types[event].s,
00268 ps1.len,ps1.s,
00269 ps2.len,ps2.s,
00270 pi1,
00271 pi2);
00272
00273
00274
00275
00276
00277
00278
00279
00280 #if IMS_PM_DEBUG
00281 fflush(f_log);
00282 #endif
00283 }
00284
00285
00286
00287 #endif