add nohang-desktop.service; rename psi-monitor to psi2log; update Makefile

This commit is contained in:
Alexey Avramov 2019-11-24 06:03:25 +09:00
parent aef8af62ed
commit 9f23c47776
6 changed files with 49 additions and 60 deletions

View File

@ -4,16 +4,11 @@ language: python
sudo: required
before_install:
- sudo apt-get install -y pylint3
script:
- sudo make install
- sudo make systemd
- sudo systemctl enable --now nohang
- sudo systemctl stop nohang.service
- make pylint
- oom-sort -h
- oom-sort
@ -21,6 +16,7 @@ script:
- nohang -v
- nohang -cc /etc/nohang/nohang.conf
- nohang -cc /etc/nohang/nohang-desktop.conf
- nohang -cc nohang/test.conf
- nohang -p

View File

@ -6,7 +6,7 @@ LOGDIR ?= /var/log
SYSTEMDUNITDIR ?= /etc/systemd/system
all:
@ echo "Use: make install, make systemd, make uninstall"
@ echo "Use: make install, make uninstall"
install:
install -d $(DESTDIR)$(BINDIR)
@ -14,7 +14,7 @@ install:
install -m0755 nohang/nohang $(DESTDIR)$(BINDIR)/nohang
install -m0755 tools/oom-sort $(DESTDIR)$(BINDIR)/oom-sort
install -m0755 tools/psi-top $(DESTDIR)$(BINDIR)/psi-top
install -m0755 tools/psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor
install -m0755 tools/psi2log $(DESTDIR)$(BINDIR)/psi2log
install -d $(DESTDIR)$(CONFDIR)/nohang
-git describe --tags --long --dirty > version
@ -24,38 +24,7 @@ install:
install -m0644 nohang/nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf
install -m0644 nohang/nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default
install -m0644 nohang/nohang-desktop.conf $(DESTDIR)$(CONFDIR)/nohang/nohang-desktop.conf
install -d $(DESTDIR)$(CONFDIR)/logrotate.d
install -m0644 nohang/nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang
install -d $(DESTDIR)$(MANDIR)
gzip -c nohang/nohang.1 > $(DESTDIR)$(MANDIR)/nohang.1.gz
gzip -c tools/oom-sort.1 > $(DESTDIR)$(MANDIR)/oom-sort.1.gz
gzip -c tools/psi-top.1 > $(DESTDIR)$(MANDIR)/psi-top.1.gz
gzip -c tools/psi-monitor.1 > $(DESTDIR)$(MANDIR)/psi-monitor.1.gz
-install -d $(DESTDIR)$(SYSTEMDUNITDIR)
-sed "s|:TARGET_BIN:|$(BINDIR)|g;s|:TARGET_CONF:|$(CONFDIR)|g" nohang/nohang.service.in > nohang.service
-install -m0644 nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
-rm -fv nohang.service
-chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
install-desktop:
install -d $(DESTDIR)$(BINDIR)
install -m0755 nohang/nohang $(DESTDIR)$(BINDIR)/nohang
install -m0755 tools/oom-sort $(DESTDIR)$(BINDIR)/oom-sort
install -m0755 tools/psi-top $(DESTDIR)$(BINDIR)/psi-top
install -m0755 tools/psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor
install -d $(DESTDIR)$(CONFDIR)/nohang
-git describe --tags --long --dirty > version
-install -m0644 version $(DESTDIR)$(CONFDIR)/nohang/version
-rm -fv version
install -m0644 nohang/nohang-desktop.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf
install -m0644 nohang/nohang-desktop.conf $(DESTDIR)$(CONFDIR)/nohang/nohang-desktop.conf.default
install -m0644 nohang/nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default
install -d $(DESTDIR)$(CONFDIR)/logrotate.d
install -m0644 nohang/nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang
@ -64,40 +33,36 @@ install-desktop:
gzip -c nohang/nohang.1 > $(DESTDIR)$(MANDIR)/nohang.1.gz
gzip -c tools/oom-sort.1 > $(DESTDIR)$(MANDIR)/oom-sort.1.gz
gzip -c tools/psi-top.1 > $(DESTDIR)$(MANDIR)/psi-top.1.gz
gzip -c tools/psi-monitor.1 > $(DESTDIR)$(MANDIR)/psi-monitor.1.gz
gzip -c tools/psi2log.1 > $(DESTDIR)$(MANDIR)/psi2log.1.gz
-install -d $(DESTDIR)$(SYSTEMDUNITDIR)
-sed "s|:TARGET_BIN:|$(BINDIR)|g;s|:TARGET_CONF:|$(CONFDIR)|g" nohang/nohang.service.in > nohang.service
-sed "s|:TARGET_BIN:|$(BINDIR)|g;s|:TARGET_CONF:|$(CONFDIR)|g" nohang/nohang-desktop.service.in > nohang-desktop.service
-install -m0644 nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
-install -m0644 nohang-desktop.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang-desktop.service
-rm -fv nohang.service
-rm -fv nohang-desktop.service
-chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
-chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang-desktop.service
-systemctl daemon-reload
uninstall:
# 'make uninstall' must not fail with error if systemctl is unavailable or returns error
-systemctl stop nohang.service || true
-systemctl stop nohang-desktop.service || true
-systemctl disable nohang.service || true
-systemctl disable nohang-desktop.service || true
-systemctl daemon-reload
rm -fv $(DESTDIR)$(BINDIR)/nohang
rm -fv $(DESTDIR)$(BINDIR)/oom-sort
rm -fv $(DESTDIR)$(BINDIR)/psi-top
rm -fv $(DESTDIR)$(BINDIR)/psi-monitor
rm -fv $(DESTDIR)$(BINDIR)/psi2log
rm -fv $(DESTDIR)$(MANDIR)/nohang.1.gz
rm -fv $(DESTDIR)$(MANDIR)/oom-sort.1.gz
rm -fv $(DESTDIR)$(MANDIR)/psi-top.1.gz
rm -fv $(DESTDIR)$(MANDIR)/psi-monitor.1.gz
rm -fv $(DESTDIR)$(MANDIR)/psi2log.1.gz
rm -fv $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service
rm -fv $(DESTDIR)$(SYSTEMDUNITDIR)/nohang-desktop.service
rm -fvr $(DESTDIR)$(CONFDIR)/nohang/
rm -fvr $(DESTDIR)$(CONFDIR)/logrotate.d/nohang
rm -fvr $(DESTDIR)$(LOGDIR)/nohang/
systemd:
-systemctl daemon-reload
-systemctl enable nohang.service
-systemctl restart nohang
-systemctl status nohang
pylint:
-pylint3 -E nohang/nohang
-pylint3 -E tools/oom-sort
-pylint3 -E tools/psi-top
-pylint3 -E tools/psi-monitor

View File

@ -0,0 +1,28 @@
[Unit]
Description=Highly configurable OOM prevention daemon
Documentation=man:nohang(1) https://github.com/hakavlad/nohang
Conflicts=nohang.service
After=system.slice
[Service]
ExecStart=:TARGET_BIN:/nohang --config :TARGET_CONF:/nohang/nohang-desktop.conf
Restart=always
RestartSec=0
KillMode=mixed
TasksMax=100
Nice=-15
CPUSchedulingResetOnFork=true
OOMScoreAdjust=-10
UMask=0027
PrivateTmp=true
RestrictRealtime=yes
MemoryDenyWriteExecute=yes
ProtectKernelModules=true
SystemCallArchitectures=native
ReadOnlyPaths=/
ReadWritePaths=/tmp /var /run /dev/shm
CapabilityBoundingSet=CAP_KILL CAP_IPC_LOCK CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_AUDIT_WRITE CAP_SETUID CAP_SETGID
AmbientCapabilities=CAP_KILL CAP_IPC_LOCK CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_AUDIT_WRITE CAP_SETUID CAP_SETGID
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +0,0 @@
.TH psi-monitor 1
.SH NAME
psi-monitor \- PSI metrics monitor

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""psi-monitor"""
"""psi2log"""
import os
from time import sleep

5
tools/psi2log.1 Normal file
View File

@ -0,0 +1,5 @@
.TH psi2log 1
.SH NAME
psi2log \- PSI metrics monitor and logger