Skip to content

Commit

Permalink
Merge pull request #163 from robbietu/master
Browse files Browse the repository at this point in the history
add methods for sand box-id to process
  • Loading branch information
robbietu authored Jun 7, 2024
2 parents 3f144cb + 05d002b commit a01e255
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endif ()
# set PKTMINERG_MAJOR_VERSION, PKTMINERG_MINOR_VERSION, etc.
set(PKTMINERG_MAJOR_VERSION "0")
set(PKTMINERG_MINOR_VERSION "7")
set(PKTMINERG_PATCH_VERSION "4")
set(PKTMINERG_PATCH_VERSION "5")
set(PKTMINERG_VERSION_STRING "${PKTMINERG_MAJOR_VERSION}.${PKTMINERG_MINOR_VERSION}.${PKTMINERG_PATCH_VERSION}")

if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/daemonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ DaemonManager::DaemonManager(const boost::program_options::variables_map &vm, ti
}
}

daemon_.setClientVersion("0.7.4");
daemon_.setClientVersion("0.7.5");
std::vector<std::string> strs;
split(strs, SUPPORT_API_VERSIONS, boost::algorithm::is_any_of(","));
for (const auto& str:strs) {
Expand Down
33 changes: 28 additions & 5 deletions src/pktminerg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,37 @@ static std::string getProccssIdWithContainer(const std::string &containerId, Log
id = containerId.substr(pos+3);
}

std::string output_buffer = std::string("Get containerId:") + id;
std::string output_buffer = std::string("Get Id:") + id +std::string(" from CPM.");
ctx.log(output_buffer, log4cpp::Priority::INFO);
std::cout << StatisLogContext::getTimeString() << output_buffer << std::endl;
const auto cmd = boost::str(
boost::format("sh /usr/local/bin/get_pid_with_container.sh %1%") % id);
fp=popen(cmd.c_str(),"r");
fgets(buffer,sizeof(buffer),fp);
//get pid with docker
auto cmd = std::string("docker inspect ") + id + std::string("|grep -i \"pid\"");
fp=popen(cmd.c_str(),"r");
if (!fgets(buffer,sizeof(buffer),fp)) {
pclose(fp);
cmd = std::string("crictl inspect ") + id + std::string("|grep -i \"pid\"");
fp=popen(cmd.c_str(),"r");
fgets(buffer,sizeof(buffer),fp);
}
std::cout<<StatisLogContext::getTimeString()<<"Get Pid with docker/crictl:"<<buffer<<std::endl;
pclose(fp);
if (strlen(buffer) != 0) {
std::string pidStr = buffer;
int leftIndex = pidStr.find(":");
int rightIndex = pidStr.find(",");
pidStr = pidStr.substr(leftIndex+1, rightIndex-leftIndex-1);
if (pidStr[0]==' ') {
pidStr = pidStr.substr(1,pidStr.length()-1);
}
std::cout<<StatisLogContext::getTimeString()<<"Get PidNum with docker/crictl:"<<pidStr<<std::endl;
return pidStr;
} else {
auto cmd = boost::str(
boost::format("sh get_pid_with_container.sh %1%") % id);
fp=popen(cmd.c_str(),"r");
fgets(buffer,sizeof(buffer),fp);
pclose(fp);
}

if (strlen(buffer) == 0) {
std::string output_buffer = std::string("Can't get pid for the containerId:") + id;
Expand Down

0 comments on commit a01e255

Please sign in to comment.