// ************************************************************************** // construct a string with the node number and PIN of the ancestor // executor process and the string ".log". This will be used as the suffix // of the log name. So if the log name specified by the user in the // configuration file is "sql_events", the actual log name will be // something like "sql_events_0_12345.log" // ************************************************************************** void getMyTopAncestor(char ancsNidPid[]) { short result = 0; NAProcessHandle myPhandle; myPhandle.getmine(); myPhandle.decompose(); char processName[MS_MON_MAX_PROCESS_NAME + 1]; char ppName[MS_MON_MAX_PROCESS_NAME + 1]; memset(processName, 0, sizeof(processName)); memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen()); memset(ppName, 0, sizeof(ppName)); MS_Mon_Process_Info_Type procInfo; Int32 rc = 0; Int32 ancsNid = 0; Int32 ancsPid = 0; do { rc = msg_mon_get_process_info_detail(processName, &procInfo); ancsNid = procInfo.nid; ancsPid = procInfo.pid; strcpy(ppName, procInfo.parent_name); strcpy(processName, ppName); } while ((rc == XZFIL_ERR_OK) && (procInfo.parent_nid != -1) && (procInfo.parent_pid != -1)); snprintf (ancsNidPid, 5+2*sizeof(Int32), "_%d_%d.log", ancsNid, ancsPid); }
// ************************************************************************** // construct a string with the node number of the // process and the string ".log". This will be used as the suffix // of the log name forthis process . So if the log name specified by the // user in the // configuration file is "sql_events", the actual log name will be // something like "sql_events_<nid>.log" // ************************************************************************** void getMyNidSuffix(char stringNidSuffix[]) { short result = 0; NAProcessHandle myPhandle; myPhandle.getmine(); myPhandle.decompose(); Int32 myNid = myPhandle.getCpu(); snprintf (stringNidSuffix, 5+sizeof(Int32), "_%d.log", myNid); }
// ************************************************************************** // construct a string with the node number of the // process and the string ".log". This will be used as the suffix // of the log name forthis process . So if the log name specified by the // user in the // configuration file is "sql_events", the actual log name will be // something like "sql_events_<nid>.log" // ************************************************************************** void getMyNidSuffix(char stringNidSuffix[]) { short result = 0; NAProcessHandle myPhandle; myPhandle.getmine(); myPhandle.decompose(); char processName[MS_MON_MAX_PROCESS_NAME + 1]; memset(processName, 0, sizeof(processName)); memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen()); memset(processName, 0, sizeof(processName)); memcpy(processName, myPhandle.getPhandleString(), myPhandle.getPhandleStringLen()); MS_Mon_Process_Info_Type procInfo; Int32 rc = 0; Int32 myNid = 0; do { rc = msg_mon_get_process_info_detail(processName, &procInfo); myNid = procInfo.nid; } while ((rc == XZFIL_ERR_OK) && (procInfo.parent_nid != -1) && (procInfo.parent_pid != -1)); snprintf (stringNidSuffix, 5+sizeof(Int32), "_%d.log", myNid); }
void genLinuxCorefile(const char *eventMsg) { if (eventMsg) SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, eventMsg, 0); NAProcessHandle myPhandle; myPhandle.getmine(); myPhandle.decompose(); char coreFile[PATH_MAX]; msg_mon_dump_process_name(NULL, myPhandle.getPhandleString(), coreFile); char coreLocationMessage[PATH_MAX + 200]; sprintf(coreLocationMessage, "Core-file for this process created at %s.", coreFile); SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, coreLocationMessage, 0); }
// ----------------------------------------------------------------------- // // ComRtGetProgramInfo() // // Outputs: // 1) the pathname of the directory where the application program // is being run from. // For OSS processes, this will be the fully qualified oss directory // pathname. // For Guardian processes, pathname is not set // 2) the process type (oss or guardian). // 3) Other output values are: cpu, pin, nodename, nodename Len, processCreateTime // and processNameString in the format <\node_name>.<cpu>,<pin> // // // Return status: 0, if all ok. <errnum>, in case of an error. // // ----------------------------------------------------------------------- Lng32 ComRtGetProgramInfo(char * pathName, /* out */ Lng32 pathNameMaxLen, short &processType,/* out */ Int32 &cpu, /* cpu */ pid_t &pin, /* pin */ Lng32 &nodeNumber, char * nodeName, // GuaNodeNameMaxLen+1 short &nodeNameLen, Int64 &processCreateTime, char *processNameString, char *parentProcessNameString #ifdef SQ_PHANDLE_VERIFIER , SB_Verif_Type *verifier #endif ) { Lng32 retcode = 0; processType = 2; strcpy(nodeName, "NSK"); nodeNameLen = strlen("NSK"); NAProcessHandle myPhandle; myPhandle.getmine(); myPhandle.decompose(); cpu = myPhandle.getCpu(); pin = myPhandle.getPin(); #ifdef SQ_PHANDLE_VERIFIER if (verifier) *verifier = myPhandle.getSeqNum(); #endif // Map the node number to cpu nodeNumber = cpu; strcpy(processNameString, myPhandle.getPhandleString()); MS_Mon_Process_Info_Type processInfo; if ((retcode = msg_mon_get_process_info_detail( processNameString, &processInfo)) != XZFIL_ERR_OK) return retcode; processCreateTime = ComRtGetJulianFromUTC(processInfo.creation_time); if (processInfo.parent_nid != -1 && processInfo.parent_pid != -1 && parentProcessNameString) strcpy(parentProcessNameString, processInfo.parent_name); else parentProcessNameString = NULL; return retcode; }