add warning_exe option
This commit is contained in:
parent
269b8e958c
commit
81a9f67b5f
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.1 (/usr/local/bin/python3.6)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/nohang.iml" filepath="$PROJECT_DIR$/.idea/nohang.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
11
.idea/nohang.iml
Normal file
11
.idea/nohang.iml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="TestRunnerService">
|
||||||
|
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
155
.idea/workspace.xml
Normal file
155
.idea/workspace.xml
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="1ae39a30-dfc7-4dda-8d17-274c30e136b9" name="Default" comment="" />
|
||||||
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
|
<option name="TRACKING_ENABLED" value="true" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="FileEditorManager">
|
||||||
|
<leaf>
|
||||||
|
<file leaf-file-name="nohang" pinned="false" current-in-tab="true">
|
||||||
|
<entry file="file://$PROJECT_DIR$/nohang">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="228">
|
||||||
|
<caret line="1368" column="50" lean-forward="true" selection-start-line="1368" selection-start-column="50" selection-end-line="1368" selection-end-column="50" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#75#84#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
</leaf>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectFrameBounds" extendedState="6">
|
||||||
|
<option name="x" value="-6" />
|
||||||
|
<option name="y" value="24" />
|
||||||
|
<option name="width" value="1378" />
|
||||||
|
<option name="height" value="726" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectView">
|
||||||
|
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||||
|
<flattenPackages />
|
||||||
|
<showMembers />
|
||||||
|
<showModules />
|
||||||
|
<showLibraryContents />
|
||||||
|
<hideEmptyPackages />
|
||||||
|
<abbreviatePackageNames />
|
||||||
|
<autoscrollToSource />
|
||||||
|
<autoscrollFromSource />
|
||||||
|
<sortByType />
|
||||||
|
<manualOrder />
|
||||||
|
<foldersAlwaysOnTop value="true" />
|
||||||
|
</navigator>
|
||||||
|
<panes>
|
||||||
|
<pane id="Scratches" />
|
||||||
|
<pane id="Scope" />
|
||||||
|
<pane id="ProjectPane">
|
||||||
|
<subPane>
|
||||||
|
<expand>
|
||||||
|
<path>
|
||||||
|
<item name="nohang" type="b2602c69:ProjectViewProjectNode" />
|
||||||
|
<item name="nohang" type="462c0819:PsiDirectoryNode" />
|
||||||
|
</path>
|
||||||
|
</expand>
|
||||||
|
<select />
|
||||||
|
</subPane>
|
||||||
|
</pane>
|
||||||
|
</panes>
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">
|
||||||
|
<property name="last_opened_file_path" value="/usr/local/bin/python3.6" />
|
||||||
|
<property name="SearchEverywhereHistoryKey" value="settings	ACTION	WelcomeScreen.Settings" />
|
||||||
|
<property name="settings.editor.selected.configurable" value="tasks.servers" />
|
||||||
|
</component>
|
||||||
|
<component name="RunDashboard">
|
||||||
|
<option name="ruleStates">
|
||||||
|
<list>
|
||||||
|
<RuleState>
|
||||||
|
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||||
|
</RuleState>
|
||||||
|
<RuleState>
|
||||||
|
<option name="name" value="StatusDashboardGroupingRule" />
|
||||||
|
</RuleState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ShelveChangesManager" show_recycled="false">
|
||||||
|
<option name="remove_strategy" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="1ae39a30-dfc7-4dda-8d17-274c30e136b9" name="Default" comment="" />
|
||||||
|
<created>1553474923472</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1553474923472</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="ToolWindowManager">
|
||||||
|
<frame x="-6" y="24" width="1932" height="1033" extended-state="6" />
|
||||||
|
<editor active="true" />
|
||||||
|
<layout>
|
||||||
|
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1921875" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||||
|
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||||
|
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||||
|
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||||
|
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||||
|
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||||
|
</layout>
|
||||||
|
</component>
|
||||||
|
<component name="VcsContentAnnotationSettings">
|
||||||
|
<option name="myLimit" value="2678400000" />
|
||||||
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager />
|
||||||
|
<watches-manager />
|
||||||
|
</component>
|
||||||
|
<component name="editorHistoryManager">
|
||||||
|
<entry file="file://$PROJECT_DIR$/nohang">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="228">
|
||||||
|
<caret line="1368" column="50" lean-forward="true" selection-start-line="1368" selection-start-column="50" selection-end-line="1368" selection-end-column="50" />
|
||||||
|
<folding>
|
||||||
|
<element signature="e#75#84#0" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</component>
|
||||||
|
<component name="masterDetails">
|
||||||
|
<states>
|
||||||
|
<state key="ScopeChooserConfigurable.UI">
|
||||||
|
<settings>
|
||||||
|
<splitter-proportions>
|
||||||
|
<option name="proportions">
|
||||||
|
<list>
|
||||||
|
<option value="0.2" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</splitter-proportions>
|
||||||
|
</settings>
|
||||||
|
</state>
|
||||||
|
</states>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -240,7 +240,8 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe
|
|||||||
- [x] Reduced memory usage with `mlockall()` using `MCL_ONFAULT` ([rfjakob/earlyoom#112](https://github.com/rfjakob/earlyoom/issues/112)) and lock all memory by default
|
- [x] Reduced memory usage with `mlockall()` using `MCL_ONFAULT` ([rfjakob/earlyoom#112](https://github.com/rfjakob/earlyoom/issues/112)) and lock all memory by default
|
||||||
- [x] Improve poll rate algorithm
|
- [x] Improve poll rate algorithm
|
||||||
- [x] Added `max_post_sigterm_victim_lifetime` option: send SIGKILL to the victim if it doesn't respond to SIGTERM for a certain time
|
- [x] Added `max_post_sigterm_victim_lifetime` option: send SIGKILL to the victim if it doesn't respond to SIGTERM for a certain time
|
||||||
- [x] Added `post_kill_exe` option
|
- [x] Added `post_kill_exe` option (the ability to run any command after killing the victim)
|
||||||
|
- [x] Added `warning_exe` option (the ability to run any command instead of GUI low memory warnings)
|
||||||
- [x] Improve victim search algorithm (do it ~30% faster) ([rfjakob/earlyoom#114](https://github.com/rfjakob/earlyoom/issues/114))
|
- [x] Improve victim search algorithm (do it ~30% faster) ([rfjakob/earlyoom#114](https://github.com/rfjakob/earlyoom/issues/114))
|
||||||
- [x] Improve limiting `oom_score_adj`: now it can works with UID != 0
|
- [x] Improve limiting `oom_score_adj`: now it can works with UID != 0
|
||||||
- [x] Fixed conf parsing: use of `line.partition('=')` instead of `line.split('=')`
|
- [x] Fixed conf parsing: use of `line.partition('=')` instead of `line.split('=')`
|
||||||
|
30
nohang
30
nohang
@ -610,17 +610,24 @@ def send_notify_warn():
|
|||||||
|
|
||||||
t0 = time()
|
t0 = time()
|
||||||
|
|
||||||
|
if check_warning_exe:
|
||||||
|
|
||||||
|
print('Warning threshold exceeded')
|
||||||
|
print('Execute the command: {}'.format(warning_exe))
|
||||||
|
err = os.system(warning_exe)
|
||||||
|
print('Exit code: {}'.format(err))
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
title = 'Low memory'
|
title = 'Low memory'
|
||||||
body = 'MemAvail: {}%\nSwapFree: {}%'.format(
|
body = 'MemAvail: {}%\nSwapFree: {}%'.format(
|
||||||
round(mem_available / mem_total * 100),
|
round(mem_available / mem_total * 100),
|
||||||
round(swap_free / (swap_total + 0.1) * 100)
|
round(swap_free / (swap_total + 0.1) * 100)
|
||||||
)
|
)
|
||||||
|
|
||||||
send_notification(title, body)
|
send_notification(title, body)
|
||||||
|
|
||||||
t1 = time()
|
t1 = time()
|
||||||
|
print('Warning duration:', t1 - t0)
|
||||||
print('t:', t1 - t0)
|
|
||||||
|
|
||||||
|
|
||||||
def send_notify(signal, name, pid):
|
def send_notify(signal, name, pid):
|
||||||
@ -1366,7 +1373,7 @@ print_proc_table_flag = False
|
|||||||
|
|
||||||
if len(argv) == 1:
|
if len(argv) == 1:
|
||||||
if os.path.exists('./nohang.conf'):
|
if os.path.exists('./nohang.conf'):
|
||||||
config = cd = os.getcwd() + '/nohang.conf'
|
config = os.getcwd() + '/nohang.conf'
|
||||||
else:
|
else:
|
||||||
config = '/etc/nohang/nohang.conf'
|
config = '/etc/nohang/nohang.conf'
|
||||||
elif len(argv) == 2:
|
elif len(argv) == 2:
|
||||||
@ -1380,7 +1387,7 @@ elif len(argv) == 2:
|
|||||||
elif argv[1] == '--print-proc-table' or argv[1] == '--ppt':
|
elif argv[1] == '--print-proc-table' or argv[1] == '--ppt':
|
||||||
print_proc_table_flag = True
|
print_proc_table_flag = True
|
||||||
if os.path.exists('./nohang.conf'):
|
if os.path.exists('./nohang.conf'):
|
||||||
config = cd = os.getcwd() + '/nohang.conf'
|
config = os.getcwd() + '/nohang.conf'
|
||||||
else:
|
else:
|
||||||
config = '/etc/nohang/nohang.conf'
|
config = '/etc/nohang/nohang.conf'
|
||||||
else:
|
else:
|
||||||
@ -1805,6 +1812,17 @@ else:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if 'warning_exe' in config_dict:
|
||||||
|
warning_exe = config_dict['warning_exe']
|
||||||
|
if warning_exe != '':
|
||||||
|
check_warning_exe = True
|
||||||
|
else:
|
||||||
|
check_warning_exe = False
|
||||||
|
else:
|
||||||
|
errprint('warning_exe is not in config\nExit')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
print_total_stat = conf_parse_bool('print_total_stat')
|
print_total_stat = conf_parse_bool('print_total_stat')
|
||||||
print_proc_table = conf_parse_bool('print_proc_table')
|
print_proc_table = conf_parse_bool('print_proc_table')
|
||||||
|
|
||||||
@ -1979,6 +1997,7 @@ else:
|
|||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
# outdated section, need fixes
|
||||||
|
|
||||||
if print_config:
|
if print_config:
|
||||||
|
|
||||||
@ -2365,7 +2384,6 @@ while True:
|
|||||||
if warn_timer > min_time_between_warnings:
|
if warn_timer > min_time_between_warnings:
|
||||||
t0 = time()
|
t0 = time()
|
||||||
send_notify_warn()
|
send_notify_warn()
|
||||||
# caused log err
|
|
||||||
log(str(time() - t0) + ' | send notify warning time')
|
log(str(time() - t0) + ' | send notify warning time')
|
||||||
warn_timer = 0
|
warn_timer = 0
|
||||||
|
|
||||||
|
19
nohang.conf
19
nohang.conf
@ -99,7 +99,7 @@ psi_metrics = some_avg10
|
|||||||
sigterm_psi_threshold = 80
|
sigterm_psi_threshold = 80
|
||||||
sigkill_psi_threshold = 90
|
sigkill_psi_threshold = 90
|
||||||
|
|
||||||
psi_post_action_delay = 40
|
psi_post_action_delay = 60
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -316,6 +316,12 @@ gui_notifications = False
|
|||||||
|
|
||||||
gui_low_memory_warnings = False
|
gui_low_memory_warnings = False
|
||||||
|
|
||||||
|
Execute the command instead of sending GUI notifications if the value is
|
||||||
|
not empty line. For example:
|
||||||
|
warning_exe = cat /proc/meminfo &
|
||||||
|
|
||||||
|
warning_exe =
|
||||||
|
|
||||||
Минимальное время между отправками уведомлений в секундах.
|
Минимальное время между отправками уведомлений в секундах.
|
||||||
Valid values are floating-point numbers from the range [1; 300].
|
Valid values are floating-point numbers from the range [1; 300].
|
||||||
|
|
||||||
@ -327,9 +333,9 @@ min_time_between_warnings = 15
|
|||||||
Can be specified in % (percent) and M (MiB).
|
Can be specified in % (percent) and M (MiB).
|
||||||
Valid values are floating-point numbers from the range [0; 100] %.
|
Valid values are floating-point numbers from the range [0; 100] %.
|
||||||
|
|
||||||
mem_min_warnings = 20 %
|
mem_min_warnings = 25 %
|
||||||
|
|
||||||
swap_min_warnings = 20 %
|
swap_min_warnings = 25 %
|
||||||
|
|
||||||
Если доля zram в памяти превысит значение zram_max_warnings,
|
Если доля zram в памяти превысит значение zram_max_warnings,
|
||||||
то будут отправляться уведомления с минимальным периодом равным
|
то будут отправляться уведомления с минимальным периодом равным
|
||||||
@ -340,6 +346,7 @@ zram_max_warnings = 40 %
|
|||||||
Ampersands (&) will be replaced with asterisks (*) in process
|
Ampersands (&) will be replaced with asterisks (*) in process
|
||||||
names and in commands.
|
names and in commands.
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
8. Verbosity
|
8. Verbosity
|
||||||
@ -397,9 +404,9 @@ psi_debug = False
|
|||||||
|
|
||||||
max_post_sigterm_victim_lifetime = 10
|
max_post_sigterm_victim_lifetime = 10
|
||||||
|
|
||||||
Выполнить произвольную команду после SIGKILL.
|
Execute the command after sending SIGKILL to the victim if the value is
|
||||||
Пустая строка - ничего не выполнять.
|
not empty line. For example:
|
||||||
Произвольная строка.
|
warning_exe = cat /proc/meminfo &
|
||||||
|
|
||||||
post_kill_exe =
|
post_kill_exe =
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user