btop: Install btop and run it on the console
`btop` is so much better than `top`. It makes a really nice status indicator for machine health, so I like running it on tty1.
This commit is contained in:
3
hosts
3
hosts
@@ -7,6 +7,9 @@ file0.pyrocufflink.blue
|
|||||||
[bitwarden_rs]
|
[bitwarden_rs]
|
||||||
bw0.pyrocufflink.blue
|
bw0.pyrocufflink.blue
|
||||||
|
|
||||||
|
[btop]
|
||||||
|
chromie.pyrocufflink.blue
|
||||||
|
|
||||||
[burp-client]
|
[burp-client]
|
||||||
bw0.pyrocufflink.blue
|
bw0.pyrocufflink.blue
|
||||||
cloud0.pyrocufflink.blue
|
cloud0.pyrocufflink.blue
|
||||||
|
|||||||
33
roles/btop/files/btop.service
Normal file
33
roles/btop/files/btop.service
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# vim: set ft=systemd :
|
||||||
|
[Unit]
|
||||||
|
Description=Run btop on tty1
|
||||||
|
After=systemd-user-sessions.service
|
||||||
|
Conflicts=getty@tty1.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
RuntimeDirectory=%N
|
||||||
|
LogsDirectory=%N
|
||||||
|
Environment=XDG_CONFIG_HOME=%t
|
||||||
|
Environment=LANG=en_US.UTF-8
|
||||||
|
# btop *requires* write access to its configuration file, or it won't
|
||||||
|
# even read it. Thus, we copy the file from /etc to /run and tell
|
||||||
|
# btop to use the ephemeral, writable copy.
|
||||||
|
ExecStartPre=-/bin/cp %E/%N/btop.conf %t/%N/btop.conf
|
||||||
|
ExecStartPre=-/bin/ln -s %L/%N/btop.log %t/%N/btop.log
|
||||||
|
ExecStart=/usr/bin/btop
|
||||||
|
StandardInput=tty
|
||||||
|
StandardOutput=tty
|
||||||
|
StandardError=journal+console
|
||||||
|
TTYPath=/dev/tty1
|
||||||
|
Restart=always
|
||||||
|
CapabilityBoundingSet=
|
||||||
|
ProtectSystem=strict
|
||||||
|
DeviceAllow=/dev/tty1
|
||||||
|
DevicePolicy=closed
|
||||||
|
ProtectKernelTunables=yes
|
||||||
|
ProtectKernelModules=true
|
||||||
|
ProtectControlGroups=yes
|
||||||
|
NoNewPrivileges=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
8
roles/btop/handlers/main.yml
Normal file
8
roles/btop/handlers/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
- name: reload systemd
|
||||||
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: restart btop
|
||||||
|
service:
|
||||||
|
name: btop
|
||||||
|
state: restarted
|
||||||
53
roles/btop/tasks/main.yml
Normal file
53
roles/btop/tasks/main.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
- name: ensure btop is installed
|
||||||
|
package:
|
||||||
|
name: btop
|
||||||
|
state: present
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
|
||||||
|
- name: ensure btop systemd unit is installed
|
||||||
|
copy:
|
||||||
|
src: btop.service
|
||||||
|
dest: /etc/systemd/system/btop.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,go=r
|
||||||
|
notify:
|
||||||
|
- reload systemd
|
||||||
|
- restart btop
|
||||||
|
tags:
|
||||||
|
- systemd
|
||||||
|
|
||||||
|
- name: ensure btop configuration directory exists
|
||||||
|
file:
|
||||||
|
path: /etc/btop
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rwx,go=rx
|
||||||
|
state: directory
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
- name: ensure btop is configured
|
||||||
|
template:
|
||||||
|
src: btop.conf.j2
|
||||||
|
dest: /etc/btop/btop.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,go=r
|
||||||
|
notify:
|
||||||
|
- restart btop
|
||||||
|
tags:
|
||||||
|
- config
|
||||||
|
|
||||||
|
- name: ensure btop service is enabled
|
||||||
|
service:
|
||||||
|
name: btop
|
||||||
|
enabled: true
|
||||||
|
tags:
|
||||||
|
- service
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
- name: ensure btop service is running
|
||||||
|
service:
|
||||||
|
name: btop
|
||||||
|
state: started
|
||||||
3
roles/btop/templates/btop.conf.j2
Normal file
3
roles/btop/templates/btop.conf.j2
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
proc_sorting = "cpu direct"
|
||||||
|
|
||||||
|
log_level = "INFO"
|
||||||
Reference in New Issue
Block a user