-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This plugin triggers kernel panic when executed. This helps capture elusive memory issues which go away after OOM kills. Reviewed By: masoncl Differential Revision: D51082682 fbshipit-source-id: 5af584086353ba3fc833dce80dd7959315201af6
- Loading branch information
1 parent
168fdc2
commit 54bb4db
Showing
3 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2018-present, Facebook, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#include "oomd/plugins/KernelPanic.h" | ||
|
||
#include "oomd/Log.h" | ||
#include "oomd/PluginRegistry.h" | ||
#include "oomd/util/Fs.h" | ||
#include "oomd/util/Util.h" | ||
|
||
namespace Oomd { | ||
|
||
REGISTER_PLUGIN(kernel_panic, KernelPanic::create); | ||
|
||
int KernelPanic::init( | ||
const Engine::PluginArgs& args, | ||
const PluginConstructionContext& /* unused */) { | ||
return argParser_.parse(args) ? 0 : 1; | ||
} | ||
|
||
Engine::PluginRet KernelPanic::run(OomdContext& /* unused */) { | ||
const auto fd = Fs::Fd::open("/proc/sysrq-trigger", false); | ||
if (!fd) { | ||
OLOG << "Failed to open /proc/sysrq-trigger"; | ||
return Engine::PluginRet::CONTINUE; | ||
} | ||
if (Util::writeFull(fd->fd(), "c", 1) != 1) { | ||
OLOG << "Failed to trigger kernel panic"; | ||
return Engine::PluginRet::CONTINUE; | ||
} | ||
return Engine::PluginRet::STOP; | ||
} | ||
|
||
} // namespace Oomd |
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,39 @@ | ||
/* | ||
* Copyright (C) 2018-present, Facebook, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "oomd/engine/BasePlugin.h" | ||
|
||
namespace Oomd { | ||
|
||
class KernelPanic : public Oomd::Engine::BasePlugin { | ||
public: | ||
int init( | ||
const Engine::PluginArgs& args, | ||
const PluginConstructionContext& context) override; | ||
|
||
Engine::PluginRet run(OomdContext& /* unused */) override; | ||
|
||
static KernelPanic* create() { | ||
return new KernelPanic(); | ||
} | ||
|
||
~KernelPanic() override = default; | ||
}; | ||
|
||
} // namespace Oomd |