X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=RIC-E2-TERMINATION%2FsctpThread.cpp;h=55f90833ec011a944d4293c5b462061f79d800b4;hb=c9d8d2891c793e9b90ae0f4d91e32e28df0faef1;hp=3d00a62f236890f3dce3acfd7b81ba7ebb368393;hpb=64f37244f88f852bf25fd7f680a9a94e4d251097;p=ric-plt%2Fe2.git diff --git a/RIC-E2-TERMINATION/sctpThread.cpp b/RIC-E2-TERMINATION/sctpThread.cpp index 3d00a62..55f9083 100644 --- a/RIC-E2-TERMINATION/sctpThread.cpp +++ b/RIC-E2-TERMINATION/sctpThread.cpp @@ -60,6 +60,22 @@ boost::shared_ptr> boostLogger double cpuClock = 0.0; bool jsonTrace = false; +char* getinterfaceip() +{ + char hostname[256]; + char *IP; + struct hostent *host_entry; + int retVal; + retVal = gethostname(hostname, sizeof(hostname)); + if ( retVal == -1 ) + return NULL; + host_entry = gethostbyname(hostname); + if ( host_entry == NULL ) + return NULL; + IP = inet_ntoa(*((struct in_addr*) host_entry->h_addr_list[0])); + return IP; +} + static int enable_log_change_notify(const char* fileName) { @@ -129,7 +145,7 @@ static void * monitor_loglevel_change_handler(void* arg) #if !(defined(UNIT_TEST) || defined(MODULE_TEST)) if( errno == EAGAIN ) { } else { - fprintf( stderr, "### CRIT ### config listener read err: %s\n", strerror( errno ) ); + printf( "### CRIT ### config listener read err: %s\n", strerror( errno ) ); } continue; #endif @@ -495,6 +511,9 @@ void startPrometheus(sctp_params_t &sctpParams) { if (strstr(podName, "alpha") != NULL) { metric = "E2TAlpha"; } + //Get eth0 interface IP + char* host = getinterfaceip(); + string hostip = host; sctpParams.prometheusFamily = &BuildCounter() .Name(metric.c_str()) @@ -505,7 +524,12 @@ void startPrometheus(sctp_params_t &sctpParams) { // Build E2T instance level metrics buildE2TPrometheusCounters(sctpParams); - string prometheusPath = sctpParams.prometheusPort + "," + "[::]:" + sctpParams.prometheusPort; + string prometheusPath; + if (hostip.empty()) + prometheusPath = sctpParams.prometheusPort + "," + "[::]:" + sctpParams.prometheusPort; + else + prometheusPath = hostip + ":" + sctpParams.prometheusPort; + if (mdclog_level_get() >= MDCLOG_DEBUG) { mdclog_write(MDCLOG_DEBUG, "Start Prometheus Pull mode on %s", prometheusPath.c_str()); } @@ -812,6 +836,10 @@ void listener(sctp_params_t *params) { continue; } mdclog_write(MDCLOG_ERR, "Epoll wait failed, errno = %s", strerror(errno)); + if(events) + { + free(events); + } return; #endif } @@ -2861,7 +2889,7 @@ int receiveXappMessages(Sctp_Map_t *sctpMap, } else if (rmrMessageBuffer.rcvMessage->state != 0) { mdclog_write(MDCLOG_ERR, "Failed to send RIC_HEALTH_CHECK_RESP, on RMR state = %d ( %s)", rmrMessageBuffer.rcvMessage->state, translateRmrErrorMessages(rmrMessageBuffer.rcvMessage->state).c_str()); - } else if (loglevel >= MDCLOG_DEBUG && ++counter % 100 == 0) { + } else if (loglevel >= MDCLOG_DEBUG && (++counter % 100 == 0)) { mdclog_write(MDCLOG_DEBUG, "Got %d RIC_HEALTH_CHECK_REQ Request send : OK", counter); }