Hi,
we are trying to send some custom data from our c++ application to the fluent-bit api (following the instructions here )the following way:
auto sensor1Value = sensor1->GetValue();
auto sensor2Value = sensor2->GetValue();
auto sensor3Value = sensor3->GetValue();
auto sensor4Value = sensor4->GetValue();
std::stringstream jsonstream;
jsonstream << "{\"sensor1\":" << sensor1Value << ",\"sensor2\":" << sensor2Value << ",\"sensor3\":" << sensor3Value << ",\"sensor4\":" << sensor4Value << "}";
std::string jsonString = jsonstream.str();
//WHY ??? If this is called from the console, it works, but not from the application
std::string command = "curl -X POST http://localhost:9999/custom -H 'Content-Type: application/json' -d '"+jsonString+"'";
FILE *file_ptr = ::popen(command.c_str(),"r"); //or system(command.c_str(),)
if(file_ptr)
{
std::cout << "popen succeeded!" << command.c_str() <<std::endl;
}
if (pclose(file_ptr) != 0)
{
std::cout << "pclose failed!" << std::endl;
}
So the problem is, if the “command” string is run via the console on the board (via the VSCode extension->Open Terminal), the new custom metrics sensor1, sensor2, sensor3, … are shown under https://app.torizon.io/ “device metrics”.
But if we just run the C++ application they are not shown!
Could this be a Docker issue, we run our C++ app via the VSCode extension provided Dockerfiles.
We use the following Linux:
Linux verdin-imx8mp-07174514 5.15.129-6.4.0+git.67c3153d20ff #1-TorizonCore SMP PREEMPT Wed Sep 27 12:30:36 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux