Skip to content

Commit

Permalink
add print sinsp_event
Browse files Browse the repository at this point in the history
  • Loading branch information
jundizhou committed Jun 30, 2022
1 parent 73b8fcc commit f95779b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions probe/src/cgo/kindling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "sinsp_capture_interrupt_exception.h"
#include <iostream>
#include <cstdlib>
#include <stdlib.h>

static sinsp *inspector = nullptr;

sinsp_evt_formatter *formatter = nullptr;
bool printEvent = false;
int cnt = 0;
map<string, ppm_event_type> m_events;
map<string, Category> m_categories;
Expand Down Expand Up @@ -61,11 +63,15 @@ void sub_event(char *eventName, char *category)
void init_probe()
{
bool bpf = false;
char* isPrintEvent = getenv("IS_PRINT_EVENT");
if (isPrintEvent != nullptr && strncmp("true", isPrintEvent, sizeof (isPrintEvent))==0){
printEvent = true;
}
string bpf_probe;
inspector = new sinsp();
init_sub_label();
string output_format;
output_format = "*%evt.num %evt.outputtime %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info";
string output_format = "*%evt.num %evt.outputtime %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info";
formatter = new sinsp_evt_formatter(inspector, output_format);
try
{
inspector = new sinsp();
Expand Down Expand Up @@ -167,7 +173,12 @@ int getEvent(void **pp_kindling_event)
{
return -1;
}

if(printEvent){
string line;
if (formatter->tostring(ev, &line)) {
cout<< line << endl;
}
}
kindling_event_t_for_go *p_kindling_event;
if(nullptr == *pp_kindling_event)
{
Expand Down

0 comments on commit f95779b

Please sign in to comment.