-
Notifications
You must be signed in to change notification settings - Fork 165
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
new(userspace): plugin api to dump async events #2152
Open
FedeDP
wants to merge
7
commits into
master
Choose a base branch
from
new/plugin_api_dump
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+222
−8
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
727c906
new(userspace): added new plugin API capability to dump plugin state.
FedeDP 7f3e821
chore(userspace/plugin): bumped plugin API version to 3.10.0
FedeDP 0f49887
new(userspace): moved `dump` API under async capability.
FedeDP 510a6d6
chore(userspace/libsinsp): disable plugin_dump test on emscripten.
FedeDP ef8f0cc
chore(userspace/libsinsp): fixed comment string.
FedeDP 2ff9268
new(userspace): `dump` API now takes a `ss_plugin_async_event_handler…
FedeDP 5dbd02e
chore(userspace/libsinsp): call plugin dump API from `fdopen` too.
FedeDP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,68 @@ TEST_F(sinsp_with_test_input, plugin_custom_source) { | |
ASSERT_EQ(next_event(), nullptr); // EOF is expected | ||
} | ||
|
||
class plugin_test_event_processor : public libsinsp::event_processor { | ||
public: | ||
explicit plugin_test_event_processor(const char* ev_name) { | ||
num_async_evts = 0; | ||
event_name = ev_name; | ||
} | ||
|
||
void on_capture_start() override {} | ||
|
||
void process_event(sinsp_evt* evt, libsinsp::event_return rc) override { | ||
if(evt->get_type() == PPME_ASYNCEVENT_E) { | ||
// Retrieve internal event name | ||
auto ev_name = evt->get_param(1)->as<std::string>(); | ||
if(ev_name == event_name) { | ||
num_async_evts++; | ||
} | ||
} | ||
} | ||
|
||
int num_async_evts; | ||
|
||
private: | ||
std::string event_name; | ||
}; | ||
|
||
// scenario: a plugin with dump capability is requested a dump and then the capture file is read. | ||
// note: emscripten has trouble with the nodriver engine and async events | ||
#if !defined(__EMSCRIPTEN__) | ||
TEST_F(sinsp_with_test_input, plugin_dump) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very simple test:
|
||
uint64_t max_count = 1; | ||
uint64_t period_ns = 1000000; // 1ms | ||
std::string async_pl_cfg = std::to_string(max_count) + ":" + std::to_string(period_ns); | ||
register_plugin(&m_inspector, get_plugin_api_sample_syscall_async); | ||
|
||
// we will not use the test scap engine here, but open the src plugin instead | ||
// note: we configure the plugin to just emit 1 event through its open params | ||
m_inspector.open_nodriver(); | ||
|
||
auto evt = next_event(); | ||
ASSERT_NE(evt, nullptr); | ||
ASSERT_EQ(evt->get_type(), PPME_ASYNCEVENT_E); | ||
|
||
auto sinspdumper = sinsp_dumper(); | ||
sinspdumper.open(&m_inspector, "test.scap", false); | ||
sinspdumper.close(); | ||
|
||
m_inspector.close(); | ||
|
||
// Here we open a replay inspector just to trigger the initstate events parsing | ||
auto replay_inspector = sinsp(); | ||
// | ||
auto processor = plugin_test_event_processor("sampleticker"); | ||
replay_inspector.register_external_event_processor(processor); | ||
ASSERT_NO_THROW(replay_inspector.open_savefile("test.scap")); | ||
|
||
ASSERT_EQ(processor.num_async_evts, 10); | ||
|
||
replay_inspector.close(); | ||
remove("test.scap"); | ||
} | ||
#endif | ||
|
||
TEST(sinsp_plugin, plugin_extract_compatibility) { | ||
std::string tmp; | ||
sinsp i; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial state events parsing enablement for
PPME_ASYNCEVENT_E
.