-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'task/#22605-publish_event_on_oom_process_termination' i…
…nto 'integration' Task #22605 : plugin for oom killer invoked event added See merge request elektrobit/base-os/elos!93
- Loading branch information
Showing
17 changed files
with
537 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/lib/*/elos/scanner/scanner_oomkiller.so |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-License-Identifier: MIT | ||
find_package(safu 0.50.1 REQUIRED) | ||
find_package(samconf 0.50.1 REQUIRED) | ||
|
||
add_library( | ||
scanner_oomkiller SHARED | ||
private/OomKillerScanner.c | ||
private/OomKillerScannerPlugin.c | ||
) | ||
|
||
create_interface_library( | ||
FROM | ||
scanner_oomkiller | ||
LIBRARIES | ||
safu::safu_interface | ||
samconf::samconf_interface | ||
) | ||
|
||
set_target_properties(scanner_oomkiller PROPERTIES PREFIX "") | ||
|
||
target_link_libraries( | ||
scanner_oomkiller | ||
PUBLIC | ||
scanner_oomkiller_interface | ||
elos_common_interface | ||
eventlogging_interface | ||
libelosplugin | ||
eventfilter_static | ||
samconf::samconf | ||
safu::safu | ||
) | ||
|
||
target_include_directories( | ||
scanner_oomkiller | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
if (INSTALL_ELOS_PLUGINS) | ||
install(TARGETS scanner_oomkiller DESTINATION ${ELOSD_SCANNER_PATH}) | ||
endif() |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Oom killer invoked event scanner | ||
================================ | ||
|
||
This scanner runs a subscription filter every `10ms` on kernel message events via a regex filter that filters | ||
the `kmsg` events for `oom killer invocation`. When an event matches the scanner then the scanner publishes a | ||
new event with `messageCode 5020`, `appName` the application terminated and its corresponding `pid`. |
84 changes: 84 additions & 0 deletions
84
src/plugins/scanners/oomkiller/interface/OomKillerScanner.h
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
#include <safu/log.h> | ||
#include <stdlib.h> | ||
|
||
#include "elos/libelosplugin/libelosplugin.h" | ||
#include "safu/common.h" | ||
|
||
/******************************************************************* | ||
* Members: | ||
* oomEventSubscriber : the event subscriber structure | ||
* oomEventPublisher : the event publisher structure | ||
* oomEventSubscription : the subscription structure | ||
******************************************************************/ | ||
typedef struct elosOomKillerScanner { | ||
struct elosSubscriber *oomEventSubscriber; | ||
struct elosPublisher *oomEventPublisher; | ||
const elosSubscription_t *oomEventSubscription; | ||
} elosOomKillerScanner_t; | ||
|
||
/************************************************************************* | ||
* Allocate a new `elosOomKillerScanner`. It shall be safe to call | ||
* `elosOomKillerScannerStop` event when a `SAFU_RESULT_FAILED` is returned | ||
* | ||
* Parameters: | ||
* oomKillerScanner : pointer to a `elosOomKillerScanner` pointer to | ||
* be set to the new OomKillerScanner. In case of | ||
* an error it is unchanged. | ||
* plugin : pointer to plugin context to which scanner members | ||
* are bound to | ||
* | ||
* Returns: | ||
* - `SAFU_RESULT_OK` on success | ||
* - `SAFU_RESULT_FAILED` on failure | ||
***************************************************************************/ | ||
safuResultE_t elosOomKillerScannerNew(elosOomKillerScanner_t **oomKillerScanner, elosPlugin_t *plugin); | ||
|
||
/******************************************************************* | ||
* Start scanning ksmg log events for oom killer invocation. Publish | ||
* matched events. | ||
* | ||
* Parameters: | ||
* oomKillerScanner : pointer to `elosOomKillerScanner` with subscriber | ||
* and subscription to match a oom killer invoked event | ||
* and a publisher to publish matched events | ||
* plugin : pointer to plugin context to which scanner members | ||
* are bound to | ||
* | ||
* Returns: | ||
* - `SAFU_RESULT_OK` on success | ||
* - `SAFU_RESULT_FAILED` on failure | ||
********************************************************************/ | ||
safuResultE_t elosOomKillerScannerStart(elosOomKillerScanner_t *oomKillerScanner, elosPlugin_t *plugin); | ||
|
||
/******************************************************************* | ||
* Delete a `elosOomKillerScannerDelete`. It delete the `elosOomKillerScanner` | ||
* | ||
* Parameters: | ||
* oomKillerScanner : pointer to a `elosOomKillerScanner_t` to be deleted. | ||
* plugin : pointer to plugin context to which scanner members | ||
* are bound to | ||
* | ||
* Returns: | ||
* - `SAFU_RESULT_OK` on success | ||
* - `SAFU_RESULT_FAILED` on failure | ||
******************************************************************/ | ||
safuResultE_t elosOomKillerScannerDelete(elosOomKillerScanner_t *oomKillerScanner, elosPlugin_t *plugin); | ||
|
||
/******************************************************************* | ||
* Stop the oomKillerScanner plugin to stop scanning ksmg events for | ||
* oom killer ivocation event | ||
* | ||
* Parameters: | ||
* oomKillerScanner : pointer to `elosOomKillerScanner` with subscriber | ||
* and subscription to match a oom killer invoked event | ||
* and a publisher to publish matched events | ||
* | ||
* Returns: | ||
* - `SAFU_RESULT_OK` on success | ||
* - `SAFU_RESULT_FAILED` on failure | ||
********************************************************************/ | ||
safuResultE_t elosOomKillerScannerStop(elosOomKillerScanner_t *oomKillerScanner); |
Oops, something went wrong.