Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add methods for sand box-id to process #163

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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